00001 #include "LCDG4CalSDNonProj.hh"
00002 #include "LCDG4CalHit.hh"
00003 #include "LCD_DocumentUtil.hh"
00004 #include "NonProjCalGeometry.hh"
00005 #include "NonProjCalGeomParams.hh"
00006 #include "Util_String.hh"
00007 #include "NPCellID.hh"
00008
00009
00010 #include "G4String.hh"
00011
00012 using std::ofstream;
00013 using std::ios;
00014
00015 XERCES_CPP_NAMESPACE_USE;
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 LCDG4CalSDNonProj::LCDG4CalSDNonProj(G4String name, const DOM_Element& voldb)
00027 : LCDG4CalSD(name)
00028 {
00029 G4cout <<" Creating non-projective LCDG4CalSD..."<< G4endl;
00030
00031
00032 hcalpar = new NonProjCalGeomParams(voldb);
00033
00034
00035 hcal = new NonProjCalGeometry(*hcalpar);
00036
00037
00038
00039 const char* geomfile = getenv("TXTGEOMFILE");
00040
00041 if (geomfile == "") {
00042 G4cerr << "geomfilepath is NULL";
00043 }
00044 else {
00045
00046 if(debugLevel) {
00047 G4cout << "For NonProj geometry parameters, please check:\n";
00048 }
00049 G4cout << "NP geom file: " << geomfile << G4endl;
00050 }
00051
00052 ofstream* outf_hcal = new ofstream(geomfile,ios::app);
00053 if( outf_hcal ) {
00054 *outf_hcal <<"Segmentation:\n\n";
00055 *outf_hcal<<"CalorimeterCell=hep.lcd.geometry.np.NPHADCalorimeterCell\n\n";
00056 *outf_hcal << "innerR= "<< hcalpar->GlobalRmin()/cm << G4endl;
00057 *outf_hcal << "outerR= "<< hcalpar->GlobalRmax()/cm << G4endl;
00058 *outf_hcal << "outerZ= "<< hcalpar->GlobalZmax()/cm << G4endl;
00059 *outf_hcal << "cellLenZ= "<< hcalpar->CellDimZ()/cm << G4endl;
00060 *outf_hcal << "cellLenPhi= "<< hcalpar->CellDimPhi()/cm<<G4endl;
00061 *outf_hcal << "num_layers= "<< hcalpar->NumberOfLayers() << G4endl;
00062 *outf_hcal << "preabs_thick= "<< hcalpar->PreAbsThickness()/cm<< G4endl;
00063 *outf_hcal << "sens_thick= "<< hcalpar->SensorThickness()/cm<< G4endl;
00064 *outf_hcal << "postabs_thick= "<< hcalpar->PostAbsThickness()/cm<< G4endl;
00065 *outf_hcal << "\nend;\n";
00066 outf_hcal->close();
00067 delete outf_hcal;
00068 }
00069 }
00070
00071
00072
00073
00074 LCDG4CalSDNonProj::~LCDG4CalSDNonProj() {
00075 }
00076
00077
00078 unsigned int LCDG4CalSDNonProj::findCell(const G4ThreeVector& pos) {
00079 NPCellID npid = hcal->getClosestCell(pos);
00080 unsigned int cellIndex = npid.packIn32Bits();
00081 return cellIndex;
00082 }
00083
00084
00085 G4ThreeVector LCDG4CalSDNonProj::getCellCenter(unsigned int cellIndex) {
00086
00087
00088
00089 unsigned int& iphi = index[2];
00090 unsigned int& iz = index[3];
00091 iphi = getIndex1(cellIndex);
00092 iz = getIndex2(cellIndex);
00093 NPCellID npid(cellIndex);
00094 G4ThreeVector cellcenter(hcal->getCellCenter(npid));
00095 return cellcenter;
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 unsigned int LCDG4CalSDNonProj::getIndex1(unsigned int cellIndex) const {
00107 return (cellIndex & 0x3fff);
00108 }
00109
00110
00111 unsigned int LCDG4CalSDNonProj::getIndex2(unsigned int cellIndex) const {
00112
00113
00114
00115 return (cellIndex >> 14) & 0xfff;
00116 }
00117
00118
00119 unsigned int LCDG4CalSDNonProj::getIndex3(unsigned int cellIndex) const {
00120 return (cellIndex >> 26) & 0x3f;
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131