CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
CastorSD Class Reference

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

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

Public Member Functions

 CastorSD (G4String, const DDCompactView &, SensitiveDetectorCatalog &clg, edm::ParameterSet const &, const SimTrackManager *)
 
virtual double getEnergyDeposit (G4Step *)
 
virtual uint32_t setDetUnitId (G4Step *step)
 
void setNumberingScheme (CastorNumberingScheme *scheme)
 
virtual ~CastorSD ()
 
- Public Member Functions inherited from CaloSD
 CaloSD (G4String aSDname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, int tSlice=1, bool ignoreTkID=false)
 
virtual void clear ()
 
virtual void DrawAll ()
 
virtual void EndOfEvent (G4HCofThisEvent *eventHC)
 
void fillHits (edm::PCaloHitContainer &, std::string n)
 
virtual void Initialize (G4HCofThisEvent *HCE)
 
virtual void PrintAll ()
 
virtual bool ProcessHits (G4Step *step, G4TouchableHistory *tHistory)
 
virtual bool ProcessHits (G4GFlashSpot *aSpot, G4TouchableHistory *)
 
virtual ~CaloSD ()
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
virtual void AssignSD (std::string &vname)
 
Local3DPoint ConvertToLocal3DPoint (G4ThreeVector point)
 
Local3DPoint FinalStepPosition (G4Step *s, coordinates)
 
virtual std::vector< std::string > getNames ()
 
Local3DPoint InitialStepPosition (G4Step *s, coordinates)
 
std::string nameOfSD ()
 
void NaNTrap (G4Step *step)
 
void Register ()
 
 SensitiveDetector (std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
virtual ~SensitiveDetector ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent *iT)
 
virtual ~Observer ()
 

Protected Member Functions

virtual void initRun ()
 
- Protected Member Functions inherited from CaloSD
G4bool checkHit ()
 
virtual void clearHits ()
 
CaloG4HitcreateNewHit ()
 
virtual bool filterHit (CaloG4Hit *, double)
 
double getAttenuation (G4Step *aStep, double birk1, double birk2, double birk3)
 
virtual uint16_t getDepth (G4Step *)
 
double getResponseWt (G4Track *)
 
virtual G4bool getStepInfo (G4Step *aStep)
 
virtual int getTrackID (G4Track *)
 
G4bool hitExists ()
 
void resetForNewPrimary (G4ThreeVector, double)
 
G4ThreeVector setToLocal (G4ThreeVector, const G4VTouchable *)
 
virtual void update (const BeginOfRun *)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const BeginOfEvent *)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const BeginOfTrack *trk)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const EndOfTrack *trk)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const ::EndOfEvent *)
 
void updateHit (CaloG4Hit *)
 
- Protected Member Functions inherited from Observer< const EndOfEvent * >
virtual void update (const EndOfEvent *)=0
 This routine will be called when the appropriate signal arrives. More...
 

Private Member Functions

void getFromLibrary (G4Step *)
 
uint32_t rotateUnitID (uint32_t, G4Track *, CastorShowerEvent)
 
int setTrackID (G4Step *)
 

Private Attributes

double energyThresholdSL
 
G4LogicalVolume * lvC3EF
 
G4LogicalVolume * lvC3HF
 
G4LogicalVolume * lvC4EF
 
G4LogicalVolume * lvC4HF
 
G4LogicalVolume * lvCAST
 
CastorNumberingSchemenumberingScheme
 
CastorShowerLibraryshowerLibrary
 
bool useShowerLibrary
 

Additional Inherited Members

- Public Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Attributes inherited from CaloSD
int checkHits
 
double correctT
 
bool corrTOFBeam
 
CaloG4HitcurrentHit
 
CaloHitID currentID
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double eminHitD
 
G4int emPDG
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
G4int epPDG
 
bool forceSave
 
G4int gammaPDG
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
const SimTrackManagerm_trackManager
 
G4ThreeVector posGlobal
 
G4StepPoint * preStepPoint
 
CaloHitID previousID
 
int primIDSaved
 
bool runInit
 
bool suppressHeavy
 
G4Track * theTrack
 
double tmaxHit
 
bool useMap
 

Detailed Description

Description: Stores hits of Castor in appropriate container

Usage: Used in sensitive detector builder

Definition at line 30 of file CastorSD.h.

Constructor & Destructor Documentation

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

Definition at line 30 of file CastorSD.cc.

References energyThresholdSL, edm::ParameterSet::getParameter(), lvC3EF, lvC3HF, lvC4EF, lvC4HF, lvCAST, setNumberingScheme(), showerLibrary, and useShowerLibrary.

