Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Yoke05_Barrel driver #241

Merged
merged 4 commits into from
Mar 2, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions detector/calorimeter/Yoke05_Barrel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
double nRadiationLengths=0.;
double nInteractionLengths=0.;
double thickness_sum=0;

// Placements of individual layers.
// Key is the prefix of the detector elements name created after this nested loop (see below)
std::vector<std::pair<std::string,dd4hep::PlacedVolume>> plvec {} ;

int l_num = 1;
for(xml_coll_t li(x_det,_U(layer)); li; ++li) {
Expand Down Expand Up @@ -309,7 +313,7 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete

Box s_box(slab_dim_x,slab_dim_y,slab_dim_z);
Volume s_vol(det_name+"_"+l_name+"_"+s_name,s_box,slice_material);
DetElement slice(layer,s_name,det_id);
// DetElement slice(layer,s_name,det_id);

nRadiationLengths += s_thickness/(2.*slice_material.radLength());
nInteractionLengths += s_thickness/(2.*slice_material.intLength());
Expand Down Expand Up @@ -342,8 +346,9 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
s_pos_y += s_thickness/2.;

Position s_pos(0,s_pos_y,0); // Position of the layer.
PlacedVolume s_phv = ChamberLog.placeVolume(s_vol,s_pos);
slice.setPlacement(s_phv);
// PlacedVolume s_phv =
ChamberLog.placeVolume(s_vol,s_pos);
// slice.setPlacement(s_phv);

// Increment x position for next slice.
s_pos_y += s_thickness/2.;
Expand Down Expand Up @@ -378,9 +383,10 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
layer_phv.addPhysVolID("layer", l_num).addPhysVolID("stave",j+1);
string stave_name = _toString(j+1,"stave%d");
string stave_layer_name = stave_name+_toString(l_num,"layer%d");
DetElement stave(stave_layer_name,det_id);;
stave.setPlacement(layer_phv);
sdet.add(stave);
// DetElement stave(stave_layer_name,det_id);;
// stave.setPlacement(layer_phv);
// sdet.add(stave);
plvec.push_back({stave_layer_name,layer_phv});
phirot -= M_PI/symmetry*2.0;

}
Expand Down Expand Up @@ -415,9 +421,15 @@ static Ref_t create_detector(Detector& theDetector, xml_h element, SensitiveDete
m_phv.addPhysVolID("tower", 1);// Not used
string m_name = _toString(module_id,"module%d");
DetElement sd (m_name,det_id);

for( auto deelts : plvec ) {
std::string deteltname = deelts.first +_toString(module_id,"module%d");
DetElement layerDet (sd, deteltname, det_id);
layerDet.setPlacement( deelts.second ) ;
}

sd.setPlacement(m_phv);
sdet.add(sd);

}

sdet.addExtension< LayeredCalorimeterData >( caloData ) ;
Expand Down