Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge SLHC updates for CaloTowers #11940

Merged
merged 18 commits into from Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
154 changes: 154 additions & 0 deletions CondTools/Geometry/plugins/calowriters.cc
Expand Up @@ -166,6 +166,160 @@ CaloGeometryDBEP<HcalGeometry, CaloGeometryDBWriter>::produceAligned( const type

return ptr ;
}

template<>
CaloGeometryDBEP<CaloTowerGeometry, CaloGeometryDBWriter>::PtrType
CaloGeometryDBEP<CaloTowerGeometry, CaloGeometryDBWriter>::produceAligned( const typename CaloTowerGeometry::AlignedRecord& iRecord ) {

const Alignments* alignPtr ( 0 ) ;
const Alignments* globalPtr ( 0 ) ;
if( m_applyAlignment ) { // get ptr if necessary
edm::ESHandle< Alignments > alignments ;
iRecord.getRecord< typename CaloTowerGeometry::AlignmentRecord >().get( alignments ) ;

assert( alignments.isValid() && // require valid alignments and expected sizet
( alignments->m_align.size() == CaloTowerGeometry::numberOfAlignments() ) ) ;
alignPtr = alignments.product() ;

edm::ESHandle< Alignments > globals ;
iRecord.getRecord<GlobalPositionRcd>().get( globals ) ;

assert( globals.isValid() ) ;
globalPtr = globals.product() ;
}

TrVec tvec ;
DimVec dvec ;
IVec ivec ;
IVec dins ;

if( CaloGeometryDBWriter::writeFlag() ) {
edm::ESHandle<CaloSubdetectorGeometry> pG ;
iRecord.get( CaloTowerGeometry::producerTag() + std::string("_master"), pG ) ;

const CaloSubdetectorGeometry* pGptr ( pG.product() ) ;

pGptr->getSummary( tvec, ivec, dvec, dins ) ;

CaloGeometryDBWriter::writeIndexed( tvec, dvec, ivec, dins, CaloTowerGeometry::dbString() ) ;
} else {
edm::ESHandle<PCaloGeometry> pG ;
iRecord.getRecord<typename CaloTowerGeometry::PGeometryRecord >().get( pG ) ;

tvec = pG->getTranslation() ;
dvec = pG->getDimension() ;
ivec = pG->getIndexes() ;
dins = pG->getDenseIndices();
}
//*********************************************************************************************

edm::ESHandle<CaloTowerTopology> caloTopology;
iRecord.getRecord<HcalRecNumberingRecord>().get( caloTopology );


CaloTowerGeometry* ctg=new CaloTowerGeometry( &*caloTopology );

const unsigned int nTrParm ( tvec.size()/ctg->numberOfCellsForCorners() ) ;

assert( dvec.size() == ctg->numberOfShapes() * CaloTowerGeometry::k_NumberOfParametersPerShape ) ;


PtrType ptr ( ctg ) ;

ptr->fillDefaultNamedParameters() ;

ptr->allocateCorners( ctg->numberOfCellsForCorners() ) ;

ptr->allocatePar( dvec.size() ,
CaloTowerGeometry::k_NumberOfParametersPerShape ) ;

for( unsigned int i ( 0 ) ; i < dins.size() ; ++i ) {
const unsigned int nPerShape ( ctg->numberOfParametersPerShape() ) ;
DimVec dims ;
dims.reserve( nPerShape ) ;

const unsigned int indx ( ivec.size()==1 ? 0 : i ) ;

DimVec::const_iterator dsrc ( dvec.begin() + ivec[indx]*nPerShape ) ;

for( unsigned int j ( 0 ) ; j != nPerShape ; ++j ) {
dims.push_back( *dsrc ) ;
++dsrc ;
}

const CCGFloat* myParm ( CaloCellGeometry::getParmPtr( dims,
ptr->parMgr(),
ptr->parVecVec() ));


const DetId id ( caloTopology->detIdFromDenseIndex(dins[i]) ) ;

const unsigned int iGlob ( 0 == globalPtr ? 0 :
ctg->alignmentTransformIndexGlobal( id ) ) ;

assert( 0 == globalPtr || iGlob < globalPtr->m_align.size() ) ;

const AlignTransform* gt ( 0 == globalPtr ? 0 : &globalPtr->m_align[ iGlob ] ) ;

assert( 0 == gt || iGlob == ctg->alignmentTransformIndexGlobal( DetId( gt->rawId() ) ) ) ;

const unsigned int iLoc ( 0 == alignPtr ? 0 :
ctg->alignmentTransformIndexLocal( id ) ) ;

assert( 0 == alignPtr || iLoc < alignPtr->m_align.size() ) ;

const AlignTransform* at ( 0 == alignPtr ? 0 :
&alignPtr->m_align[ iLoc ] ) ;

assert( 0 == at || ( ctg->alignmentTransformIndexLocal( DetId( at->rawId() ) ) == iLoc ) ) ;

const CaloGenericDetId gId ( id ) ;

Pt3D lRef ;
Pt3DVec lc ( 8, Pt3D(0,0,0) ) ;
ctg->localCorners( lc, &dims.front(), dins[i], lRef ) ;

const Pt3D lBck ( 0.25*(lc[4]+lc[5]+lc[6]+lc[7] ) ) ; // ctr rear face in local
const Pt3D lCor ( lc[0] ) ;

//----------------------------------- create transform from 6 numbers ---
const unsigned int jj ( i*nTrParm ) ;
Tr3D tr ;
const ROOT::Math::Translation3D tl ( tvec[jj], tvec[jj+1], tvec[jj+2] ) ;
const ROOT::Math::EulerAngles ea (
6==nTrParm ?
ROOT::Math::EulerAngles( tvec[jj+3], tvec[jj+4], tvec[jj+5] ) :
ROOT::Math::EulerAngles() ) ;
const ROOT::Math::Transform3D rt ( ea, tl ) ;
double xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz;
rt.GetComponents(xx,xy,xz,dx,yx,yy,yz,dy,zx,zy,zz,dz) ;
tr = Tr3D( CLHEP::HepRep3x3( xx, xy, xz,
yx, yy, yz,
zx, zy, zz ),
CLHEP::Hep3Vector(dx,dy,dz) );

// now prepend alignment(s) for final transform
const Tr3D atr ( 0 == at ? tr :
( 0 == gt ? at->transform()*tr :
at->transform()*gt->transform()*tr ) ) ;
//--------------------------------- done making transform ---------------

const Pt3D gRef ( atr*lRef ) ;
const GlobalPoint fCtr ( gRef.x(), gRef.y(), gRef.z() ) ;
const Pt3D gBck ( atr*lBck ) ;
const GlobalPoint fBck ( gBck.x(), gBck.y(), gBck.z() ) ;
const Pt3D gCor ( atr*lCor ) ;
const GlobalPoint fCor ( gCor.x(), gCor.y(), gCor.z() ) ;

assert( caloTopology->denseIndex(id) == dins[i] );

ptr->newCell( fCtr, fBck, fCor, myParm, id ) ;
}

ptr->initializeParms() ; // initializations; must happen after cells filled

return ptr ;
}