33  :
34  CaloSD(name, cpv, clg, p, manager), numberingScheme(0), lvC3EF(0),
35  lvC3HF(0), lvC4EF(0), lvC4HF(0), lvCAST(0) {
36 
37  edm::ParameterSet m_CastorSD = p.getParameter<edm::ParameterSet>("CastorSD");
38  useShowerLibrary = m_CastorSD.getParameter<bool>("useShowerLibrary");
39  energyThresholdSL = m_CastorSD.getParameter<double>("minEnergyInGeVforUsingSLibrary");
40  energyThresholdSL = energyThresholdSL*GeV; // Convert GeV => MeV
41 
42  if (useShowerLibrary) showerLibrary = new CastorShowerLibrary(name, p);
43 
45 
46  edm::LogInfo("ForwardSim")
47  << "***************************************************\n"
48  << "* *\n"
49  << "* Constructing a CastorSD with name " << GetName() << "\n"
50  << "* *\n"
51  << "***************************************************";
52 
53  const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
54  std::vector<G4LogicalVolume*>::const_iterator lvcite;
55  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
56  if (strcmp(((*lvcite)->GetName()).c_str(),"C3EF") == 0) lvC3EF = (*lvcite);
57  if (strcmp(((*lvcite)->GetName()).c_str(),"C3HF") == 0) lvC3HF = (*lvcite);
58  if (strcmp(((*lvcite)->GetName()).c_str(),"C4EF") == 0) lvC4EF = (*lvcite);
59  if (strcmp(((*lvcite)->GetName()).c_str(),"C4HF") == 0) lvC4HF = (*lvcite);
60  if (strcmp(((*lvcite)->GetName()).c_str(),"CAST") == 0) lvCAST = (*lvcite);
61  if (lvC3EF != 0 && lvC3HF != 0 && lvC4EF != 0 && lvC4HF != 0 && lvCAST != 0) break;
62  }
63  edm::LogInfo("ForwardSim") << "CastorSD:: LogicalVolume pointers\n"
64  << lvC3EF << " for C3EF; " << lvC3HF
65  << " for C3HF; " << lvC4EF << " for C4EF; "
66  << lvC4HF << " for C4HF; "
67  << lvCAST << " for CAST. " << std::endl;
68 
69  // if(useShowerLibrary) edm::LogInfo("ForwardSim") << "\n Using Castor Shower Library \n";
70 
71 }
T getParameter(std::string const &) const
CastorNumberingScheme * numberingScheme
Definition: CastorSD.h:46
bool useShowerLibrary
Definition: CastorSD.h:51
G4LogicalVolume * lvC4HF
Definition: CastorSD.h:48
CaloSD(G4String aSDname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, int tSlice=1, bool ignoreTkID=false)
Definition: CaloSD.cc:21
G4LogicalVolume * lvC3HF
Definition: CastorSD.h:48
double energyThresholdSL
Definition: CastorSD.h:52
G4LogicalVolume * lvC4EF
Definition: CastorSD.h:48
G4LogicalVolume * lvCAST
Definition: CastorSD.h:49
CastorShowerLibrary * showerLibrary
Definition: CastorSD.h:47
void setNumberingScheme(CastorNumberingScheme *scheme)
Definition: CastorSD.cc:510
G4LogicalVolume * lvC3EF
Definition: CastorSD.h:48
CastorSD::~CastorSD ( )
virtual

Definition at line 75 of file CastorSD.cc.

References showerLibrary, and useShowerLibrary.

75  {
76  if (useShowerLibrary) delete showerLibrary;
77 }
bool useShowerLibrary
Definition: CastorSD.h:51
CastorShowerLibrary * showerLibrary
Definition: CastorSD.h:47

Member Function Documentation

double CastorSD::getEnergyDeposit ( G4Step *  aStep)
virtual

Reimplemented from CaloSD.

Definition at line 92 of file CastorSD.cc.

References a, abs, beta, DeDxDiscriminatorTools::charge(), dot(), energyThresholdSL, eta(), getFromLibrary(), funct::log(), LogDebug, lvC3EF, lvC3HF, lvC4EF, lvC4HF, lvCAST, M_PI, max(), min, SensitiveDetector::name, NULL, ExpressReco_HICollisions_FallBack::particleType, phi, pi, CaloSD::preStepPoint, csvReporter::r, dttmaxenums::R, mathSSE::sqrt(), funct::tan(), theta(), CaloSD::theTrack, and useShowerLibrary.

