CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes

CastorNumberingScheme Class Reference

#include <SimG4CMS/Forward/interface/CastorNumberingScheme.h>

List of all members.

Public Member Functions

 CastorNumberingScheme ()
virtual uint32_t getUnitID (const G4Step *aStep) const
virtual ~CastorNumberingScheme ()

Static Public Member Functions

static uint32_t packIndex (int z, int sector, int zmodule)
static void unpackIndex (const uint32_t &idx, int &z, int &sector, int &zmodule)

Private Types

typedef G4LogicalVolume * lvp

Private Member Functions

void detectorLevel (const G4Step *, int &, int *, lvp *) const

Private Attributes

lvp lvC3EF
lvp lvC3HF
lvp lvC4EF
lvp lvC4HF
lvp lvCAER
lvp lvCAES
lvp lvCAHR
lvp lvCAHS
lvp lvCAST
lvp lvCEDR
lvp lvCEDS
lvp lvCHDR
lvp lvCHDS

Detailed Description

Description: This class manages the UnitID that labels Castor sensitive volumes

Usage: Used in CastorSD to get unique ID of sensitive detector element

Definition at line 31 of file CastorNumberingScheme.h.


Member Typedef Documentation

typedef G4LogicalVolume* CastorNumberingScheme::lvp [private]

Definition at line 58 of file CastorNumberingScheme.h.


Constructor & Destructor Documentation

CastorNumberingScheme::CastorNumberingScheme ( )

Definition at line 15 of file CastorNumberingScheme.cc.

References LogDebug, lvC3EF, lvC3HF, lvC4EF, lvC4HF, lvCAER, lvCAES, lvCAHR, lvCAHS, lvCAST, lvCEDR, lvCEDS, lvCHDR, and lvCHDS.

                                            : lvCAST(0),lvCAES(0),lvCEDS(0),
                                                lvCAHS(0),lvCHDS(0),lvCAER(0),
                                                lvCEDR(0),lvCAHR(0),lvCHDR(0),
                                                lvC3EF(0),lvC3HF(0),lvC4EF(0),
                                                lvC4HF(0) {
  edm::LogInfo("ForwardSim") << "Creating CastorNumberingScheme";
  const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
  std::vector<lvp>::const_iterator lvcite;
  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
    if (strcmp(((*lvcite)->GetName()).c_str(),"CAST") == 0) lvCAST = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CAES") == 0) lvCAES = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CEDS") == 0) lvCEDS = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CAHS") == 0) lvCAHS = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CHDS") == 0) lvCHDS = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CAER") == 0) lvCAER = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CEDR") == 0) lvCEDR = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CAHR") == 0) lvCAHR = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"CHDR") == 0) lvCHDR = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"C3EF") == 0) lvC3EF = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"C3HF") == 0) lvC3HF = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"C4EF") == 0) lvC4EF = (*lvcite);
    if (strcmp(((*lvcite)->GetName()).c_str(),"C4HF") == 0) lvC4HF = (*lvcite);
  }
#ifdef debug
  LogDebug("ForwardSim") << "CastorNumberingScheme:: LogicalVolume pointers\n"
                         << lvCAST << " for CAST; " << lvCAES << " for CAES; "
                         << lvCEDS << " for CEDS; " << lvCAHS << " for CAHS; "
                         << lvCHDS << " for CHDS; " << lvCAER << " for CAER; "
                         << lvCEDR << " for CEDR; " << lvCAHR << " for CAHR; "
                         << lvCHDR << " for CHDR; " << lvC3EF << " for C3EF; "
                         << lvC3HF << " for C3HF; " << lvC4EF << " for C4EF; "
                         << lvC4HF << " for C4HF.";
#endif
}
CastorNumberingScheme::~CastorNumberingScheme ( ) [virtual]

Definition at line 50 of file CastorNumberingScheme.cc.

                                              {
  edm::LogInfo("ForwardSim") << "Deleting CastorNumberingScheme";
}

Member Function Documentation

void CastorNumberingScheme::detectorLevel ( const G4Step *  aStep,
int &  level,
int *  copyno,
lvp lvs 
) const [private]

Definition at line 176 of file CastorNumberingScheme.cc.

References i, and testEve_cfg::level.

Referenced by getUnitID().

                                                                       {
 
  //Get name and copy numbers
  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
  level = 0;
  if (touch) level = ((touch->GetHistoryDepth())+1);
  if (level > 0) {
    for (int ii = 0; ii < level; ii++) {
      int i      = level - ii - 1;
      lvs[ii]    = touch->GetVolume(i)->GetLogicalVolume();
      copyno[ii] = touch->GetReplicaNumber(i);
    }
  }
}
uint32_t CastorNumberingScheme::getUnitID ( const G4Step *  aStep) const [virtual]

Definition at line 54 of file CastorNumberingScheme.cc.

References detectorLevel(), getHLTprescales::index, testEve_cfg::level, LogDebug, lvC3EF, lvC3HF, lvC4EF, lvC4HF, lvCAER, lvCAES, lvCAHR, lvCAHS, lvCAST, lvCEDR, lvCEDS, lvCHDR, lvCHDS, packIndex(), and DetId::rawId().