template class CaloGeometryDBEP< EcalBarrelGeometry , CaloGeometryDBWriter> ;
template class CaloGeometryDBEP< EcalEndcapGeometry , CaloGeometryDBWriter> ;
Expand Down
26 changes: 13 additions & 13 deletions Configuration/AlCa/python/autoCond.py
Expand Up @@ -2,31 +2,31 @@

### NEW KEYS ###
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run1
'run1_design' : '76X_mcRun1_design_v7',
'run1_design' : '76X_mcRun1_design_v8',
# GlobalTag for MC production (pp collisions) with realistic alignment and calibrations for Run1
'run1_mc' : '76X_mcRun1_realistic_v7',
'run1_mc' : '76X_mcRun1_realistic_v8',
# GlobalTag for MC production (Heavy Ions collisions) with realistic alignment and calibrations for Run1
'run1_mc_hi' : '76X_mcRun1_HeavyIon_v7',
'run1_mc_hi' : '76X_mcRun1_HeavyIon_v8',
# GlobalTag for MC production (p-Pb collisions) with realistic alignment and calibrations for Run1
'run1_mc_pa' : '76X_mcRun1_pA_v7',
'run1_mc_pa' : '76X_mcRun1_pA_v8',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Run2
'run2_design' : '76X_mcRun2_design_v7',
'run2_design' : '76X_mcRun2_design_v8',
# GlobalTag for MC production with pessimistic alignment and calibrations for Run2
'run2_mc_50ns' : '76X_mcRun2_startup_v7',
'run2_mc_50ns' : '76X_mcRun2_startup_v8',
#GlobalTag for MC production with optimistic alignment and calibrations for Run2
'run2_mc' : '76X_mcRun2_asymptotic_v7',
'run2_mc' : '76X_mcRun2_asymptotic_v8',
# GlobalTag for MC production (Heavy Ions collisions) with optimistic alignment and calibrations for Run2
'run2_mc_hi' : '76X_mcRun2_HeavyIon_v7',
'run2_mc_hi' : '76X_mcRun2_HeavyIon_v8',
# GlobalTag for Run1 data reprocessing
'run1_data' : '76X_dataRun1_v6',
'run1_data' : '76X_dataRun1_v7',
# GlobalTag for Run2 data reprocessing
'run2_data' : '76X_dataRun2_v6',
'run2_data' : '76X_dataRun2_v7',
# GlobalTag for Run1 HLT: it points to the online GT
'run1_hlt' : '76X_dataRun1_HLT_frozen_v6',
'run1_hlt' : '76X_dataRun1_HLT_frozen_v7',
# GlobalTag for Run2 HLT: it points to the online GT
'run2_hlt' : '76X_dataRun2_HLT_frozen_v6',
'run2_hlt' : '76X_dataRun2_HLT_frozen_v7',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2017
'phase1_2017_design' : '76X_upgrade2017_design_v3',
'phase1_2017_design' : '76X_upgrade2017_design_v4',
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase1 2019
'phase1_2019_design' : 'DES19_70_V2', # placeholder (GT not meant for standard RelVal)
# GlobalTag for MC production with perfectly aligned and calibrated detector for Phase2
Expand Down
1 change: 1 addition & 0 deletions DataFormats/CaloTowers/BuildFile.xml
Expand Up @@ -3,6 +3,7 @@
<use name="DataFormats/Math"/>
<use name="FWCore/Utilities"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/HcalDetId"/>

