15 #include "G4EventManager.hh"
17 #include "G4LogicalVolumeStore.hh"
18 #include "G4LogicalVolume.hh"
22 #include "G4SystemOfUnits.hh"
32 m_trackManager(manager) {
40 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Initailised with TestBeam = "
41 << testBeam <<
" Emin = " << eMin <<
" MeV and"
45 G4String attribute =
"ReadOutName";
54 G4String
value =
"Calorimeter";
55 std::vector<std::string> caloNames =
getNames (value, sv);
57 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
58 for (
unsigned int i=0;
i<caloNames.size();
i++)
59 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << caloNames[
i];
63 std::vector<double> levels =
getNumbers (value, sv);
65 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
66 for (
unsigned int i=0;
i<levels.size();
i++)
67 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << levels[
i];
71 std::vector<double> neighbours =
getNumbers (value, sv);
73 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
74 for (
unsigned int i=0;
i<neighbours.size();
i++)
75 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << neighbours[
i];
79 std::vector<std::string> insideNames =
getNames (value, sv);
81 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
82 for (
unsigned int i=0;
i<insideNames.size();
i++)
83 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << insideNames[
i];
86 value =
"InsideLevel";
87 std::vector<double> insideLevel =
getNumbers (value, sv);
89 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
90 for (
unsigned int i=0;
i<insideLevel.size();
i++)
91 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << insideLevel[
i];
94 if (caloNames.size() < neighbours.size()) {
95 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of Calorimeter bins "
96 << caloNames.size() <<
" does not match with "
97 << neighbours.size() <<
" ==> illegal ";
99 <<
"Calorimeter array size does not match with size of neighbours\n";
102 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
103 std::vector<G4LogicalVolume *>::const_iterator lvcite;
105 for (
unsigned int i=0;
i<caloNames.size();
i++) {
106 G4LogicalVolume* lv = 0;
107 G4String name = caloNames[
i];
108 int number =
static_cast<int>(neighbours[
i]);
109 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
110 if ((*lvcite)->GetName() ==
name) {
119 detector.
level =
static_cast<int>(levels[
i]);
120 if (istart+number > (
int)(insideNames.size())) {
121 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of InsideNames bins "
122 << insideNames.size() <<
" too few compaerd to "
123 << istart+number <<
" requested ==> illegal ";
125 <<
"InsideNames array size does not match with list of neighbours\n";
127 std::vector<std::string> inside;
128 std::vector<G4LogicalVolume*> insideLV;
129 std::vector<int> insideLevels;
132 name = insideNames[istart+
k];
133 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
134 if ((*lvcite)->GetName() ==
name) {
138 inside.push_back(name);
139 insideLV.push_back(lv);
140 insideLevels.push_back(static_cast<int>(insideLevel[istart+
k]));
151 <<
" calorimetric volumes";
153 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Calorimeter volume " <<
i
157 <<
detectors[
i].fromDets.size() <<
" neighbours";
167 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Deleted";
178 G4Track* theTrack = aStep->GetTrack();
179 int id = theTrack->GetTrackID();
182 (theTrack->GetUserInformation());
185 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: No trk info !!!! abort ";
187 <<
"cannot get trkInfo for Track " <<
id <<
"\n";
193 LogDebug(
"CaloSim") <<
"CaloTrkProcessing set IDonCaloSurface to " <<
id
194 <<
" at step Number "
195 << theTrack->GetCurrentStepNumber();
198 theTrack->GetDefinition()->GetPDGEncoding(),
199 theTrack->GetMomentum().mag());
201 if (theTrack->GetKineticEnergy()/MeV >
eMin)
210 LogDebug(
"CaloSim") <<
"CaloTrkProcessing Entered for " <<
id
211 <<
" at stepNumber "<< theTrack->GetCurrentStepNumber()
217 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
218 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
228 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
229 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
232 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
233 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
235 if (inside >= 0 || (theTrack->GetCurrentStepNumber()==1)) {
237 theTrack->GetDefinition()->GetPDGEncoding(),
238 theTrack->GetMomentum().mag());
243 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: set ID on Calo " << ical
244 <<
" surface (Inside " << inside <<
") to "
245 <<
id <<
" of a Track with Kinetic Energy "
246 << theTrack->GetKineticEnergy()/MeV <<
" MeV";
258 LogDebug(
"CaloSim") <<
"CaloTrkProcessing::getNames called for " << str;
265 const std::vector<std::string> & fvec = value.
strings();
266 int nval = fvec.size();
269 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str
270 <<
" bins " << nval <<
" < 1 ==> illegal ";
272 <<
"nval < 2 for array " << str <<
"\n";
277 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: cannot get array " << str ;
279 <<
"cannot get array " << str <<
"\n";
287 LogDebug(
"CaloSim") <<
"CaloTrkProcessing::getNumbers called for " << str;
294 const std::vector<double> & fvec = value.
doubles();
295 int nval = fvec.size();
297 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str
298 <<
" bins " << nval <<
" < 1 ==> illegal ";
300 <<
"nval < 2 for array " << str <<
"\n";
305 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: cannot get array " << str ;
307 <<
"cannot get array " << str <<
"\n";
314 G4LogicalVolume* lv=0;
315 for (
unsigned int it=0; it <
detectors.size(); it++) {
318 lv =
detLV(touch, lastLevel);
321 if (lv != 0) name1 = lv->GetName();
322 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
323 <<
" at Level " << lastLevel;
326 G4String name2[20];
int copyno2[20];
328 for (
int i2=0; i2<levels; i2++)
329 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" "
343 G4LogicalVolume* lv=0;
345 if (idcal < 0) {id1 = 0; id2 =
static_cast<int>(
detectors.size());}
346 else {id1 = idcal; id2 = id1+1;}
347 for (
int it1 = id1; it1 < id2; it1++) {
349 for (
unsigned int it2 = 0; it2 <
detectors[it1].fromDets.size(); it2++) {
350 if (lastLevel !=
detectors[it1].fromLevels[it2]) {
351 lastLevel =
detectors[it1].fromLevels[it2];
352 lv =
detLV(touch,lastLevel);
355 if (lv != 0) name1 = lv->GetName();
356 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
357 <<
" at Level " << lastLevel;
360 G4String name2[20];
int copyno2[20];
362 for (
int i2=0; i2<levels; i2++)
363 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" "
372 lastLevel =
detectors[it1].fromLevels[idin];
373 lv =
detLV(touch,lastLevel);
376 if (lv != 0) name1 = lv->GetName();
377 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
378 <<
" at Level " << lastLevel;
381 G4String name2[20];
int copyno2[20];
383 for (
int i2=0; i2<levels; i2++)
384 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" "
399 return ((touch->GetHistoryDepth())+1);
405 int currentlevel)
const {
407 G4LogicalVolume* lv=0;
409 int level = ((touch->GetHistoryDepth())+1);
410 if (level > 0 && level >= currentlevel) {
411 int ii = level - currentlevel;
412 lv = touch->GetVolume(ii)->GetLogicalVolume();
420 int* copyno, G4String*
name)
const {
426 int i = level -
ii - 1;
427 G4VPhysicalVolume* pv = touch->GetVolume(i);
429 name[
ii] = pv->GetName();
432 copyno[
ii] = touch->GetReplicaNumber(i);
T getParameter(std::string const &) const
G4LogicalVolume * detLV(const G4VTouchable *, int) const
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
void addFilter(const DDFilter &, log_op op=AND)
virtual ~CaloTrkProcessing()
int detLevels(const G4VTouchable *) const
int isItCalo(const G4VTouchable *)
type of data representation of DDCompactView
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
int isItInside(const G4VTouchable *, int, int)
std::vector< int > fromLevels
std::vector< Detector > detectors
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
std::vector< double > getNumbers(G4String, const DDsvalues_type &)
std::vector< G4LogicalVolume * > fromDetL
virtual std::vector< std::string > getNames()
std::vector< std::string > fromDets
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
CaloTrkProcessing(G4String aSDname, const DDCompactView &cpv, SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *)
void update(const BeginOfEvent *evt)
This routine will be called when the appropriate signal arrives.
DDsvalues_type mergedSpecifics() const
bool firstChild()
set the current node to the first child ...
void setCriteria(const DDValue &nameVal, comp_op, log_op l=AND, bool asString=true, bool merged=true)
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.