[369744d] | 1 | /*
|
---|
| 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
| 4 | *
|
---|
| 5 | * This program is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * This program is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[cfc3160] | 19 | #include "display/Delphes3DGeometry.h"
|
---|
| 20 | #include <set>
|
---|
| 21 | #include <map>
|
---|
| 22 | #include <utility>
|
---|
| 23 | #include <vector>
|
---|
| 24 | #include <algorithm>
|
---|
| 25 | #include <sstream>
|
---|
| 26 | #include <cassert>
|
---|
| 27 | #include "TGeoManager.h"
|
---|
| 28 | #include "TGeoVolume.h"
|
---|
| 29 | #include "TGeoMedium.h"
|
---|
| 30 | #include "TGeoNode.h"
|
---|
| 31 | #include "TGeoCompositeShape.h"
|
---|
| 32 | #include "TGeoMatrix.h"
|
---|
| 33 | #include "TGeoTube.h"
|
---|
| 34 | #include "TGeoCone.h"
|
---|
| 35 | #include "TGeoArb8.h"
|
---|
| 36 | #include "external/ExRootAnalysis/ExRootConfReader.h"
|
---|
| 37 | #include "classes/DelphesClasses.h"
|
---|
| 38 | #include "TF2.h"
|
---|
| 39 | #include "TH1F.h"
|
---|
| 40 | #include "TMath.h"
|
---|
| 41 |
|
---|
| 42 | using namespace std;
|
---|
| 43 |
|
---|
| 44 | Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom) {
|
---|
| 45 |
|
---|
| 46 | //--- the geometry manager
|
---|
| 47 | geom_ = geom==NULL? gGeoManager : geom;
|
---|
| 48 | //gGeoManager->DefaultColors();
|
---|
| 49 |
|
---|
| 50 | //--- define some materials
|
---|
| 51 | TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
|
---|
| 52 | TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // placeholder
|
---|
| 53 | matVacuum->SetTransparency(85);
|
---|
| 54 | matAl->SetTransparency(85);
|
---|
| 55 |
|
---|
| 56 | //--- define some media
|
---|
| 57 | TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
|
---|
| 58 | TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);
|
---|
| 59 | vacuum_ = Vacuum;
|
---|
| 60 | tkmed_ = Vacuum; // placeholder
|
---|
| 61 | calomed_ = Al; // placeholder
|
---|
| 62 | mudetmed_ = Al; // placeholder
|
---|
| 63 |
|
---|
| 64 | // custom parameters
|
---|
| 65 | contingency_ = 10.;
|
---|
| 66 | calo_barrel_thickness_ = 50.;
|
---|
| 67 | calo_endcap_thickness_ = 75.;
|
---|
| 68 | muonSystem_thickn_ = 10.;
|
---|
| 69 |
|
---|
| 70 | // read these parameters from the Delphes Card (with default values)
|
---|
| 71 | etaAxis_ = NULL;
|
---|
| 72 | phiAxis_ = NULL;
|
---|
| 73 | tk_radius_ = 120.;
|
---|
| 74 | tk_length_ = 150.;
|
---|
| 75 | tk_etamax_ = 3.0;
|
---|
| 76 | tk_Bz_ = 1.;
|
---|
| 77 | muonSystem_radius_ = 200.;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | void Delphes3DGeometry::readFile(const char *configFile,
|
---|
| 81 | const char* ParticlePropagator, const char* TrackingEfficiency,
|
---|
| 82 | const char* MuonEfficiency, const char* Calorimeters) {
|
---|
| 83 |
|
---|
| 84 | ExRootConfReader *confReader = new ExRootConfReader;
|
---|
| 85 | confReader->ReadFile(configFile);
|
---|
| 86 |
|
---|
| 87 | tk_radius_ = confReader->GetDouble(Form("%s::Radius",ParticlePropagator), 1.0)*100.; // tk_radius
|
---|
| 88 | tk_length_ = confReader->GetDouble(Form("%s::HalfLength",ParticlePropagator), 3.0)*100.; // tk_length
|
---|
| 89 | tk_Bz_ = confReader->GetDouble("ParticlePropagator::Bz", 0.0); // tk_Bz
|
---|
| 90 |
|
---|
| 91 | {
|
---|
| 92 | TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",TrackingEfficiency),"abs(eta)<3.0");
|
---|
| 93 | tkEffFormula.ReplaceAll("pt","x");
|
---|
| 94 | tkEffFormula.ReplaceAll("eta","y");
|
---|
| 95 | tkEffFormula.ReplaceAll("phi","0.");
|
---|
| 96 | TF2* tkEffFunction = new TF2("tkEff",tkEffFormula,0,1000,-10,10);
|
---|
| 97 | TH1F etaHisto("eta","eta",100,5.,-5.);
|
---|
| 98 | Double_t pt,eta;
|
---|
| 99 | for(int i=0;i<1000;++i) {
|
---|
| 100 | tkEffFunction->GetRandom2(pt,eta);
|
---|
| 101 | etaHisto.Fill(eta);
|
---|
| 102 | }
|
---|
| 103 | Int_t bin = -1;
|
---|
| 104 | bin = etaHisto.FindFirstBinAbove(0.5);
|
---|
| 105 | Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
|
---|
| 106 | bin = etaHisto.FindLastBinAbove(0.5);
|
---|
| 107 | Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
|
---|
| 108 | tk_etamax_ = TMath::Max(fabs(etamin),fabs(etamax)); // tk_etamax
|
---|
| 109 | delete tkEffFunction;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | {
|
---|
| 113 | muondets_.push_back("muons");
|
---|
| 114 | TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",MuonEfficiency),"abs(eta)<2.0");
|
---|
| 115 | muonEffFormula.ReplaceAll("pt","x");
|
---|
| 116 | muonEffFormula.ReplaceAll("eta","y");
|
---|
| 117 | muonEffFormula.ReplaceAll("phi","0.");
|
---|
| 118 | TF2* muEffFunction = new TF2("muEff",muonEffFormula,0,1000,-10,10);
|
---|
| 119 | TH1F etaHisto("eta2","eta2",100,5.,-5.);
|
---|
| 120 | Double_t pt,eta;
|
---|
| 121 | for(int i=0;i<1000;++i) {
|
---|
| 122 | muEffFunction->GetRandom2(pt,eta);
|
---|
| 123 | etaHisto.Fill(eta);
|
---|
| 124 | }
|
---|
| 125 | Int_t bin = -1;
|
---|
| 126 | bin = etaHisto.FindFirstBinAbove(0.5);
|
---|
| 127 | Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
|
---|
| 128 | bin = etaHisto.FindLastBinAbove(0.5);
|
---|
| 129 | Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
|
---|
| 130 | muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin),fabs(etamax)); // muonSystem_etamax
|
---|
| 131 | delete muEffFunction;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | std::string s(Calorimeters);
|
---|
| 135 | std::replace( s.begin(), s.end(), ',', ' ' );
|
---|
| 136 | std::istringstream stream( s );
|
---|
| 137 | std::string word;
|
---|
| 138 | while (stream >> word) calorimeters_.push_back(word);
|
---|
| 139 |
|
---|
| 140 | caloBinning_.clear(); // calo binning
|
---|
| 141 | for(std::vector<std::string>::const_iterator calo=calorimeters_.begin();calo!=calorimeters_.end(); ++calo) {
|
---|
| 142 | set< pair<Double_t, Int_t> > caloBinning;
|
---|
| 143 | ExRootConfParam paramEtaBins, paramPhiBins;
|
---|
| 144 | ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",calo->c_str()));
|
---|
| 145 | Int_t size = param.GetSize();
|
---|
| 146 | for(int i = 0; i < size/2; ++i) {
|
---|
| 147 | paramEtaBins = param[i*2];
|
---|
| 148 | paramPhiBins = param[i*2+1];
|
---|
| 149 | assert(paramEtaBins.GetSize()==1);
|
---|
| 150 | caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(),paramPhiBins.GetSize()-1));
|
---|
| 151 | }
|
---|
| 152 | caloBinning_[*calo] = caloBinning;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | set< pair<Double_t, Int_t> > caloBinning = caloBinning_[*calorimeters_.begin()];
|
---|
| 156 | Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo
|
---|
| 157 | unsigned int ii = 0;
|
---|
| 158 | for(set< pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) {
|
---|
| 159 | etaBins[ii++] = itEtaSet->first;
|
---|
| 160 | }
|
---|
| 161 | etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins);
|
---|
| 162 | phiAxis_ = new TAxis(72, -TMath::Pi(), TMath::Pi()); // note that this is fixed while #phibins could vary, also with eta, which doesn't seem possible in ROOT
|
---|
| 163 |
|
---|
| 164 | muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_+calo_barrel_thickness_)*calorimeters_.size() + muonSystem_thickn_;
|
---|
| 165 | muonSystem_length_ = tk_length_ + contingency_ + (contingency_+calo_endcap_thickness_)*calorimeters_.size() + muonSystem_thickn_;
|
---|
| 166 |
|
---|
| 167 | delete confReader;
|
---|
| 168 |
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | TGeoVolume* Delphes3DGeometry::getDetector(bool withTowers) {
|
---|
| 172 | // compute the envelope
|
---|
| 173 | Double_t system_radius = tk_radius_+calo_barrel_thickness_+3*contingency_;
|
---|
| 174 | Double_t system_length = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size()+contingency_;
|
---|
| 175 | // the detector volume
|
---|
| 176 | TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length);
|
---|
| 177 | // build the detector
|
---|
| 178 | std::pair<Double_t, Double_t> limits = addTracker(top);
|
---|
| 179 | Double_t radius = limits.first;
|
---|
| 180 | Double_t length = limits.second;
|
---|
| 181 | for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo) {
|
---|
| 182 | limits = addCalorimeter(top,calo->c_str(),radius,length,caloBinning_[*calo]);
|
---|
| 183 | if (withTowers) {
|
---|
| 184 | addCaloTowers(top,calo->c_str(),radius,length,caloBinning_[*calo]);
|
---|
| 185 | }
|
---|
| 186 | radius = limits.first;
|
---|
| 187 | length = limits.second;
|
---|
| 188 | }
|
---|
| 189 | for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon) {
|
---|
| 190 | limits = addMuonDets(top, muon->c_str(), radius, length);
|
---|
| 191 | radius = limits.first;
|
---|
| 192 | length = limits.second;
|
---|
| 193 | }
|
---|
| 194 | // return the result
|
---|
| 195 | return top;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top) {
|
---|
| 199 | // tracker: a cylinder with two cones substracted
|
---|
| 200 | new TGeoCone("forwardTkAcceptance",(tk_length_/2.+0.05),0.,tk_radius_,(tk_length_)*2.*exp(-tk_etamax_)/(1-exp(-2.*tk_etamax_)),tk_radius_);
|
---|
| 201 | TGeoTranslation *tr1 = new TGeoTranslation("tkacc1",0., 0., tk_length_/2.);
|
---|
| 202 | tr1->RegisterYourself();
|
---|
| 203 | TGeoRotation *negz = new TGeoRotation("tknegz",0,180,0);
|
---|
| 204 | negz->RegisterYourself();
|
---|
| 205 | TGeoCombiTrans *tr2 = new TGeoCombiTrans("tkacc2",0.,0.,-tk_length_/2.,negz);
|
---|
| 206 | tr2->RegisterYourself();
|
---|
| 207 | TGeoCompositeShape* tracker_cs = new TGeoCompositeShape("tracker_cs","forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2");
|
---|
| 208 | TGeoVolume *tracker = new TGeoVolume("tracker",tracker_cs,tkmed_);
|
---|
| 209 | tracker->SetLineColor(kYellow);
|
---|
| 210 | top->AddNode(tracker,1);
|
---|
| 211 | return std::make_pair(tk_radius_,tk_length_);
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char* name,
|
---|
| 215 | Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
|
---|
| 216 | // parameters derived from the inputs
|
---|
| 217 | Double_t calo_endcap_etamax = TMath::Max(fabs(caloBinning.begin()->first),fabs(caloBinning.rbegin()->first));
|
---|
| 218 | Double_t calo_barrel_innerRadius = innerBarrelRadius+contingency_;
|
---|
| 219 | Double_t calo_barrel_length = innerBarrelLength + calo_barrel_thickness_;
|
---|
| 220 | Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength));
|
---|
| 221 | Double_t calo_endcap_innerRadius1 = innerBarrelLength*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
|
---|
| 222 | Double_t calo_endcap_innerRadius2 = (innerBarrelLength+calo_endcap_thickness_)*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
|
---|
| 223 | Double_t calo_endcap_outerRadius1 = innerBarrelRadius;
|
---|
| 224 | Double_t calo_endcap_outerRadius2 = innerBarrelRadius+calo_barrel_thickness_;
|
---|
| 225 | Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
|
---|
| 226 | Double_t calo_endcap_diskThickness = TMath::Max(0.,calo_endcap_thickness_-calo_endcap_coneThickness);
|
---|
| 227 |
|
---|
| 228 | // calorimeters: tube truncated in eta + cones
|
---|
| 229 | new TGeoTube(Form("%s_barrel_cylinder",name),calo_barrel_innerRadius,calo_barrel_innerRadius+calo_barrel_thickness_,calo_barrel_length);
|
---|
| 230 | new TGeoCone(Form("%s_endcap_cone",name),calo_endcap_coneThickness/2.,calo_endcap_innerRadius1,calo_endcap_outerRadius1,calo_endcap_innerRadius2,calo_endcap_outerRadius2);
|
---|
| 231 | new TGeoTube(Form("%s_endcap_disk",name),calo_endcap_innerRadius2,tk_radius_+calo_barrel_thickness_,calo_endcap_diskThickness/2.);
|
---|
| 232 | TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1",name),0., 0., (calo_endcap_coneThickness+calo_endcap_diskThickness)/2.);
|
---|
| 233 | tr1->RegisterYourself();
|
---|
| 234 | TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs",name),Form("%s_endcap_cone+%s_endcap_disk:%s_tr1",name,name,name));
|
---|
| 235 | TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.);
|
---|
| 236 | trc1->RegisterYourself();
|
---|
| 237 | TGeoRotation *negz = new TGeoRotation(Form("%s_negz",name),0,180,0);
|
---|
| 238 | TGeoCombiTrans *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.),negz);
|
---|
| 239 | trc2->RegisterYourself();
|
---|
| 240 | TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.+contingency_);
|
---|
| 241 | trc1c->RegisterYourself();
|
---|
| 242 | TGeoCombiTrans *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.)-contingency_,negz);
|
---|
| 243 | trc2c->RegisterYourself();
|
---|
| 244 | TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap",name),calo_endcap_cs,calomed_);
|
---|
| 245 | TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs",name),
|
---|
| 246 | Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position",name,name,name,name,name));
|
---|
| 247 | TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel",name),calo_barrel_cs,calomed_);
|
---|
| 248 | calo_endcap->SetLineColor(kViolet);
|
---|
| 249 | calo_endcap->SetFillColor(kViolet);
|
---|
| 250 | calo_barrel->SetLineColor(kRed);
|
---|
| 251 | top->AddNode(calo_endcap,1,trc1c);
|
---|
| 252 | top->AddNode(calo_endcap,2,trc2c);
|
---|
| 253 | top->AddNode(calo_barrel,1);
|
---|
| 254 | return std::make_pair(calo_barrel_innerRadius+calo_barrel_thickness_,innerBarrelLength+calo_endcap_thickness_+contingency_);
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength) {
|
---|
| 258 | // muon system: tube + disks
|
---|
| 259 | Double_t muonSystem_radius = innerBarrelRadius + contingency_;
|
---|
| 260 | Double_t muonSystem_length = innerBarrelLength + contingency_;
|
---|
| 261 | Double_t muonSystem_rmin = muonSystem_length*2.*exp(-muonSystem_etamax_[name])/(1-exp(-2.*muonSystem_etamax_[name]));
|
---|
| 262 | TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel",name),mudetmed_,muonSystem_radius,muonSystem_radius+muonSystem_thickn_,muonSystem_length);
|
---|
| 263 | muon_barrel->SetLineColor(kBlue);
|
---|
| 264 | top->AddNode(muon_barrel,1);
|
---|
| 265 | TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap",name),mudetmed_,muonSystem_rmin,muonSystem_radius+muonSystem_thickn_,muonSystem_thickn_/2.);
|
---|
| 266 | muon_endcap->SetLineColor(kBlue);
|
---|
| 267 | TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position",name),0.,0.,muonSystem_length);
|
---|
| 268 | trm1->RegisterYourself();
|
---|
| 269 | TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position",name),0.,0.,-muonSystem_length);
|
---|
| 270 | trm1->RegisterYourself();
|
---|
| 271 | top->AddNode(muon_endcap,1,trm1);
|
---|
| 272 | top->AddNode(muon_endcap,2,trm2);
|
---|
| 273 | return std::make_pair(muonSystem_radius,muonSystem_length);
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char* name,
|
---|
| 277 | Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
|
---|
| 278 |
|
---|
| 279 | TGeoVolume* calo_endcap = top->GetNode(Form("%s_endcap_1",name))->GetVolume();
|
---|
| 280 | TGeoVolume* calo_barrel = top->GetNode(Form("%s_barrel_1",name))->GetVolume();
|
---|
| 281 | Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength));
|
---|
| 282 | Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
|
---|
| 283 |
|
---|
| 284 | // calo towers in the barrel
|
---|
| 285 | Double_t vertices[16] = {0.,0.,0.,0.,0.,0.,0.,0.}; // summit of the pyramid
|
---|
| 286 | Double_t R = tk_radius_ + contingency_+(contingency_+calo_barrel_thickness_)*calorimeters_.size(); // radius of the muons system = height of the pyramid
|
---|
| 287 | Int_t nEtaBins = caloBinning.size();
|
---|
| 288 | // this rotation is to make the tower point "up"
|
---|
| 289 | TGeoRotation* initTowerRot = new TGeoRotation(Form("%s_initTowerRot",name),0.,90.,0.);
|
---|
| 290 | TGeoCombiTrans* initTower = new TGeoCombiTrans(Form("%s_initTower",name),0.,-R/2.,0.,initTowerRot);
|
---|
| 291 | initTower->RegisterYourself();
|
---|
| 292 | // eta bins... we build one pyramid per eta slice and then translate it nphi times.
|
---|
| 293 | // phi bins represented by rotations around z
|
---|
| 294 | Double_t *y = new Double_t[nEtaBins];
|
---|
| 295 | Double_t *dx = new Double_t[nEtaBins];
|
---|
| 296 | Int_t *nphi = new Int_t[nEtaBins];
|
---|
| 297 | Int_t etaslice = 0;
|
---|
| 298 | std::map<std::pair<int,int>, TGeoRotation*> phirotations;
|
---|
| 299 | for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
|
---|
| 300 | if(abs(bin->first)>calo_endcap_etamin) continue; // only in the barrel
|
---|
| 301 | nphi[etaslice] = bin->second;
|
---|
| 302 | y[etaslice] = 0.5*R*(1-exp(-2*bin->first))/exp(-bin->first);
|
---|
| 303 | Double_t phiRotationAngle = 360./nphi[etaslice];
|
---|
| 304 | dx[etaslice] = R*tan(TMath::Pi()*phiRotationAngle/360.);
|
---|
| 305 | for(int phislice=0;phislice<nphi[etaslice];++phislice) {
|
---|
| 306 | phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
|
---|
| 307 | phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
|
---|
| 308 | }
|
---|
| 309 | ++etaslice;
|
---|
| 310 | }
|
---|
| 311 | nEtaBins = etaslice;
|
---|
| 312 | for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
|
---|
| 313 | vertices[8] = -dx[i]; vertices[9] = y[i];
|
---|
| 314 | vertices[10] = -dx[i]; vertices[11] = y[i+1];
|
---|
| 315 | vertices[12] = dx[i]; vertices[13] = y[i+1];
|
---|
| 316 | vertices[14] = dx[i]; vertices[15] = y[i];
|
---|
| 317 | new TGeoArb8(Form("%s_tower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
|
---|
| 318 | // intersection between the tower and the calo_barrel
|
---|
| 319 | TGeoCompositeShape *finaltower_cs = new TGeoCompositeShape(Form("%s_ftower%d_cs",name,i),Form("%s_tower%d:%s_initTower*%s_barrel_cs",name,i,name,name));
|
---|
| 320 | TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d",name,i),finaltower_cs,calomed_);
|
---|
| 321 | finaltower->SetLineColor(kRed);
|
---|
| 322 | for(int j=0;j<nphi[i];++j) { // loop on the phi slices
|
---|
| 323 | calo_barrel->AddNode(finaltower,j,phirotations[make_pair(i,j)]);
|
---|
| 324 | }
|
---|
| 325 | }
|
---|
| 326 | delete[] y;
|
---|
| 327 | delete[] dx;
|
---|
| 328 | delete[] nphi;
|
---|
| 329 | //the towers in the forward region
|
---|
| 330 | R = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size(); // Z of the muons system = height of the pyramid
|
---|
| 331 | nEtaBins = caloBinning.size();
|
---|
| 332 | // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place)
|
---|
| 333 | TGeoTranslation* towerdz = new TGeoTranslation(Form("%s_towerdz",name),0.,0.,R/2.-(innerBarrelLength+calo_endcap_coneThickness/2.));
|
---|
| 334 | towerdz->RegisterYourself();
|
---|
| 335 | // eta bins... we build one pyramid per eta slice and then translate it nphi times.
|
---|
| 336 | Double_t *r = new Double_t[nEtaBins];
|
---|
| 337 | nphi = new Int_t[nEtaBins];
|
---|
| 338 | etaslice = 0;
|
---|
| 339 | phirotations.clear();
|
---|
| 340 | for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
|
---|
| 341 | if(bin->first<calo_endcap_etamin) continue; // only in the + endcap
|
---|
| 342 | r[etaslice] = R*2*exp(-bin->first)/(1-exp(-2*bin->first));
|
---|
| 343 | nphi[etaslice] = bin->second;
|
---|
| 344 | Double_t phiRotationAngle = 360./nphi[etaslice];
|
---|
| 345 | for(int phislice=0;phislice<nphi[etaslice];++phislice) {
|
---|
| 346 | phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
|
---|
| 347 | phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
|
---|
| 348 | }
|
---|
| 349 | ++etaslice;
|
---|
| 350 | }
|
---|
| 351 | nEtaBins = etaslice;
|
---|
| 352 | for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
|
---|
| 353 | vertices[8] = -r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[9] = r[i+1]*cos(TMath::Pi()/nphi[i]);
|
---|
| 354 | vertices[10] = -r[i]*sin(TMath::Pi()/nphi[i]); vertices[11] = r[i]*cos(TMath::Pi()/nphi[i]);
|
---|
| 355 | vertices[12] = r[i]*sin(TMath::Pi()/nphi[i]); vertices[13] = r[i]*cos(TMath::Pi()/nphi[i]);
|
---|
| 356 | vertices[14] = r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[15] = r[i+1]*cos(TMath::Pi()/nphi[i]);
|
---|
| 357 | new TGeoArb8(Form("%sfwdtower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
|
---|
| 358 | // intersection between the tower and the calo_endcap
|
---|
| 359 | TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs",name,i),Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs",name,i,name,name));
|
---|
| 360 | TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d",name,i),finalfwdtower_cs,calomed_);
|
---|
| 361 | finalfwdtower->SetLineColor(kViolet);
|
---|
| 362 | for(int j=0;j<nphi[i];++j) { // loop on the phi slices
|
---|
| 363 | calo_endcap->AddNode(finalfwdtower,j,phirotations[make_pair(i,j)]);
|
---|
| 364 | }
|
---|
| 365 | }
|
---|
| 366 | delete[] r;
|
---|
| 367 | delete[] nphi;
|
---|
| 368 | }
|
---|
| 369 |
|
---|