92  {
93 
94  float NCherPhot = 0.;
95 
96  if (aStep == NULL) {
97  return 0;
98  } else {
99  // preStepPoint information *********************************************
100 
101  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
102  G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
103  G4LogicalVolume* currentLV = currentPV->GetLogicalVolume();
104  G4String name = currentPV->GetName();
105  std::string nameVolume;
106  nameVolume.assign(name,0,4);
107 
108 #ifdef debugLog
109  G4SteppingControl stepControlFlag = aStep->GetControlFlag();
110  if (aStep->IsFirstStepInVolume())
111  LogDebug("ForwardSim") << "CastorSD::getEnergyDeposit:"
112  << "\n IsFirstStepInVolume " ;
113 #endif
114 
115  // Get theTrack
116  G4Track* theTrack = aStep->GetTrack();
117 
118 #ifdef debugLog
119  if (useShowerLibrary && currentLV==lvCAST) {
120  LogDebug("ForwardSim") << "CastorSD::getEnergyDeposit:"
121  << "\n TrackID , ParentID , ParticleName ,"
122  << " eta , phi , z , time ,"
123  << " K , E , Mom "
124  << "\n TRACKINFO: "
125  << theTrack->GetTrackID()
126  << " , "
127  << theTrack->GetParentID()
128  << " , "
129  << theTrack->GetDefinition()->GetParticleName()
130  << " , "
131  << theTrack->GetPosition().eta()
132  << " , "
133  << theTrack->GetPosition().phi()
134  << " , "
135  << theTrack->GetPosition().z()
136  << " , "
137  << theTrack->GetGlobalTime()
138  << " , "
139  << theTrack->GetKineticEnergy()
140  << " , "
141  << theTrack->GetTotalEnergy()
142  << " , "
143  << theTrack->GetMomentum().mag() ;
144  if(theTrack->GetTrackID() != 1)
145  LogDebug("ForwardSim") << "CastorSD::getEnergyDeposit:"
146  << "\n CurrentStepNumber , TrackID , Particle , VertexPosition ,"
147  << " LogicalVolumeAtVertex , CreatorProcess"
148  << "\n TRACKINFO2: "
149  << theTrack->GetCurrentStepNumber()
150  << " , "
151  << theTrack->GetTrackID()
152  << " , "
153  << theTrack->GetDefinition()->GetParticleName()
154  << " , "
155  << theTrack->GetVertexPosition()
156  << " , "
157  << theTrack->GetLogicalVolumeAtVertex()->GetName()
158  << " , "
159  << theTrack->GetCreatorProcess()->GetProcessName() ;
160  } // end of if(useShowerLibrary)
161 #endif
162 
163  // if particle moves from interaction point or "backwards (halo)
164  bool backward = false;
165  G4ThreeVector hitPoint = preStepPoint->GetPosition();
166  G4ThreeVector hit_mom = preStepPoint->GetMomentumDirection();
167  double zint = hitPoint.z();
168  double pz = hit_mom.z();
169 
170  // Check if theTrack moves backward
171  if (pz * zint < 0.) backward = true;
172 
173  // Check that theTrack is above the energy threshold to use Shower Library
174  bool aboveThreshold = false;
175  if(theTrack->GetKineticEnergy() > energyThresholdSL) aboveThreshold = true;
176 
177  // Check if theTrack is a muon (if so, DO NOT use Shower Library)
178  bool notaMuon = true;
179  G4int mumPDG = 13;
180  G4int mupPDG = -13;
181  G4int parCode = theTrack->GetDefinition()->GetPDGEncoding();
182  if (parCode == mupPDG || parCode == mumPDG ) notaMuon = false;
183 
184  // angle condition
185  double theta_max = M_PI - 3.1305; // angle in radians corresponding to -5.2 eta
186  double R_mom=sqrt(hit_mom.x()*hit_mom.x() + hit_mom.y()*hit_mom.y());
187  double theta = atan2(R_mom,std::abs(pz));
188  bool angleok = false;
189  if ( theta < theta_max) angleok = true;
190 
191  // OkToUse
192  double R = sqrt(hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y());
193  bool dot = false;
194  if ( zint < -14450. && R < 45.) dot = true;
195  bool inRange = true;
196  if ( zint < -14700. || R > 193.) inRange = false;
197  bool OkToUse = false;
198  if ( inRange && !dot) OkToUse = true;
199 
200  if (useShowerLibrary && aboveThreshold && notaMuon && (!backward) && OkToUse && angleok && currentLV == lvCAST ) {
201  // Use Castor shower library if energy is above threshold, is not a muon
202  // and is not moving backward
203  getFromLibrary(aStep);
204 
205 #ifdef debugLog
206  LogDebug("ForwardSim") << " Current logical volume is " << nameVolume ;
207 #endif
208  return NCherPhot;
209  } else {
210  // Usual calculations
211  // G4ThreeVector hitPoint = preStepPoint->GetPosition();
212  // G4ThreeVector hit_mom = preStepPoint->GetMomentumDirection();
213  G4double stepl = aStep->GetStepLength()/cm;
214  G4double beta = preStepPoint->GetBeta();
215  G4double charge = preStepPoint->GetCharge();
216  // G4VProcess* curprocess = preStepPoint->GetProcessDefinedStep();
217  // G4String namePr = preStepPoint->GetProcessDefinedStep()->GetProcessName();
218  // std::string nameProcess;
219  // nameProcess.assign(namePr,0,4);
220 
221  // G4LogicalVolume* lv = currentPV->GetLogicalVolume();
222  // G4Material* mat = lv->GetMaterial();
223  // G4double rad = mat->GetRadlen();
224 
225 
226  // postStepPoint information *********************************************
227  G4StepPoint* postStepPoint= aStep->GetPostStepPoint();
228  G4VPhysicalVolume* postPV = postStepPoint->GetPhysicalVolume();
229  G4String postname = postPV->GetName();
230  std::string postnameVolume;
231  postnameVolume.assign(postname,0,4);
232 
233  // theTrack information *************************************************
234  // G4Track* theTrack = aStep->GetTrack();
235  //G4double entot = theTrack->GetTotalEnergy();
236  G4ThreeVector vert_mom = theTrack->GetVertexMomentumDirection();
237 
238  G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->
239  GetTopTransform().TransformPoint(hitPoint);
240 
241  // calculations... *************************************************
242  float phi = -100.;
243  if (vert_mom.x() != 0) phi = atan2(vert_mom.y(),vert_mom.x());
244  if (phi < 0.) phi += twopi;
245  G4String particleType = theTrack->GetDefinition()->GetParticleName();
246 #ifdef debugLog
247  float costheta =vert_mom.z()/sqrt(vert_mom.x()*vert_mom.x()+
248  vert_mom.y()*vert_mom.y()+
249  vert_mom.z()*vert_mom.z());
250  float theta = acos(std::min(std::max(costheta,float(-1.)),float(1.)));
251  float eta = -log(tan(theta/2));
252  G4int primaryID = theTrack->GetTrackID();
253  // *************************************************
254 
255 
256  // *************************************************
257  double edep = aStep->GetTotalEnergyDeposit();
258 #endif
259 
260  // *************************************************
261 
262 
263  // *************************************************
264  // take into account light collection curve for plate
265  // double weight = curve_Castor(nameVolume, preStepPoint);
266  // double edep = aStep->GetTotalEnergyDeposit() * weight;
267  // *************************************************
268 
269 
270  // *************************************************
271  /* comments for sensitive volumes:
272  C001 ...-... CP06,CBU1 ...-...CALM --- > fibres and bundle
273  for first release of CASTOR
274  CASF --- > quartz plate for first and second releases of CASTOR
275  GF2Q, GFNQ, GR2Q, GRNQ
276  for tests with my own test geometry of HF (on ask of Gavrilov)
277  C3TF, C4TF - for third release of CASTOR
278  */
279  double meanNCherPhot=0;
280 
281  if (currentLV == lvC3EF || currentLV == lvC4EF || currentLV == lvC3HF ||
282  currentLV == lvC4HF) {
283  // if(nameVolume == "C3EF" || nameVolume == "C4EF" || nameVolume == "C3HF" || nameVolume == "C4HF") {
284 
285  float bThreshold = 0.67;
286  float nMedium = 1.4925;
287  // float photEnSpectrDL = (1./400.nm-1./700.nm)*10000000.cm/nm; /* cm-1 */
288  // float photEnSpectrDL = 10714.285714;
289 
290  float photEnSpectrDE = 1.24; /* see below */
291  /* E = 2pi*(1./137.)*(eV*cm/370.)/lambda = */
292  /* = 12.389184*(eV*cm)/lambda */
293  /* Emax = 12.389184*(eV*cm)/400nm*10-7cm/nm = 3.01 eV */
294  /* Emin = 12.389184*(eV*cm)/700nm*10-7cm/nm = 1.77 eV */
295  /* delE = Emax - Emin = 1.24 eV --> */
296  /* */
297  /* default for Castor nameVolume == "CASF" or (C3TF & C4TF) */
298  float effPMTandTransport = 0.19;
299  /* for test HF geometry volumes:
300  if(nameVolume == "GF2Q" || nameVolume == "GFNQ" ||
301  nameVolume == "GR2Q" || nameVolume == "GRNQ")
302  effPMTandTransport = 0.19;
303  */
304 
305  float thFullRefl = 23.; /* 23.dergee */
306  float thFullReflRad = thFullRefl*pi/180.;
307 
308  /* default for Castor nameVolume == "CASF" or (C3TF & C4TF) */
309  float thFibDir = 45.; /* .dergee */
310  /* for test HF geometry volumes:
311  if(nameVolume == "GF2Q" || nameVolume == "GFNQ" ||
312  nameVolume == "GR2Q" || nameVolume == "GRNQ")
313  thFibDir = 0.0; // .dergee
314  */
315  float thFibDirRad = thFibDir*pi/180.;
316  /* */
317  /* */
318 
319  // at which theta the point is located:
320  // float th1 = hitPoint.theta();
321 
322  // theta of charged particle in LabRF(hit momentum direction):
323  float costh =hit_mom.z()/sqrt(hit_mom.x()*hit_mom.x()+
324  hit_mom.y()*hit_mom.y()+
325  hit_mom.z()*hit_mom.z());
326  if (zint < 0) costh = -costh;
327  float th = acos(std::min(std::max(costh,float(-1.)),float(1.)));
328 
329  // just in case (can do bot use):
330  if (th < 0.) th += twopi;
331 
332 
333 
334  // theta of cone with Cherenkov photons w.r.t.direction of charged part.:
335  float costhcher =1./(nMedium*beta);
336  float thcher = acos(std::min(std::max(costhcher,float(-1.)),float(1.)));
337 
338  // diff thetas of charged part. and quartz direction in LabRF:
339  float DelFibPart = fabs(th - thFibDirRad);
340 
341  // define real distances:
342  float d = fabs(tan(th)-tan(thFibDirRad));
343 
344  // float a = fabs(tan(thFibDirRad)-tan(thFibDirRad+thFullReflRad));
345  // float r = fabs(tan(th)-tan(th+thcher));
346 
347  float a = tan(thFibDirRad)+tan(fabs(thFibDirRad-thFullReflRad));
348  float r = tan(th)+tan(fabs(th-thcher));
349 
350 
351  // define losses d_qz in cone of full reflection inside quartz direction
352  float d_qz;
353  float variant;
354 
355  if(DelFibPart > (thFullReflRad + thcher) ) {d_qz = 0.; variant=0.;}
356  // if(d > (r+a) ) {d_qz = 0.; variant=0.;}
357  else {
358  if((th + thcher) < (thFibDirRad+thFullReflRad) &&
359  (th - thcher) > (thFibDirRad-thFullReflRad)
360  ) {d_qz = 1.; variant=1.;}
361  // if((DelFibPart + thcher) < thFullReflRad ) {d_qz = 1.; variant=1.;}
362  // if((d+r) < a ) {d_qz = 1.; variant=1.;}
363  else {
364  if((thFibDirRad + thFullReflRad) < (th + thcher) &&
365  (thFibDirRad - thFullReflRad) > (th - thcher) ) {
366  // if((thcher - DelFibPart ) > thFullReflRad )
367  // if((r-d ) > a )
368  d_qz = 0.; variant=2.;
369 
370  } else {
371  // if((thcher + DelFibPart ) > thFullReflRad &&
372  // thcher < (DelFibPart+thFullReflRad) )
373  // {
374  d_qz = 0.; variant=3.;
375 
376 
377  // use crossed length of circles(cone projection)
378  // dC1/dC2 :
379  float arg_arcos = 0.;
380  float tan_arcos = 2.*a*d;
381  if(tan_arcos != 0.) arg_arcos =(r*r-a*a-d*d)/tan_arcos;
382  arg_arcos = fabs(arg_arcos);
383  float th_arcos = acos(std::min(std::max(arg_arcos,float(-1.)),float(1.)));
384  d_qz = th_arcos/pi/2.;
385  d_qz = fabs(d_qz);
386 
387 
388 
389  // }
390  // else
391  // {
392  // d_qz = 0.; variant=4.;
393  //#ifdef debugLog
394  // std::cout <<" ===============>variant 4 information: <===== " <<std::endl;
395  // std::cout <<" !!!!!!!!!!!!!!!!!!!!!! variant = " << variant <<std::endl;
396  //#endif
397  //
398  // }
399  }
400  }
401  }
402 
403 
404  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
405 
406  if(charge != 0. && beta > bThreshold && d_qz != 0. ) {
407 
408  meanNCherPhot = 370.*charge*charge*
409  ( 1. - 1./(nMedium*nMedium*beta*beta) )*
410  photEnSpectrDE*stepl;
411 
412  // dLamdX:
413  // meanNCherPhot = (2.*pi/137.)*charge*charge*
414  // ( 1. - 1./(nMedium*nMedium*beta*beta) )*
415  // photEnSpectrDL*stepl;
416 
417 
418  // NCherPhot = meanNCherPhot;
419  // Poisson:
420  G4int poissNCherPhot = (G4int) G4Poisson(meanNCherPhot);
421 
422  if(poissNCherPhot < 0) poissNCherPhot = 0;
423 
424  NCherPhot = poissNCherPhot * effPMTandTransport * d_qz;
425 
426 
427 
428 #ifdef debugLog
429  float thgrad = th*180./pi;
430  float thchergrad = thcher*180./pi;
431  float DelFibPartgrad = DelFibPart*180./pi;
432  LogDebug("ForwardSim") << " ==============================> start all "
433  << "information:<========= \n" << " =====> for "
434  << "test:<=== \n" << " variant = " << variant
435  << "\n thgrad = " << thgrad << "\n thchergrad "
436  << "= " << thchergrad << "\n DelFibPartgrad = "
437  << DelFibPartgrad << "\n d_qz = " << d_qz
438  << "\n =====> Start Step Information <=== \n"
439  << " ===> calo preStepPoint info <=== \n"
440  << " hitPoint = " << hitPoint << "\n"
441  << " hitMom = " << hit_mom << "\n"
442  << " stepControlFlag = " << stepControlFlag
443  // << "\n curprocess = " << curprocess << "\n"
444  // << " nameProcess = " << nameProcess
445  << "\n charge = " << charge << "\n"
446  << " beta = " << beta << "\n"
447  << " bThreshold = " << bThreshold << "\n"
448  << " thgrad =" << thgrad << "\n"
449  << " effPMTandTransport=" << effPMTandTransport
450  // << "\n volume = " << name
451  << "\n nameVolume = " << nameVolume << "\n"
452  << " nMedium = " << nMedium << "\n"
453  // << " rad length = " << rad << "\n"
454  // << " material = " << mat << "\n"
455  << " stepl = " << stepl << "\n"
456  << " photEnSpectrDE = " << photEnSpectrDE <<"\n"
457  << " edep = " << edep << "\n"
458  << " ===> calo theTrack info <=== " << "\n"
459  << " particleType = " << particleType << "\n"
460  << " primaryID = " << primaryID << "\n"
461  << " entot= " << theTrack->GetTotalEnergy() << "\n"
462  << " vert_eta= " << eta << "\n"
463  << " vert_phi= " << phi << "\n"
464  << " vert_mom= " << vert_mom << "\n"
465  << " ===> calo hit preStepPointinfo <=== "<<"\n"
466  << " local point = " << localPoint << "\n"
467  << " ==============================> final info"
468  << ": <=== \n"
469  << " meanNCherPhot = " << meanNCherPhot << "\n"
470  << " poissNCherPhot = " << poissNCherPhot <<"\n"
471  << " NCherPhot = " << NCherPhot;
472 #endif
473 
474  // Included by WC
475  // std::cout << "\n volume = " << name
476  // << "\n nameVolume = " << nameVolume << "\n"
477  // << "\n postvolume = " << postname
478  // << "\n postnameVolume = " << postnameVolume << "\n"
479  // << "\n particleType = " << particleType
480  // << "\n primaryID = " << primaryID << "\n";
481 
482  }
483  }
484 
485 
486 #ifdef debugLog
487  LogDebug("ForwardSim") << "CastorSD:: " << nameVolume
488  // << " Light Collection Efficiency " << weight
489  << " Weighted Energy Deposit " << edep/MeV
490  << " MeV\n";
491 #endif
492  // Temporary member for testing purpose only...
493  // unit_id = setDetUnitId(aStep);
494  // if(NCherPhot != 0) std::cout << "\n UnitID = " << unit_id << " ; NCherPhot = " << NCherPhot ;
495 
496  return NCherPhot;
497  }
498  }
499  return 0;
500 }
#define LogDebug(id)
const double beta
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
Geom::Theta< T > theta() const
#define min(a, b)
Definition: mlp_lapack.h:161
T dot(const Basic3DVector &v) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
bool useShowerLibrary
Definition: CastorSD.h:51
double charge(const std::vector< uint8_t > &Ampls)
T eta() const
void getFromLibrary(G4Step *)
Definition: CastorSD.cc:610
G4LogicalVolume * lvC4HF
Definition: CastorSD.h:48
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:28
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
G4LogicalVolume * lvC3HF
Definition: CastorSD.h:48
G4Track * theTrack
Definition: CaloSD.h:116
double energyThresholdSL
Definition: CastorSD.h:52
G4StepPoint * preStepPoint
Definition: CaloSD.h:118
G4LogicalVolume * lvC4EF
Definition: CastorSD.h:48
#define M_PI
Definition: BFit3D.cc:3
Log< T >::type log(const T &t)
Definition: Log.h:22
G4LogicalVolume * lvCAST
Definition: CastorSD.h:49
G4LogicalVolume * lvC3EF
Definition: CastorSD.h:48
double a
Definition: hdecay.h:121
double pi
Definition: DDAxes.h:10
void CastorSD::getFromLibrary ( G4Step *  aStep)
private

