CMS 3D CMS Logo

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

HcalTB06BeamSD Class Reference

#include <HcalTB06BeamSD.h>

Inheritance diagram for HcalTB06BeamSD:
CaloSD SensitiveCaloDetector Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const EndOfTrack * > Observer< const EndOfEvent * > SensitiveDetector

List of all members.

Public Member Functions

virtual double getEnergyDeposit (G4Step *)
 HcalTB06BeamSD (G4String, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
virtual uint32_t setDetUnitId (G4Step *step)
virtual ~HcalTB06BeamSD ()

Static Public Member Functions

static uint32_t packIndex (int det, int lay, int x, int y)
static void unpackIndex (const uint32_t &idx, int &det, int &lay, int &x, int &y)

Private Member Functions

std::vector< G4String > getNames (DDFilteredView &)
bool isItWireChamber (G4String)

Private Attributes

double birk1
double birk2
double birk3
G4String matName
bool useBirk
std::vector< G4String > wcNames

Detailed Description

Definition at line 20 of file HcalTB06BeamSD.h.


Constructor & Destructor Documentation

HcalTB06BeamSD::HcalTB06BeamSD ( G4String  name,
const DDCompactView cpv,
SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 21 of file HcalTB06BeamSD.cc.

References DDFilteredView::addFilter(), birk1, birk2, birk3, DDSpecificsFilter::equals, DDFilteredView::firstChild(), g, SensitiveDetector::getNames(), edm::ParameterSet::getParameter(), i, funct::log(), LogDebug, DDFilteredView::logicalPart(), DDLogicalPart::material(), matName, DDName::name(), DDBase< N, C >::name(), DDFilteredView::next(), DDSpecificsFilter::setCriteria(), useBirk, relativeConstraints::value, and wcNames.

                                                               : 
  CaloSD(name, cpv, clg, p, manager) {

  // Values from NIM 80 (1970) 239-244: as implemented in Geant3
  edm::ParameterSet m_HC = p.getParameter<edm::ParameterSet>("HcalTB06BeamSD");
  useBirk    = m_HC.getParameter<bool>("UseBirkLaw");
  birk1      = m_HC.getParameter<double>("BirkC1")*(g/(MeV*cm2));
  birk2      = m_HC.getParameter<double>("BirkC2");
  birk3      = m_HC.getParameter<double>("BirkC3");

  LogDebug("HcalTBSim") <<"***************************************************"
                        << "\n"
                        <<"*                                                 *"
                        << "\n"
                        << "* Constructing a HcalTB06BeamSD  with name " 
                        << name << "\n"
                        <<"*                                                 *"
                        << "\n"
                        <<"***************************************************";

  edm::LogInfo("HcalTBSim") << "HcalTB06BeamSD:: Use of Birks law is set to " 
                            << useBirk << "  with three constants kB = "
                            << birk1 << ", C1 = " <<birk2 << ", C2 = " <<birk3;

  std::string attribute, value;

  // Wire Chamber volume names
  attribute = "Volume";
  value     = "WireChamber";
  DDSpecificsFilter filter1;
  DDValue           ddv1(attribute,value,0);
  filter1.setCriteria(ddv1,DDSpecificsFilter::equals);
  DDFilteredView fv1(cpv);
  fv1.addFilter(filter1);
  wcNames = getNames(fv1);
  edm::LogInfo("HcalTBSim") << "HcalTB06BeamSD:: Names to be tested for " 
                            << attribute << " = " << value << ": " 
                            << wcNames.size() << " paths";
  for (unsigned int i=0; i<wcNames.size(); i++)
    edm::LogInfo("HcalTBSim") << "HcalTB06BeamSD:: (" << i << ") " 
                              << wcNames[i];

  //Material list for scintillator detector
  attribute = "ReadOutName";
  DDSpecificsFilter filter2;
  DDValue           ddv2(attribute,name,0);
  filter2.setCriteria(ddv2,DDSpecificsFilter::equals);
  DDFilteredView fv2(cpv);
  fv2.addFilter(filter2);
  bool dodet = fv2.firstChild();

  std::vector<G4String> matNames;
  std::vector<int>      nocc;
  while (dodet) {
    const DDLogicalPart & log = fv2.logicalPart();
    matName = log.material().name().name();
    bool notIn = true;
    for (unsigned int i=0; i<matNames.size(); i++) 
      if (matName == matNames[i]) {notIn = false; nocc[i]++;}
    if (notIn) {
      matNames.push_back(matName);
      nocc.push_back(0);
    }
    dodet = fv2.next();
  }
  if (matNames.size() > 0) {
    matName = matNames[0];
    int occ = nocc[0];
    for (unsigned int i = 0; i < matNames.size(); i++) {
      if (nocc[i] > occ) {
        occ     = nocc[i];
        matName = matNames[i];
      }
    }
  } else {
    matName = "Not Found";
  }

  edm::LogInfo("HcalTBSim") << "HcalTB06BeamSD: Material name for " 
                            << attribute << " = " << name << ":" << matName;
}
HcalTB06BeamSD::~HcalTB06BeamSD ( ) [virtual]

Definition at line 106 of file HcalTB06BeamSD.cc.

{}

Member Function Documentation

double HcalTB06BeamSD::getEnergyDeposit ( G4Step *  aStep) [virtual]

Reimplemented from CaloSD.

Definition at line 108 of file HcalTB06BeamSD.cc.

References birk1, birk2, birk3, CaloSD::getAttenuation(), LogDebug, matName, useBirk, and CommonMethods::weight().

                                                     {

  double destep = aStep->GetTotalEnergyDeposit();
  double weight = 1;
  if (useBirk) {
    G4Material* mat = aStep->GetPreStepPoint()->GetMaterial();
    if (mat->GetName() == matName)
      weight *= getAttenuation(aStep, birk1, birk2, birk3);
  }
  LogDebug("HcalTBSim") << "HcalTB06BeamSD: Detector " 
                        << aStep->GetPreStepPoint()->GetTouchable()->GetVolume()->GetName()
                        << " weight " << weight;
  return weight*destep;
}
std::vector< G4String > HcalTB06BeamSD::getNames ( DDFilteredView fv) [private]

Definition at line 175 of file HcalTB06BeamSD.cc.

References DDFilteredView::firstChild(), i, funct::log(), DDFilteredView::logicalPart(), SensitiveDetector::name, DDName::name(), DDBase< N, C >::name(), DDFilteredView::next(), convertSQLiteXML::ok, and tmp.

                                                               {
 
  std::vector<G4String> tmp;
  bool dodet = fv.firstChild();
  while (dodet) {
    const DDLogicalPart & log = fv.logicalPart();
    G4String name = log.name().name();
    bool ok = true;
    for (unsigned int i=0; i<tmp.size(); i++)
      if (name == tmp[i]) ok = false;
    if (ok) tmp.push_back(name);
    dodet = fv.next();
  }
  return tmp;
}
bool HcalTB06BeamSD::isItWireChamber ( G4String  name) [private]

Definition at line 191 of file HcalTB06BeamSD.cc.

References wcNames.

Referenced by setDetUnitId().

                                                   {
 
  std::vector<G4String>::const_iterator it = wcNames.begin();
  for (; it != wcNames.end(); it++)
    if (name == *it) return true;
  return false;
}
uint32_t HcalTB06BeamSD::packIndex ( int  det,
int  lay,
int  x,
int  y 
) [static]

Definition at line 145 of file HcalTB06BeamSD.cc.

References ixx, iyy, LogDebug, ExpressReco_HICollisions_FallBack::x, and ExpressReco_HICollisions_FallBack::y.

Referenced by setDetUnitId().

                                                                 {

  int ix = 0, ixx = x;
  if (x < 0) { ix = 1; ixx =-x;}
  int iy = 0, iyy = y;
  if (y < 0) { iy = 1; iyy =-y;}
  uint32_t idx = (det&15)<<28;      //bits 28-31
  idx         += (lay&127)<<21;     //bits 21-27
  idx         += (iy&1)<<19;        //bit  19
  idx         += (iyy&511)<<10;     //bits 10-18
  idx         += (ix&1)<<9;         //bit   9
  idx         += (ixx&511);         //bits  0-8

  LogDebug("HcalTBSim") << "HcalTB06BeamSD: Detector " << det << " Layer "
                        << lay << " x " << x << " " << ix << " " << ixx 
                        << " y " << y << " " << iy << " " << iyy << " ID " 
                        << std::hex << idx << std::dec;
  return idx;
}
uint32_t HcalTB06BeamSD::setDetUnitId ( G4Step *  step) [virtual]

Implements CaloSD.

Definition at line 123 of file HcalTB06BeamSD.cc.

References isItWireChamber(), SensitiveDetector::name, packIndex(), CaloSD::preStepPoint, CaloSD::setToLocal(), ExpressReco_HICollisions_FallBack::x, and ExpressReco_HICollisions_FallBack::y.

                                                    { 

  G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); 
  const G4VTouchable* touch = preStepPoint->GetTouchable();
  G4String name             = preStepPoint->GetPhysicalVolume()->GetName();

  int det = 1;
  int lay = 0, x = 0, y = 0;
  if (!isItWireChamber(name)) {
    lay     = (touch->GetReplicaNumber(0));
  } else {
    det = 2;
    lay = (touch->GetReplicaNumber(1));
    G4ThreeVector hitPoint    = preStepPoint->GetPosition();
    G4ThreeVector localPoint  = setToLocal(hitPoint, touch);
    x   = (int)(localPoint.x()/(0.2*mm));
    y   = (int)(localPoint.y()/(0.2*mm));
  }

  return packIndex (det, lay, x, y);
}
void HcalTB06BeamSD::unpackIndex ( const uint32_t &  idx,
int &  det,
int &  lay,
int &  x,
int &  y 
) [static]

Definition at line 165 of file HcalTB06BeamSD.cc.

References ExpressReco_HICollisions_FallBack::x, and ExpressReco_HICollisions_FallBack::y.

                                                 {

  det  = (idx>>28)&15;
  lay  = (idx>>21)&127;
  y    = (idx>>10)&511; if (((idx>>19)&1) == 1) y = -y;
  x    = (idx)&511;     if (((idx>>9)&1)  == 1) x = -x;

}

Member Data Documentation

double HcalTB06BeamSD::birk1 [private]

Definition at line 39 of file HcalTB06BeamSD.h.

Referenced by getEnergyDeposit(), and HcalTB06BeamSD().

double HcalTB06BeamSD::birk2 [private]

Definition at line 39 of file HcalTB06BeamSD.h.

Referenced by getEnergyDeposit(), and HcalTB06BeamSD().

double HcalTB06BeamSD::birk3 [private]

Definition at line 39 of file HcalTB06BeamSD.h.

Referenced by getEnergyDeposit(), and HcalTB06BeamSD().

G4String HcalTB06BeamSD::matName [private]

Definition at line 41 of file HcalTB06BeamSD.h.

Referenced by getEnergyDeposit(), and HcalTB06BeamSD().

bool HcalTB06BeamSD::useBirk [private]

Definition at line 38 of file HcalTB06BeamSD.h.

Referenced by getEnergyDeposit(), and HcalTB06BeamSD().

std::vector<G4String> HcalTB06BeamSD::wcNames [private]

Definition at line 40 of file HcalTB06BeamSD.h.

Referenced by HcalTB06BeamSD(), and isItWireChamber().