<export>
<lib name="1"/>
Expand Down
31 changes: 25 additions & 6 deletions DataFormats/CaloTowers/interface/CaloTower.h
Expand Up @@ -5,6 +5,7 @@
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
#include "Rtypes.h"
#include <vector>
#include <cmath>
Expand Down Expand Up @@ -67,6 +68,20 @@ class CaloTower : public reco::LeafCandidate {

void setEcalTime(int t) { ecalTime_ = t; };
void setHcalTime(int t) { hcalTime_ = t; };
void setHcalSubdet(int lastHB, int lastHE, int lastHF, int lastHO) {
int ct_ieta = ietaAbs();
if(ct_ieta <= lastHB) subdet_ = HcalBarrel;
else if(ct_ieta <= lastHE) subdet_ = HcalEndcap;
else if(ct_ieta <= lastHF) subdet_ = HcalForward;

//account for HO separately
if(ct_ieta <= lastHO) inHO_ = true;
else inHO_ = false;

//account for gap/crossover tower separately
if(ct_ieta == lastHB) inHBHEgap_ = true;
else inHBHEgap_ = false;
}

// set CaloTower status based on the number of
// bad/recovered/problematic cells in ECAL and HCAL
Expand All @@ -93,12 +108,12 @@ class CaloTower : public reco::LeafCandidate {
// energy in HO ("outerEnergy")is not included in "hadEnergy"
double emEnergy() const { return emE_ ; }
double hadEnergy() const { return hadE_ ; }
double outerEnergy() const { return (id_.ietaAbs()<16)? outerE_ : 0.0; }
double outerEnergy() const { return (inHO_) ? outerE_ : 0.0; }

// transverse energies wrt to vtx (0,0,0)
double emEt() const { return emE_ * sin( theta() ); }
double hadEt() const { return hadE_ * sin( theta() ); }
double outerEt() const { return (id_.ietaAbs()<16)? outerE_ * sin( theta() ) : 0.0; }
double outerEt() const { return (inHO_) ? outerE_ * sin( theta() ) : 0.0; }


// preserve the inherited default accessors where applicable
Expand All @@ -117,7 +132,7 @@ class CaloTower : public reco::LeafCandidate {

double emEt(double vtxZ) const { return emE_ * sin(p4(vtxZ).theta()); }
double hadEt(double vtxZ) const { return hadE_ * sin(p4(vtxZ).theta()); }
double outerEt(double vtxZ) const { return (id_.ietaAbs()<16)? outerE_ * sin(p4(vtxZ).theta()) : 0.0; }
double outerEt(double vtxZ) const { return (inHO_) ? outerE_ * sin(p4(vtxZ).theta()) : 0.0; }

// recalculated wrt vertex provided as 3D point

Expand All @@ -127,7 +142,7 @@ class CaloTower : public reco::LeafCandidate {

double emEt(const Point& v) const { return emE_ * sin(p4(v).theta()); }
double hadEt(const Point& v) const { return hadE_ * sin(p4(v).theta()); }
double outerEt(const Point& v) const { return (id_.ietaAbs()<16)? outerE_ * sin(p4(v).theta()) : 0.0; }
double outerEt(const Point& v) const { return (inHO_) ? outerE_ * sin(p4(v).theta()) : 0.0; }

double hottestCellE() const { return hottestCellE_; }

Expand All @@ -148,8 +163,8 @@ class CaloTower : public reco::LeafCandidate {
int hadLv11() const { return hadLvl1_; }

// energy contained in depths>1 in the HE for 18<|iEta|<29
double hadEnergyHeOuterLayer() const { return (id_.ietaAbs()<18 || id_.ietaAbs()>29)? 0 : outerE_; }
double hadEnergyHeInnerLayer() const { return (id_.ietaAbs()<18 || id_.ietaAbs()>29)? 0 : hadE_ - outerE_; }
double hadEnergyHeOuterLayer() const { return (subdet_ == HcalEndcap) ? outerE_ : 0; }
double hadEnergyHeInnerLayer() const { return (subdet_ == HcalEndcap) ? hadE_ - outerE_ : 0; }

// energy in the tower by HCAL subdetector
// This is trivial except for tower 16
Expand Down Expand Up @@ -198,6 +213,10 @@ class CaloTower : public reco::LeafCandidate {
GlobalPoint emPosition_;
GlobalPoint hadPosition_;

//hcal subdetector info
HcalSubdetector subdet_;
bool inHO_, inHBHEgap_;

// time
int ecalTime_;
int hcalTime_;
Expand Down
27 changes: 0 additions & 27 deletions DataFormats/CaloTowers/interface/CaloTowerDetId.h
Expand Up @@ -33,33 +33,6 @@ class CaloTowerDetId : public DetId {

static const int SubdetId = 1;

static bool validDetId( int ie , int ip ) ;

uint32_t denseIndex() const ;

static CaloTowerDetId detIdFromDenseIndex( uint32_t din ) ;

static bool validDenseIndex( uint32_t din ) { return ( din < kSizeForDenseIndexing ) ; }

enum { kMaxIEta = 41 ,
kMaxIPhi = 72 ,
kBarNPhi = kMaxIPhi ,
kEndNPhi = kMaxIPhi/2 ,
kForNPhi = kMaxIPhi/4 ,
kBarIEta = 20 ,
kEndIEta = 39 ,
kForIEta = kMaxIEta ,
kBarNEta = kBarIEta ,
kEndNEta = kEndIEta - kBarNEta ,
kForNEta = kForIEta - kEndIEta ,
kBarNTot = kBarNPhi*kBarNEta ,
kEndNTot = kEndNPhi*kEndNEta ,
kForNTot = kForNPhi*kForNEta ,
kAllNTot = kBarNTot + kEndNTot + kForNTot ,
kNIndex = 2*kAllNTot } ;

enum { kSizeForDenseIndexing = kNIndex } ;

};

std::ostream& operator<<(std::ostream&, const CaloTowerDetId& id);
Expand Down