Definition at line 610 of file CastorSD.cc.

References CaloSD::checkHit(), CaloSD::createNewHit(), CaloSD::currentHit, CaloSD::currentID, CaloSD::edepositEM, CaloSD::edepositHAD, CaloSD::emPDG, CaloSD::epPDG, CaloSD::gammaPDG, CastorShowerEvent::getDetID(), CastorShowerEvent::getHitPosition(), CastorShowerEvent::getNhit(), CastorShowerEvent::getNphotons(), CastorShowerEvent::getPrimE(), CastorShowerLibrary::getShowerHits(), CastorShowerEvent::getTime(), GetVolume(), i, LogDebug, convertSQLiteXML::ok, CaloSD::posGlobal, position, CaloSD::preStepPoint, CaloSD::previousID, CaloSD::resetForNewPrimary(), rotateUnitID(), CaloHitID::setID(), setTrackID(), showerLibrary, CaloSD::theTrack, cond::rpcobgas::time, funct::true, and CaloSD::updateHit().

Referenced by getEnergyDeposit().

610  {
611 
613 //
614 // Method to get hits from the Shower Library
615 //
616 // CastorShowerEvent hits returned by getShowerHits are used to
617 // replace the full simulation of the shower from theTrack
618 //
619 // "updateHit" save the Hits to a CaloG4Hit container
620 //
622 
623  preStepPoint = aStep->GetPreStepPoint();
624  theTrack = aStep->GetTrack();
625  bool ok;
626 
627  // **** Call method to retrieve hits from the ShowerLibrary ****
628  CastorShowerEvent hits = showerLibrary->getShowerHits(aStep, ok);
629 
630  double etrack = preStepPoint->GetKineticEnergy();
631  int primaryID = setTrackID(aStep);
632  // int primaryID = theTrack->GetTrackID();
633 
634  // Reset entry point for new primary
635  posGlobal = preStepPoint->GetPosition();
636  resetForNewPrimary(posGlobal, etrack);
637 
638  // Check whether track is EM or HAD
639  G4int particleCode = theTrack->GetDefinition()->GetPDGEncoding();
640  bool isEM , isHAD ;
641  if (particleCode==emPDG || particleCode==epPDG || particleCode==gammaPDG) {
642  isEM = true ; isHAD = false;
643  } else {
644  isEM = false; isHAD = true ;
645  }
646 
647 #ifdef debugLog
648  // edm::LogInfo("ForwardSim") << "\n CastorSD::getFromLibrary: "
649  LogDebug("ForwardSim") << "\n CastorSD::getFromLibrary: "
650  << hits.getNhit() << " hits for " << GetName() << " from "
651  << theTrack->GetDefinition()->GetParticleName() << " of "
652  << preStepPoint->GetKineticEnergy()/GeV << " GeV and trackID "
653  << theTrack->GetTrackID() ;
654 #endif
655 
656  // Scale to correct energy
657  double E_track = preStepPoint->GetTotalEnergy() ;
658  double E_SLhit = hits.getPrimE() * GeV ;
659  double scale = E_track/E_SLhit ;
660 
661 /* double theTrackEnergy = theTrack->GetTotalEnergy() ;
662 
663  if(fabs(theTrackEnergy-E_track)>10.) {
664  edm::LogInfo("ForwardSim") << "\n TrackID = " << theTrack->GetTrackID()
665  << "\n theTrackEnergy = " << theTrackEnergy
666  << "\n preStepPointEnergy = " << E_track ;
667  G4TrackVector tsec = *(aStep->GetSecondary());
668  for (unsigned int kk=0; kk<tsec.size(); kk++) {
669  edm::LogInfo("ForwardSim") << "CastorSD::getFromLibrary:"
670  << "\n tsec[" << kk << "]->GetTrackID() = "
671  << tsec[kk]->GetTrackID()
672  << " with energy "
673  << tsec[kk]->GetTotalEnergy() ;
674  }
675  }
676 */
677  // Loop over hits retrieved from the library
678  for (unsigned int i=0; i<hits.getNhit(); i++) {
679 
680  // Get nPhotoElectrons and set edepositEM / edepositHAD accordingly
681  double nPhotoElectrons = hits.getNphotons(i);
682  // Apply scaling
683  nPhotoElectrons *= scale ;
684  if(isEM) {
685  // edepositEM = nPhotoElectrons*GeV;
686  edepositEM = nPhotoElectrons;
687  edepositHAD = 0.;
688  } else if(isHAD) {
689  edepositEM = 0.;
690  edepositHAD = nPhotoElectrons;
691  // edepositHAD = nPhotoElectrons*GeV;
692  }
693 
694  // Get hit position and time
695  double time = hits.getTime(i);
697 
698  // Get hit detID
699  unsigned int unitID = hits.getDetID(i);
700 
701  // Make the detID "rotation" from one sector to another taking into account the
702  // sectors of the impinging particle (theTrack) and of the particle that produced
703  // the 'hits' retrieved from shower library
704  unsigned int rotatedUnitID = rotateUnitID(unitID , theTrack , hits);
705  currentID.setID(rotatedUnitID, time, primaryID, 0);
706  // currentID.setID(unitID, time, primaryID, 0);
707 
708  // check if it is in the same unit and timeslice as the previous one
709  if (currentID == previousID) {
711  } else {
712  if (!checkHit()) currentHit = createNewHit();
713  }
714  } // End of loop over hits
715 
716  //Now kill the current track
717  if (ok) {
718  theTrack->SetTrackStatus(fStopAndKill);
719 #ifdef debugLog
720  LogDebug("ForwardSim") << "CastorSD::getFromLibrary:"
721  << "\n \"theTrack\" with TrackID() = "
722  << theTrack->GetTrackID()
723  << " and with energy "
724  << theTrack->GetTotalEnergy()
725  << " has been set to be killed" ;
726 #endif
727  G4TrackVector tv = *(aStep->GetSecondary());
728  for (unsigned int kk=0; kk<tv.size(); kk++) {
729  if (tv[kk]->GetVolume() == preStepPoint->GetPhysicalVolume()) {
730  tv[kk]->SetTrackStatus(fStopAndKill);
731 #ifdef debugLog
732  LogDebug("ForwardSim") << "CastorSD::getFromLibrary:"
733  << "\n tv[" << kk << "]->GetTrackID() = "
734  << tv[kk]->GetTrackID()
735  << " with energy "
736  << tv[kk]->GetTotalEnergy()
737  << " has been set to be killed" ;
738 #endif
739  }
740  }
741  }
742 }
#define LogDebug(id)
float edepositEM
Definition: CaloSD.h:119
int i
Definition: DBlmapReader.cc:9
G4int emPDG
Definition: CaloSD.h:134
void updateHit(CaloG4Hit *)
Definition: CaloSD.cc:453
Point getHitPosition(int i)
uint32_t rotateUnitID(uint32_t, G4Track *, CastorShowerEvent)
Definition: CastorSD.cc:545
G4ThreeVector posGlobal
Definition: CaloSD.h:111
unsigned int getDetID(int i)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
G4bool checkHit()
Definition: CaloSD.cc:343
float edepositHAD
Definition: CaloSD.h:119
G4int epPDG
Definition: CaloSD.h:134
float getTime(int i)
G4int gammaPDG
Definition: CaloSD.h:134
int setTrackID(G4Step *)
Definition: CastorSD.cc:522
float getNphotons(int i)
CaloHitID previousID
Definition: CaloSD.h:115
CaloG4Hit * currentHit
Definition: CaloSD.h:126
G4Track * theTrack
Definition: CaloSD.h:116
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:44
G4StepPoint * preStepPoint
Definition: CaloSD.h:118
static const G4LogicalVolume * GetVolume(const std::string &name)
CaloHitID currentID
Definition: CaloSD.h:115
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
CastorShowerLibrary * showerLibrary
Definition: CastorSD.h:47
CastorShowerEvent getShowerHits(G4Step *, bool &)
void resetForNewPrimary(G4ThreeVector, double)
Definition: CaloSD.cc:468
CaloG4Hit * createNewHit()
Definition: CaloSD.cc:375
unsigned int getNhit()
void CastorSD::initRun ( )
protectedvirtual