Referenced by CastorSD::setDetUnitId().

                                                                   {

  uint32_t intindex = 0;

  uint32_t index=0;
  int      level, copyno[20];
  lvp      lvs[20];
  detectorLevel(aStep, level, copyno, lvs);

#ifdef debug
  LogDebug("ForwardSim") << "CastorNumberingScheme number of levels= " <<level;
#endif

  if (level > 0) {

    int zside   = 0;
    int sector  = 0;
    int module = 0;

    //    HcalCastorDetId::Section section;
     for (int ich=0; ich  <  level; ich++) {
       if(lvs[ich] == lvCAST) {
     // Z index +Z = 1 ; -Z = 2
     zside   = copyno[ich];
       } else if(lvs[ich] == lvCAES || lvs[ich] == lvCEDS) {
     // sector number for dead material 1 - 8
     //section = HcalCastorDetId::EM;
     if (copyno[ich]<5) {sector = 5-copyno[ich] ;
          }else{sector = 13-copyno[ich] ;}  
       } else if(lvs[ich] == lvCAHS || lvs[ich] == lvCHDS) {
     // sector number for dead material 1 - 8
     if (copyno[ich]<5) {sector = 5-copyno[ich] ;
          }else{sector = 13-copyno[ich] ;}
      //section = HcalCastorDetId::HAD;
       } else if(lvs[ich] == lvCAER || lvs[ich] == lvCEDR) {
     // zmodule number 1-2 for EM section (2 copies)
     module = copyno[ich];
       } else if(lvs[ich] == lvCAHR || lvs[ich] == lvCHDR) {
     //zmodule number 3-14 for HAD section (12 copies)
     module = copyno[ich] + 2;
       } else if(lvs[ich] == lvC3EF || lvs[ich] == lvC3HF) {
     // sector number for sensitive material 1 - 16
     sector = sector*2  ;
       } else if(lvs[ich] == lvC4EF || lvs[ich] == lvC4HF) {
     // sector number for sensitive material 1 - 16
     sector = sector*2 -1;
       }
   
    
    
#ifdef debug
      LogDebug("ForwardSim") << "CastorNumberingScheme  " << "ich = " << ich  
                             << "copyno" << copyno[ich] << "name = " 
                             << lvs[ich]->GetName();
#endif
    }
    // use for Castor number 9 
    // 
    // Z index +Z = 1 ; -Z = 2
    // sector number 1 - 16
    // zmodule number  1 - 18


    //    int det = 9; 
    //    intindex = packIndex (det, zside, sector, zmodule);

    //intindex = packIndex (section, zside, sector, module);

    intindex = packIndex(zside, sector, module);

    bool true_for_positive_eta = false;
    if(zside == 1)true_for_positive_eta = true;
    if(zside == -1)true_for_positive_eta = false;

    HcalCastorDetId castorId = HcalCastorDetId(true_for_positive_eta, sector, module);
    index = castorId.rawId();

#ifdef debug
    LogDebug("ForwardSim") << "CastorNumberingScheme :" <<" zside "
                           << zside << " sector " << sector << " module " 
                           << module << " UnitID 0x" << std::hex << intindex 
                           << std::dec;
#endif
  }
  return index;
  
}
uint32_t CastorNumberingScheme::packIndex ( int  z,
int  sector,
int  zmodule 
) [static]

pack the Unit ID for Castor
Bits 0- 5: zmodule index
Bits 6- 9: sector index
Bits 10-19: unused
Bit 20: +/- z side
Bits 22-27: unused
Bits 28-31: subdetector
(+z=1,-z=2); sector=1..16, zmodule=1..18;

Definition at line 144 of file CastorNumberingScheme.cc.

References UserOptions_cff::idx.

Referenced by CastorShowerLibraryMaker::FillShowerEvent(), and getUnitID().

                                                                       {
  /*
  uint32_t idx=(section&31)<<28;     //bits 28-31   (21-27 are free for now)
  idx+=((z-1)&1)<<20;                //bits  20  (1...2)
  idx+=(sector&15)<<6;               //bits  6-9 (1...16)
  idx+=(module&63);                 //bits  0-5 (1...18)
  return idx;
  */

  uint32_t idx=((z-1)&1)<<8;       //bit 8
  idx+=(sector&15)<<4;             //bits  4-7 (1...16)
  idx+=(module&15);                 //bits  0-3 (1...14)
  return idx;

}
void CastorNumberingScheme::unpackIndex ( const uint32_t &  idx,
int &  z,
int &  sector,
int &  zmodule 
) [static]

Definition at line 162 of file CastorNumberingScheme.cc.

Referenced by CastorShowerLibraryMaker::FillShowerEvent(), CastorTestAnalysis::getCastorBranchData(), and DoCastorAnalysis::update().

                                                                                             {
  /*
  section = (idx>>28)&31;
  z   = (idx>>20)&1;
  z  += 1;
  sector = (idx>>6)&15;
  module= (idx&63);
  */
  z   = (idx>>8)&1;
  z  += 1;
  sector = (idx>>4)&15;
  module= (idx&15);
}

Member Data Documentation

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 64 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().

Definition at line 63 of file CastorNumberingScheme.h.

Referenced by CastorNumberingScheme(), and getUnitID().