14 #include "G4EventManager.hh"
15 #include "G4LogicalVolumeStore.hh"
16 #include "G4LogicalVolume.hh"
20 #include "G4SystemOfUnits.hh"
30 m_trackManager(manager) {
38 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Initailised with TestBeam = "
39 << testBeam <<
" Emin = " << eMin <<
" MeV and"
43 G4String attribute =
"ReadOutName";
52 G4String
value =
"Calorimeter";
53 std::vector<std::string> caloNames =
getNames (value, sv);
55 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
56 for (
unsigned int i=0;
i<caloNames.size();
i++)
57 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << caloNames[
i];
61 std::vector<double> levels =
getNumbers (value, sv);
63 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
64 for (
unsigned int i=0;
i<levels.size();
i++)
65 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << levels[
i];
69 std::vector<double> neighbours =
getNumbers (value, sv);
71 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
72 for (
unsigned int i=0;
i<neighbours.size();
i++)
73 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << neighbours[
i];
77 std::vector<std::string> insideNames =
getNames (value, sv);
79 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
80 for (
unsigned int i=0;
i<insideNames.size();
i++)
81 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << insideNames[
i];
84 value =
"InsideLevel";
85 std::vector<double> insideLevel =
getNumbers (value, sv);
87 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
88 for (
unsigned int i=0;
i<insideLevel.size();
i++)
89 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << insideLevel[
i];
92 if (caloNames.size() < neighbours.size()) {
93 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of Calorimeter bins "
94 << caloNames.size() <<
" does not match with "
95 << neighbours.size() <<
" ==> illegal ";
97 <<
"Calorimeter array size does not match with size of neighbours\n";
100 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
101 std::vector<G4LogicalVolume *>::const_iterator lvcite;
103 for (
unsigned int i=0;
i<caloNames.size();
i++) {
104 G4LogicalVolume* lv = 0;
105 G4String name = caloNames[
i];
106 int number =
static_cast<int>(neighbours[
i]);
107 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
108 if ((*lvcite)->GetName() ==
name) {
117 detector.
level =
static_cast<int>(levels[
i]);
118 if (istart+number > (
int)(insideNames.size())) {
119 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of InsideNames bins "
120 << insideNames.size() <<
" too few compaerd to "
121 << istart+number <<
" requested ==> illegal ";
123 <<
"InsideNames array size does not match with list of neighbours\n";
125 std::vector<std::string> inside;
126 std::vector<G4LogicalVolume*> insideLV;
127 std::vector<int> insideLevels;
128 for (
int k = 0;
k < number;
k++) {
130 name = insideNames[istart+
k];
131 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
132 if ((*lvcite)->GetName() ==
name) {
136 inside.push_back(name);
137 insideLV.push_back(lv);
138 insideLevels.push_back(static_cast<int>(insideLevel[istart+
k]));
149 <<
" calorimetric volumes";
151 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Calorimeter volume " <<
i
155 <<
detectors[
i].fromDets.size() <<
" neighbours";
165 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Deleted";
176 G4Track* theTrack = aStep->GetTrack();
177 int id = theTrack->GetTrackID();
180 (theTrack->GetUserInformation());
183 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: No trk info !!!! abort ";
185 <<
"cannot get trkInfo for Track " <<
id <<
"\n";
191 LogDebug(
"CaloSim") <<
"CaloTrkProcessing set IDonCaloSurface to " <<
id
192 <<
" at step Number "
193 << theTrack->GetCurrentStepNumber();
196 theTrack->GetDefinition()->GetPDGEncoding(),
197 theTrack->GetMomentum().mag());
199 if (theTrack->GetKineticEnergy()/MeV >
eMin)
208 LogDebug(
"CaloSim") <<
"CaloTrkProcessing Entered for " <<
id
209 <<
" at stepNumber "<< theTrack->GetCurrentStepNumber()
215 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
216 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
226 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
227 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
230 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
231 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
233 if (inside >= 0 || (theTrack->GetCurrentStepNumber()==1)) {
235 theTrack->GetDefinition()->GetPDGEncoding(),
236 theTrack->GetMomentum().mag());
241 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: set ID on Calo " << ical
242 <<
" surface (Inside " << inside <<
") to "
243 <<
id <<
" of a Track with Kinetic Energy "
244 << theTrack->GetKineticEnergy()/MeV <<
" MeV";
256 LogDebug(
"CaloSim") <<
"CaloTrkProcessing::getNames called for " << str;
263 const std::vector<std::string> & fvec = value.
strings();
264 int nval = fvec.size();
267 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str
268 <<
" bins " << nval <<
" < 1 ==> illegal ";
270 <<
"nval < 2 for array " << str <<
"\n";
275 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: cannot get array " << str ;
277 <<
"cannot get array " << str <<
"\n";
285 LogDebug(
"CaloSim") <<
"CaloTrkProcessing::getNumbers called for " << str;
292 const std::vector<double> & fvec = value.
doubles();
293 int nval = fvec.size();
295 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str
296 <<
" bins " << nval <<
" < 1 ==> illegal ";
298 <<
"nval < 2 for array " << str <<
"\n";
303 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: cannot get array " << str ;
305 <<
"cannot get array " << str <<
"\n";
312 G4LogicalVolume* lv=0;
313 for (
unsigned int it=0; it <
detectors.size(); it++) {
316 lv =
detLV(touch, lastLevel);
319 if (lv != 0) name1 = lv->GetName();
320 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
321 <<
" at Level " << lastLevel;
324 G4String name2[20];
int copyno2[20];
326 for (
int i2=0; i2<levels; i2++)
327 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" "
341 G4LogicalVolume* lv=0;
343 if (idcal < 0) {id1 = 0; id2 =
static_cast<int>(
detectors.size());}
344 else {id1 = idcal; id2 = id1+1;}
345 for (
int it1 = id1; it1 < id2; it1++) {
347 for (
unsigned int it2 = 0; it2 <
detectors[it1].fromDets.size(); it2++) {
348 if (lastLevel !=
detectors[it1].fromLevels[it2]) {
349 lastLevel =
detectors[it1].fromLevels[it2];
350 lv =
detLV(touch,lastLevel);
353 if (lv != 0) name1 = lv->GetName();
354 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
355 <<
" at Level " << lastLevel;
358 G4String name2[20];
int copyno2[20];
360 for (
int i2=0; i2<levels; i2++)
361 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" "
370 lastLevel =
detectors[it1].fromLevels[idin];
371 lv =
detLV(touch,lastLevel);
374 if (lv != 0) name1 = lv->GetName();
375 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
376 <<
" at Level " << lastLevel;
379 G4String name2[20];
int copyno2[20];
381 for (
int i2=0; i2<levels; i2++)
382 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" "
397 return ((touch->GetHistoryDepth())+1);
403 int currentlevel)
const {
405 G4LogicalVolume* lv=0;
407 int level = ((touch->GetHistoryDepth())+1);
408 if (level > 0 && level >= currentlevel) {
409 int ii = level - currentlevel;
410 lv = touch->GetVolume(ii)->GetLogicalVolume();
418 int* copyno, G4String*
name)
const {
424 int i = level -
ii - 1;
425 G4VPhysicalVolume* pv = touch->GetVolume(i);
427 name[
ii] = pv->GetName();
430 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.