Reimplemented from CaloSD.

Definition at line 81 of file CastorSD.cc.

References CastorShowerLibrary::initParticleTable(), showerLibrary, and useShowerLibrary.

81  {
82  if (useShowerLibrary) {
83  // showerLibrary = new CastorShowerLibrary(name, cpv, p);
84  G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
85  showerLibrary->initParticleTable(theParticleTable);
86  edm::LogInfo("ForwardSim") << "CastorSD::initRun: Using Castor Shower Library \n";
87  }
88 }
void initParticleTable(G4ParticleTable *)
bool useShowerLibrary
Definition: CastorSD.h:51
CastorShowerLibrary * showerLibrary
Definition: CastorSD.h:47
uint32_t CastorSD::rotateUnitID ( uint32_t  unitID,
G4Track *  track,
CastorShowerEvent  shower 
)
private

Definition at line 545 of file CastorSD.cc.

References printConversionInfo::aux, CastorShowerEvent::getPrimPhi(), LogDebug, M_PI, and reco::btau::trackPhi.

Referenced by getFromLibrary().

545  {
546 // ==============================================================
547 //
548 // o Exploit Castor phi symmetry to return newUnitID for
549 // shower hits based on track phi coordinate
550 //
551 // ==============================================================
552 
553  // Get 'track' phi:
554  float trackPhi = track->GetPosition().phi();
555  if(trackPhi<0) trackPhi += 2*M_PI ;
556  // Get phi from primary that gave rise to SL 'shower':
557  float showerPhi = shower.getPrimPhi();
558  if(showerPhi<0) showerPhi += 2*M_PI ;
559  // Delta phi:
560 
561  // Find the OctSector for which 'track' and 'shower' belong
562  int trackOctSector = (int) ( trackPhi / (M_PI/4) ) ;
563  int showerOctSector = (int) ( showerPhi / (M_PI/4) ) ;
564 
565  uint32_t newUnitID;
566  uint32_t sec = ( ( unitID>>4 ) & 0xF ) ;
567  uint32_t complement = ( unitID & 0xFFFFFF0F ) ;
568 
569  // edm::LogInfo("ForwardSim") << "\n CastorSD::rotateUnitID: "
570  // << "\n unitID = " << unitID
571  // << "\n sec = " << sec
572  // << "\n complement = " << complement ;
573 
574  // Get 'track' z:
575  float trackZ = track->GetPosition().z();
576 
577  int aux ;
578  int dSec = 2*(trackOctSector - showerOctSector) ;
579  // if(trackZ<0) // Good for revision 1.8 of CastorNumberingScheme
580  if(trackZ>0) // Good for revision 1.9 of CastorNumberingScheme
581  {
582  int sec1 = sec-dSec;
583  // sec -= dSec ;
584  if(sec1<0) sec1 += 16;
585  if(sec1>15) sec1 -= 16;
586  sec = (uint32_t)(sec1);
587  } else {
588  if( dSec<0 ) sec += 16 ;
589  sec += dSec ;
590  aux = (int) (sec/16) ;
591  sec -= aux*16 ;
592  }
593  sec = sec<<4 ;
594  newUnitID = complement | sec ;
595 
596 #ifdef debugLog
597  if(newUnitID != unitID) {
598  LogDebug("ForwardSim") << "\n CastorSD::rotateUnitID: "
599  << "\n unitID = " << unitID
600  << "\n newUnitID = " << newUnitID ;
601  }
602 #endif
603 
604  return newUnitID ;
605 
606 }
#define LogDebug(id)
#define M_PI
Definition: BFit3D.cc:3
uint32_t CastorSD::setDetUnitId ( G4Step *  step)
virtual

Implements CaloSD.

Definition at line 504 of file CastorSD.cc.

References CastorNumberingScheme::getUnitID(), and numberingScheme.

504  {
505  return (numberingScheme == 0 ? 0 : numberingScheme->getUnitID(aStep));
506 }
CastorNumberingScheme * numberingScheme
Definition: CastorSD.h:46
virtual uint32_t getUnitID(const G4Step *aStep) const
void CastorSD::setNumberingScheme ( CastorNumberingScheme scheme)

Definition at line 510 of file CastorSD.cc.

References numberingScheme.

Referenced by CastorSD().

510  {
511 
512  if (scheme != 0) {
513  edm::LogInfo("ForwardSim") << "CastorSD: updates numbering scheme for "
514  << GetName();
515  if (numberingScheme) delete numberingScheme;
516  numberingScheme = scheme;
517  }
518 }
CastorNumberingScheme * numberingScheme
Definition: CastorSD.h:46
int CastorSD::setTrackID ( G4Step *  aStep)
private

Definition at line 522 of file CastorSD.cc.

References TrackInformation::getIDonCaloSurface(), CaloSD::preStepPoint, CaloSD::previousID, CaloSD::resetForNewPrimary(), CaloSD::theTrack, and CaloHitID::trackID().

Referenced by getFromLibrary().

522  {
523 
524  theTrack = aStep->GetTrack();
525 
526  double etrack = preStepPoint->GetKineticEnergy();
527  TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation());
528  int primaryID = trkInfo->getIDonCaloSurface();
529  if (primaryID == 0) {
530 #ifdef debugLog
531  edm::LogWarning("ForwardSim") << "CastorSD: Problem with primaryID **** set by force "
532  << "to TkID **** " << theTrack->GetTrackID();
533 #endif
534  primaryID = theTrack->GetTrackID();
535  }
536 
537  if (primaryID != previousID.trackID())
538  resetForNewPrimary(preStepPoint->GetPosition(), etrack);
539 
540  return primaryID;
541 }
int getIDonCaloSurface() const
int trackID() const
Definition: CaloHitID.h:25
CaloHitID previousID
Definition: CaloSD.h:115
G4Track * theTrack
Definition: CaloSD.h:116
G4StepPoint * preStepPoint
Definition: CaloSD.h:118
void resetForNewPrimary(G4ThreeVector, double)
Definition: CaloSD.cc:468

Member Data Documentation

double CastorSD::energyThresholdSL
private

Definition at line 52 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

G4LogicalVolume* CastorSD::lvC3EF
private

Definition at line 48 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

G4LogicalVolume * CastorSD::lvC3HF
private

Definition at line 48 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

G4LogicalVolume * CastorSD::lvC4EF
private

Definition at line 48 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

G4LogicalVolume * CastorSD::lvC4HF
private

Definition at line 48 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

G4LogicalVolume* CastorSD::lvCAST
private

Definition at line 49 of file CastorSD.h.

Referenced by CastorSD(), and getEnergyDeposit().

CastorNumberingScheme* CastorSD::numberingScheme
private

Definition at line 46 of file CastorSD.h.

Referenced by setDetUnitId(), and setNumberingScheme().

CastorShowerLibrary* CastorSD::showerLibrary
private

Definition at line 47 of file CastorSD.h.

Referenced by CastorSD(), getFromLibrary(), initRun(), and ~CastorSD().

bool CastorSD::useShowerLibrary
private

Definition at line 51 of file CastorSD.h.

Referenced by CastorSD(), getEnergyDeposit(), initRun(), and ~CastorSD().