- Timestamp:
- Feb 12, 2019, 9:29:17 PM (6 years ago)
- Branches:
- ImprovedOutputFile, Timing, llp, master
- Children:
- 6455202
- Parents:
- 45e58be
- Location:
- display
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
display/Delphes3DGeometry.cc
r45e58be r341014c 17 17 */ 18 18 19 #include <algorithm> 20 #include <cassert> 21 #include <map> 19 22 #include <set> 20 #include < map>23 #include <sstream> 21 24 #include <utility> 22 25 #include <vector> 23 #include <algorithm>24 #include <sstream>25 #include <cassert>26 26 27 27 #include "TAxis.h" 28 #include "TF2.h" 29 #include "TFormula.h" 30 #include "TGeoArb8.h" 31 #include "TGeoCompositeShape.h" 32 #include "TGeoCone.h" 28 33 #include "TGeoManager.h" 29 #include "TGeo Volume.h"34 #include "TGeoMatrix.h" 30 35 #include "TGeoMedium.h" 31 36 #include "TGeoNode.h" 32 #include "TGeoCompositeShape.h"33 #include "TGeoMatrix.h"34 37 #include "TGeoTube.h" 35 #include "TGeoCone.h" 36 #include "TGeoArb8.h" 37 #include "TF2.h" 38 #include "TFormula.h" 38 #include "TGeoVolume.h" 39 39 #include "TH1F.h" 40 40 #include "TMath.h" … … 48 48 using namespace std; 49 49 50 Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom, bool transp) { 51 52 //--- the geometry manager 53 geom_ = geom==NULL? gGeoManager : geom; 54 //gGeoManager->DefaultColors(); 55 56 //--- define some materials 57 TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0); 58 TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // placeholder 59 if(transp) { 60 matVacuum->SetTransparency(85); 61 matAl->SetTransparency(85); 62 } 63 64 //--- define some media 65 TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum); 66 TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl); 67 vacuum_ = Vacuum; 68 tkmed_ = Vacuum; // placeholder 69 calomed_ = Al; // placeholder 70 mudetmed_ = Al; // placeholder 71 72 // custom parameters 73 contingency_ = 10.; 74 calo_barrel_thickness_ = 50.; 75 calo_endcap_thickness_ = 75.; 76 muonSystem_thickn_ = 10.; 77 78 // read these parameters from the Delphes Card (with default values) 79 etaAxis_ = NULL; 80 phiAxis_ = NULL; 81 tk_radius_ = 120.; 82 tk_length_ = 150.; 83 tk_etamax_ = 3.0; 84 tk_Bz_ = 1.; 85 muonSystem_radius_ = 200.; 50 Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom, bool transp) 51 { 52 53 //--- the geometry manager 54 geom_ = geom == NULL ? gGeoManager : geom; 55 //gGeoManager->DefaultColors(); 56 57 //--- define some materials 58 TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0); 59 TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7); // placeholder 60 if(transp) 61 { 62 matVacuum->SetTransparency(85); 63 matAl->SetTransparency(85); 64 } 65 66 //--- define some media 67 TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum); 68 TGeoMedium *Al = new TGeoMedium("Root Material", 2, matAl); 69 vacuum_ = Vacuum; 70 tkmed_ = Vacuum; // placeholder 71 calomed_ = Al; // placeholder 72 mudetmed_ = Al; // placeholder 73 74 // custom parameters 75 contingency_ = 10.; 76 calo_barrel_thickness_ = 50.; 77 calo_endcap_thickness_ = 75.; 78 muonSystem_thickn_ = 10.; 79 80 // read these parameters from the Delphes Card (with default values) 81 etaAxis_ = NULL; 82 phiAxis_ = NULL; 83 tk_radius_ = 120.; 84 tk_length_ = 150.; 85 tk_etamax_ = 3.0; 86 tk_Bz_ = 1.; 87 muonSystem_radius_ = 200.; 86 88 } 87 89 88 90 void Delphes3DGeometry::readFile(const char *configFile, 89 const char* ParticlePropagator, const char* TrackingEfficiency, 90 const char* MuonEfficiency, const char* Calorimeters) { 91 92 ExRootConfReader *confReader = new ExRootConfReader; 93 confReader->ReadFile(configFile); 94 95 tk_radius_ = confReader->GetDouble(Form("%s::Radius",ParticlePropagator), 1.0)*100.; // tk_radius 96 tk_length_ = confReader->GetDouble(Form("%s::HalfLength",ParticlePropagator), 3.0)*100.; // tk_length 97 tk_Bz_ = confReader->GetDouble("ParticlePropagator::Bz", 0.0); // tk_Bz 98 99 TString buffer; 100 const char *it; 101 102 103 { 104 TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",TrackingEfficiency),"abs(eta)<3.0"); 105 tkEffFormula.ReplaceAll("pt","x"); 106 tkEffFormula.ReplaceAll("eta","y"); 107 tkEffFormula.ReplaceAll("phi","0."); 108 109 buffer.Clear(); 110 for(it = tkEffFormula.Data(); *it; ++it) 111 { 112 if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue; 113 buffer.Append(*it); 114 } 115 116 TF2* tkEffFunction = new TF2("tkEff",buffer,0,1000,-10,10); 117 TH1F etaHisto("eta","eta",100,5.,-5.); 118 Double_t pt,eta; 119 for(int i=0;i<1000;++i) { 120 tkEffFunction->GetRandom2(pt,eta); 121 etaHisto.Fill(eta); 122 } 123 Int_t bin = -1; 124 bin = etaHisto.FindFirstBinAbove(0.5); 125 Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.; 126 bin = etaHisto.FindLastBinAbove(0.5); 127 Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.; 128 tk_etamax_ = TMath::Max(fabs(etamin),fabs(etamax)); // tk_etamax 129 delete tkEffFunction; 130 } 131 132 { 133 muondets_.push_back("muons"); 134 TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",MuonEfficiency),"abs(eta)<2.0"); 135 muonEffFormula.ReplaceAll("pt","x"); 136 muonEffFormula.ReplaceAll("eta","y"); 137 muonEffFormula.ReplaceAll("phi","0."); 138 139 buffer.Clear(); 140 for(it = muonEffFormula.Data(); *it; ++it) 141 { 142 if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue; 143 buffer.Append(*it); 144 } 145 146 TF2* muEffFunction = new TF2("muEff",buffer,0,1000,-10,10); 147 TH1F etaHisto("eta2","eta2",100,5.,-5.); 148 Double_t pt,eta; 149 for(int i=0;i<1000;++i) { 150 muEffFunction->GetRandom2(pt,eta); 151 etaHisto.Fill(eta); 152 } 153 Int_t bin = -1; 154 bin = etaHisto.FindFirstBinAbove(0.5); 155 Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.; 156 bin = etaHisto.FindLastBinAbove(0.5); 157 Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.; 158 muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin),fabs(etamax)); // muonSystem_etamax 159 delete muEffFunction; 160 } 161 162 std::string s(Calorimeters); 163 std::replace( s.begin(), s.end(), ',', ' ' ); 164 std::istringstream stream( s ); 165 std::string word; 166 while (stream >> word) calorimeters_.push_back(word); 167 168 caloBinning_.clear(); // calo binning 169 for(std::vector<std::string>::const_iterator calo=calorimeters_.begin();calo!=calorimeters_.end(); ++calo) { 170 set< pair<Double_t, Int_t> > caloBinning; 171 ExRootConfParam paramEtaBins, paramPhiBins; 172 ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",calo->c_str())); 173 Int_t size = param.GetSize(); 174 for(int i = 0; i < size/2; ++i) { 175 paramEtaBins = param[i*2]; 176 paramPhiBins = param[i*2+1]; 177 assert(paramEtaBins.GetSize()==1); 178 caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(),paramPhiBins.GetSize()-1)); 179 } 180 caloBinning_[*calo] = caloBinning; 181 } 182 183 set< pair<Double_t, Int_t> > caloBinning = caloBinning_[*calorimeters_.begin()]; 184 Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo 185 unsigned int ii = 0; 186 for(set< pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) { 187 etaBins[ii++] = itEtaSet->first; 188 } 189 etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins); 190 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 191 192 muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_+calo_barrel_thickness_)*calorimeters_.size() + muonSystem_thickn_; 193 muonSystem_length_ = tk_length_ + contingency_ + (contingency_+calo_endcap_thickness_)*calorimeters_.size() + muonSystem_thickn_; 194 195 delete confReader; 196 197 } 198 199 TGeoVolume* Delphes3DGeometry::getDetector(bool withTowers) { 200 // compute the envelope 201 Double_t system_radius = tk_radius_+calo_barrel_thickness_+3*contingency_; 202 Double_t system_length = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size()+contingency_; 203 // the detector volume 204 TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length); 205 // build the detector 206 std::pair<Double_t, Double_t> limits = addTracker(top); 207 Double_t radius = limits.first; 208 Double_t length = limits.second; 209 for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo) { 210 limits = addCalorimeter(top,calo->c_str(),radius,length,caloBinning_[*calo]); 211 if (withTowers) { 212 addCaloTowers(top,calo->c_str(),radius,length,caloBinning_[*calo]); 213 } 214 radius = limits.first; 215 length = limits.second; 216 } 217 for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon) { 218 limits = addMuonDets(top, muon->c_str(), radius, length); 219 radius = limits.first; 220 length = limits.second; 221 } 222 // return the result 223 return top; 224 } 225 226 std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top) { 227 // tracker: a cylinder with two cones substracted 228 new TGeoCone("forwardTkAcceptance",(tk_length_/2.+0.05),0.,tk_radius_,(tk_length_)*2.*exp(-tk_etamax_)/(1-exp(-2.*tk_etamax_)),tk_radius_); 229 TGeoTranslation *tr1 = new TGeoTranslation("tkacc1",0., 0., tk_length_/2.); 230 tr1->RegisterYourself(); 231 TGeoRotation *negz = new TGeoRotation("tknegz",0,180,0); 232 negz->RegisterYourself(); 233 TGeoCombiTrans *tr2 = new TGeoCombiTrans("tkacc2",0.,0.,-tk_length_/2.,negz); 234 tr2->RegisterYourself(); 235 TGeoCompositeShape* tracker_cs = new TGeoCompositeShape("tracker_cs","forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2"); 236 TGeoVolume *tracker = new TGeoVolume("tracker",tracker_cs,tkmed_); 237 tracker->SetLineColor(kYellow); 238 top->AddNode(tracker,1); 239 return std::make_pair(tk_radius_,tk_length_); 240 } 241 242 std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char* name, 243 Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) { 244 // parameters derived from the inputs 245 Double_t calo_endcap_etamax = TMath::Max(fabs(caloBinning.begin()->first),fabs(caloBinning.rbegin()->first)); 246 Double_t calo_barrel_innerRadius = innerBarrelRadius+contingency_; 247 Double_t calo_barrel_length = innerBarrelLength + calo_barrel_thickness_; 248 Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength)); 249 Double_t calo_endcap_innerRadius1 = innerBarrelLength*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax)); 250 Double_t calo_endcap_innerRadius2 = (innerBarrelLength+calo_endcap_thickness_)*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax)); 251 Double_t calo_endcap_outerRadius1 = innerBarrelRadius; 252 Double_t calo_endcap_outerRadius2 = innerBarrelRadius+calo_barrel_thickness_; 253 Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_); 254 Double_t calo_endcap_diskThickness = TMath::Max(0.,calo_endcap_thickness_-calo_endcap_coneThickness); 255 256 // calorimeters: tube truncated in eta + cones 257 new TGeoTube(Form("%s_barrel_cylinder",name),calo_barrel_innerRadius,calo_barrel_innerRadius+calo_barrel_thickness_,calo_barrel_length); 258 new TGeoCone(Form("%s_endcap_cone",name),calo_endcap_coneThickness/2.,calo_endcap_innerRadius1,calo_endcap_outerRadius1,calo_endcap_innerRadius2,calo_endcap_outerRadius2); 259 new TGeoTube(Form("%s_endcap_disk",name),calo_endcap_innerRadius2,tk_radius_+calo_barrel_thickness_,calo_endcap_diskThickness/2.); 260 TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1",name),0., 0., (calo_endcap_coneThickness+calo_endcap_diskThickness)/2.); 261 tr1->RegisterYourself(); 262 TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs",name),Form("%s_endcap_cone+%s_endcap_disk:%s_tr1",name,name,name)); 263 TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.); 264 trc1->RegisterYourself(); 265 TGeoRotation *negz = new TGeoRotation(Form("%s_negz",name),0,180,0); 266 TGeoCombiTrans *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.),negz); 267 trc2->RegisterYourself(); 268 TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.+contingency_); 269 trc1c->RegisterYourself(); 270 TGeoCombiTrans *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.)-contingency_,negz); 271 trc2c->RegisterYourself(); 272 TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap",name),calo_endcap_cs,calomed_); 273 TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs",name), 274 Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position",name,name,name,name,name)); 275 TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel",name),calo_barrel_cs,calomed_); 276 calo_endcap->SetLineColor(kViolet); 277 calo_endcap->SetFillColor(kViolet); 278 calo_barrel->SetLineColor(kRed); 279 top->AddNode(calo_endcap,1,trc1c); 280 top->AddNode(calo_endcap,2,trc2c); 281 top->AddNode(calo_barrel,1); 282 return std::make_pair(calo_barrel_innerRadius+calo_barrel_thickness_,innerBarrelLength+calo_endcap_thickness_+contingency_); 283 } 284 285 std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength) { 286 // muon system: tube + disks 287 Double_t muonSystem_radius = innerBarrelRadius + contingency_; 288 Double_t muonSystem_length = innerBarrelLength + contingency_; 289 Double_t muonSystem_rmin = muonSystem_length*2.*exp(-muonSystem_etamax_[name])/(1-exp(-2.*muonSystem_etamax_[name])); 290 TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel",name),mudetmed_,muonSystem_radius,muonSystem_radius+muonSystem_thickn_,muonSystem_length); 291 muon_barrel->SetLineColor(kBlue); 292 top->AddNode(muon_barrel,1); 293 TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap",name),mudetmed_,muonSystem_rmin,muonSystem_radius+muonSystem_thickn_,muonSystem_thickn_/2.); 294 muon_endcap->SetLineColor(kBlue); 295 TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position",name),0.,0.,muonSystem_length); 296 trm1->RegisterYourself(); 297 TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position",name),0.,0.,-muonSystem_length); 298 trm1->RegisterYourself(); 299 top->AddNode(muon_endcap,1,trm1); 300 top->AddNode(muon_endcap,2,trm2); 301 return std::make_pair(muonSystem_radius,muonSystem_length); 302 } 303 304 void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char* name, 305 Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) { 306 307 TGeoVolume* calo_endcap = top->GetNode(Form("%s_endcap_1",name))->GetVolume(); 308 TGeoVolume* calo_barrel = top->GetNode(Form("%s_barrel_1",name))->GetVolume(); 309 Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength)); 310 Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_); 311 312 // calo towers in the barrel 313 Double_t vertices[16] = {0.,0.,0.,0.,0.,0.,0.,0.}; // summit of the pyramid 314 Double_t R = tk_radius_ + contingency_+(contingency_+calo_barrel_thickness_)*calorimeters_.size(); // radius of the muons system = height of the pyramid 315 Int_t nEtaBins = caloBinning.size(); 316 // this rotation is to make the tower point "up" 317 TGeoRotation* initTowerRot = new TGeoRotation(Form("%s_initTowerRot",name),0.,90.,0.); 318 TGeoCombiTrans* initTower = new TGeoCombiTrans(Form("%s_initTower",name),0.,-R/2.,0.,initTowerRot); 319 initTower->RegisterYourself(); 320 // eta bins... we build one pyramid per eta slice and then translate it nphi times. 321 // phi bins represented by rotations around z 322 Double_t *y = new Double_t[nEtaBins]; 323 Double_t *dx = new Double_t[nEtaBins]; 324 Int_t *nphi = new Int_t[nEtaBins]; 325 Int_t etaslice = 0; 326 std::map<std::pair<int,int>, TGeoRotation*> phirotations; 327 for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) { 328 if(abs(bin->first)>calo_endcap_etamin) continue; // only in the barrel 329 nphi[etaslice] = bin->second; 330 y[etaslice] = 0.5*R*(1-exp(-2*bin->first))/exp(-bin->first); 331 Double_t phiRotationAngle = 360./nphi[etaslice]; 332 dx[etaslice] = R*tan(TMath::Pi()*phiRotationAngle/360.); 333 for(int phislice=0;phislice<nphi[etaslice];++phislice) { 334 phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.); 335 phirotations[make_pair(etaslice,phislice)]->RegisterYourself(); 336 } 337 ++etaslice; 338 } 339 nEtaBins = etaslice; 340 for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices 341 vertices[8] = -dx[i]; vertices[9] = y[i]; 342 vertices[10] = -dx[i]; vertices[11] = y[i+1]; 343 vertices[12] = dx[i]; vertices[13] = y[i+1]; 344 vertices[14] = dx[i]; vertices[15] = y[i]; 345 new TGeoArb8(Form("%s_tower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0 346 // intersection between the tower and the calo_barrel 347 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)); 348 TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d",name,i),finaltower_cs,calomed_); 349 finaltower->SetLineColor(kRed); 350 for(int j=0;j<nphi[i];++j) { // loop on the phi slices 351 calo_barrel->AddNode(finaltower,j,phirotations[make_pair(i,j)]); 352 } 353 } 354 delete[] y; 355 delete[] dx; 356 delete[] nphi; 357 //the towers in the forward region 358 R = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size(); // Z of the muons system = height of the pyramid 359 nEtaBins = caloBinning.size(); 360 // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place) 361 TGeoTranslation* towerdz = new TGeoTranslation(Form("%s_towerdz",name),0.,0.,R/2.-(innerBarrelLength+calo_endcap_coneThickness/2.)); 362 towerdz->RegisterYourself(); 363 // eta bins... we build one pyramid per eta slice and then translate it nphi times. 364 Double_t *r = new Double_t[nEtaBins]; 365 nphi = new Int_t[nEtaBins]; 366 etaslice = 0; 367 phirotations.clear(); 368 for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) { 369 if(bin->first<calo_endcap_etamin) continue; // only in the + endcap 370 r[etaslice] = R*2*exp(-bin->first)/(1-exp(-2*bin->first)); 371 nphi[etaslice] = bin->second; 372 Double_t phiRotationAngle = 360./nphi[etaslice]; 373 for(int phislice=0;phislice<nphi[etaslice];++phislice) { 374 phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.); 375 phirotations[make_pair(etaslice,phislice)]->RegisterYourself(); 376 } 377 ++etaslice; 378 } 379 nEtaBins = etaslice; 380 for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices 381 vertices[8] = -r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[9] = r[i+1]*cos(TMath::Pi()/nphi[i]); 382 vertices[10] = -r[i]*sin(TMath::Pi()/nphi[i]); vertices[11] = r[i]*cos(TMath::Pi()/nphi[i]); 383 vertices[12] = r[i]*sin(TMath::Pi()/nphi[i]); vertices[13] = r[i]*cos(TMath::Pi()/nphi[i]); 384 vertices[14] = r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[15] = r[i+1]*cos(TMath::Pi()/nphi[i]); 385 new TGeoArb8(Form("%sfwdtower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0 386 // intersection between the tower and the calo_endcap 387 TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs",name,i),Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs",name,i,name,name)); 388 TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d",name,i),finalfwdtower_cs,calomed_); 389 finalfwdtower->SetLineColor(kViolet); 390 for(int j=0;j<nphi[i];++j) { // loop on the phi slices 391 calo_endcap->AddNode(finalfwdtower,j,phirotations[make_pair(i,j)]); 392 } 393 } 394 delete[] r; 395 delete[] nphi; 396 } 397 91 const char *ParticlePropagator, const char *TrackingEfficiency, 92 const char *MuonEfficiency, const char *Calorimeters) 93 { 94 95 ExRootConfReader *confReader = new ExRootConfReader; 96 confReader->ReadFile(configFile); 97 98 tk_radius_ = confReader->GetDouble(Form("%s::Radius", ParticlePropagator), 1.0) * 100.; // tk_radius 99 tk_length_ = confReader->GetDouble(Form("%s::HalfLength", ParticlePropagator), 3.0) * 100.; // tk_length 100 tk_Bz_ = confReader->GetDouble("ParticlePropagator::Bz", 0.0); // tk_Bz 101 102 TString buffer; 103 const char *it; 104 105 { 106 TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula", TrackingEfficiency), "abs(eta)<3.0"); 107 tkEffFormula.ReplaceAll("pt", "x"); 108 tkEffFormula.ReplaceAll("eta", "y"); 109 tkEffFormula.ReplaceAll("phi", "0."); 110 111 buffer.Clear(); 112 for(it = tkEffFormula.Data(); *it; ++it) 113 { 114 if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue; 115 buffer.Append(*it); 116 } 117 118 TF2 *tkEffFunction = new TF2("tkEff", buffer, 0, 1000, -10, 10); 119 TH1F etaHisto("eta", "eta", 100, 5., -5.); 120 Double_t pt, eta; 121 for(int i = 0; i < 1000; ++i) 122 { 123 tkEffFunction->GetRandom2(pt, eta); 124 etaHisto.Fill(eta); 125 } 126 Int_t bin = -1; 127 bin = etaHisto.FindFirstBinAbove(0.5); 128 Double_t etamin = (bin > -1) ? etaHisto.GetBinLowEdge(bin) : -10.; 129 bin = etaHisto.FindLastBinAbove(0.5); 130 Double_t etamax = (bin > -1) ? etaHisto.GetBinLowEdge(bin + 1) : -10.; 131 tk_etamax_ = TMath::Max(fabs(etamin), fabs(etamax)); // tk_etamax 132 delete tkEffFunction; 133 } 134 135 { 136 muondets_.push_back("muons"); 137 TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula", MuonEfficiency), "abs(eta)<2.0"); 138 muonEffFormula.ReplaceAll("pt", "x"); 139 muonEffFormula.ReplaceAll("eta", "y"); 140 muonEffFormula.ReplaceAll("phi", "0."); 141 142 buffer.Clear(); 143 for(it = muonEffFormula.Data(); *it; ++it) 144 { 145 if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue; 146 buffer.Append(*it); 147 } 148 149 TF2 *muEffFunction = new TF2("muEff", buffer, 0, 1000, -10, 10); 150 TH1F etaHisto("eta2", "eta2", 100, 5., -5.); 151 Double_t pt, eta; 152 for(int i = 0; i < 1000; ++i) 153 { 154 muEffFunction->GetRandom2(pt, eta); 155 etaHisto.Fill(eta); 156 } 157 Int_t bin = -1; 158 bin = etaHisto.FindFirstBinAbove(0.5); 159 Double_t etamin = (bin > -1) ? etaHisto.GetBinLowEdge(bin) : -10.; 160 bin = etaHisto.FindLastBinAbove(0.5); 161 Double_t etamax = (bin > -1) ? etaHisto.GetBinLowEdge(bin + 1) : -10.; 162 muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin), fabs(etamax)); // muonSystem_etamax 163 delete muEffFunction; 164 } 165 166 std::string s(Calorimeters); 167 std::replace(s.begin(), s.end(), ',', ' '); 168 std::istringstream stream(s); 169 std::string word; 170 while(stream >> word) calorimeters_.push_back(word); 171 172 caloBinning_.clear(); // calo binning 173 for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo) 174 { 175 set<pair<Double_t, Int_t>> caloBinning; 176 ExRootConfParam paramEtaBins, paramPhiBins; 177 ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins", calo->c_str())); 178 Int_t size = param.GetSize(); 179 for(int i = 0; i < size / 2; ++i) 180 { 181 paramEtaBins = param[i * 2]; 182 paramPhiBins = param[i * 2 + 1]; 183 assert(paramEtaBins.GetSize() == 1); 184 caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(), paramPhiBins.GetSize() - 1)); 185 } 186 caloBinning_[*calo] = caloBinning; 187 } 188 189 set<pair<Double_t, Int_t>> caloBinning = caloBinning_[*calorimeters_.begin()]; 190 Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo 191 unsigned int ii = 0; 192 for(set<pair<Double_t, Int_t>>::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) 193 { 194 etaBins[ii++] = itEtaSet->first; 195 } 196 etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins); 197 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 198 199 muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_ + calo_barrel_thickness_) * calorimeters_.size() + muonSystem_thickn_; 200 muonSystem_length_ = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size() + muonSystem_thickn_; 201 202 delete confReader; 203 } 204 205 TGeoVolume *Delphes3DGeometry::getDetector(bool withTowers) 206 { 207 // compute the envelope 208 Double_t system_radius = tk_radius_ + calo_barrel_thickness_ + 3 * contingency_; 209 Double_t system_length = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size() + contingency_; 210 // the detector volume 211 TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length); 212 // build the detector 213 std::pair<Double_t, Double_t> limits = addTracker(top); 214 Double_t radius = limits.first; 215 Double_t length = limits.second; 216 for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo) 217 { 218 limits = addCalorimeter(top, calo->c_str(), radius, length, caloBinning_[*calo]); 219 if(withTowers) 220 { 221 addCaloTowers(top, calo->c_str(), radius, length, caloBinning_[*calo]); 222 } 223 radius = limits.first; 224 length = limits.second; 225 } 226 for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon) 227 { 228 limits = addMuonDets(top, muon->c_str(), radius, length); 229 radius = limits.first; 230 length = limits.second; 231 } 232 // return the result 233 return top; 234 } 235 236 std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top) 237 { 238 // tracker: a cylinder with two cones substracted 239 new TGeoCone("forwardTkAcceptance", (tk_length_ / 2. + 0.05), 0., tk_radius_, (tk_length_)*2. * exp(-tk_etamax_) / (1 - exp(-2. * tk_etamax_)), tk_radius_); 240 TGeoTranslation *tr1 = new TGeoTranslation("tkacc1", 0., 0., tk_length_ / 2.); 241 tr1->RegisterYourself(); 242 TGeoRotation *negz = new TGeoRotation("tknegz", 0, 180, 0); 243 negz->RegisterYourself(); 244 TGeoCombiTrans *tr2 = new TGeoCombiTrans("tkacc2", 0., 0., -tk_length_ / 2., negz); 245 tr2->RegisterYourself(); 246 TGeoCompositeShape *tracker_cs = new TGeoCompositeShape("tracker_cs", "forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2"); 247 TGeoVolume *tracker = new TGeoVolume("tracker", tracker_cs, tkmed_); 248 tracker->SetLineColor(kYellow); 249 top->AddNode(tracker, 1); 250 return std::make_pair(tk_radius_, tk_length_); 251 } 252 253 std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char *name, 254 Double_t innerBarrelRadius, Double_t innerBarrelLength, set<pair<Double_t, Int_t>> &caloBinning) 255 { 256 // parameters derived from the inputs 257 Double_t calo_endcap_etamax = TMath::Max(fabs(caloBinning.begin()->first), fabs(caloBinning.rbegin()->first)); 258 Double_t calo_barrel_innerRadius = innerBarrelRadius + contingency_; 259 Double_t calo_barrel_length = innerBarrelLength + calo_barrel_thickness_; 260 Double_t calo_endcap_etamin = -log(innerBarrelRadius / (2 * innerBarrelLength)); 261 Double_t calo_endcap_innerRadius1 = innerBarrelLength * 2. * exp(-calo_endcap_etamax) / (1 - exp(-2. * calo_endcap_etamax)); 262 Double_t calo_endcap_innerRadius2 = (innerBarrelLength + calo_endcap_thickness_) * 2. * exp(-calo_endcap_etamax) / (1 - exp(-2. * calo_endcap_etamax)); 263 Double_t calo_endcap_outerRadius1 = innerBarrelRadius; 264 Double_t calo_endcap_outerRadius2 = innerBarrelRadius + calo_barrel_thickness_; 265 Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1 - exp(-2. * calo_endcap_etamin)) / (2. * exp(-calo_endcap_etamin)), calo_endcap_thickness_); 266 Double_t calo_endcap_diskThickness = TMath::Max(0., calo_endcap_thickness_ - calo_endcap_coneThickness); 267 268 // calorimeters: tube truncated in eta + cones 269 new TGeoTube(Form("%s_barrel_cylinder", name), calo_barrel_innerRadius, calo_barrel_innerRadius + calo_barrel_thickness_, calo_barrel_length); 270 new TGeoCone(Form("%s_endcap_cone", name), calo_endcap_coneThickness / 2., calo_endcap_innerRadius1, calo_endcap_outerRadius1, calo_endcap_innerRadius2, calo_endcap_outerRadius2); 271 new TGeoTube(Form("%s_endcap_disk", name), calo_endcap_innerRadius2, tk_radius_ + calo_barrel_thickness_, calo_endcap_diskThickness / 2.); 272 TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1", name), 0., 0., (calo_endcap_coneThickness + calo_endcap_diskThickness) / 2.); 273 tr1->RegisterYourself(); 274 TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs", name), Form("%s_endcap_cone+%s_endcap_disk:%s_tr1", name, name, name)); 275 TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position", name), 0., 0., innerBarrelLength + calo_endcap_coneThickness / 2.); 276 trc1->RegisterYourself(); 277 TGeoRotation *negz = new TGeoRotation(Form("%s_negz", name), 0, 180, 0); 278 TGeoCombiTrans *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position", name), 0., 0., -(innerBarrelLength + calo_endcap_coneThickness / 2.), negz); 279 trc2->RegisterYourself(); 280 TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont", name), 0., 0., innerBarrelLength + calo_endcap_coneThickness / 2. + contingency_); 281 trc1c->RegisterYourself(); 282 TGeoCombiTrans *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont", name), 0., 0., -(innerBarrelLength + calo_endcap_coneThickness / 2.) - contingency_, negz); 283 trc2c->RegisterYourself(); 284 TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap", name), calo_endcap_cs, calomed_); 285 TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs", name), 286 Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position", name, name, name, name, name)); 287 TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel", name), calo_barrel_cs, calomed_); 288 calo_endcap->SetLineColor(kViolet); 289 calo_endcap->SetFillColor(kViolet); 290 calo_barrel->SetLineColor(kRed); 291 top->AddNode(calo_endcap, 1, trc1c); 292 top->AddNode(calo_endcap, 2, trc2c); 293 top->AddNode(calo_barrel, 1); 294 return std::make_pair(calo_barrel_innerRadius + calo_barrel_thickness_, innerBarrelLength + calo_endcap_thickness_ + contingency_); 295 } 296 297 std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength) 298 { 299 // muon system: tube + disks 300 Double_t muonSystem_radius = innerBarrelRadius + contingency_; 301 Double_t muonSystem_length = innerBarrelLength + contingency_; 302 Double_t muonSystem_rmin = muonSystem_length * 2. * exp(-muonSystem_etamax_[name]) / (1 - exp(-2. * muonSystem_etamax_[name])); 303 TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel", name), mudetmed_, muonSystem_radius, muonSystem_radius + muonSystem_thickn_, muonSystem_length); 304 muon_barrel->SetLineColor(kBlue); 305 top->AddNode(muon_barrel, 1); 306 TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap", name), mudetmed_, muonSystem_rmin, muonSystem_radius + muonSystem_thickn_, muonSystem_thickn_ / 2.); 307 muon_endcap->SetLineColor(kBlue); 308 TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position", name), 0., 0., muonSystem_length); 309 trm1->RegisterYourself(); 310 TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position", name), 0., 0., -muonSystem_length); 311 trm1->RegisterYourself(); 312 top->AddNode(muon_endcap, 1, trm1); 313 top->AddNode(muon_endcap, 2, trm2); 314 return std::make_pair(muonSystem_radius, muonSystem_length); 315 } 316 317 void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char *name, 318 Double_t innerBarrelRadius, Double_t innerBarrelLength, set<pair<Double_t, Int_t>> &caloBinning) 319 { 320 321 TGeoVolume *calo_endcap = top->GetNode(Form("%s_endcap_1", name))->GetVolume(); 322 TGeoVolume *calo_barrel = top->GetNode(Form("%s_barrel_1", name))->GetVolume(); 323 Double_t calo_endcap_etamin = -log(innerBarrelRadius / (2 * innerBarrelLength)); 324 Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1 - exp(-2. * calo_endcap_etamin)) / (2. * exp(-calo_endcap_etamin)), calo_endcap_thickness_); 325 326 // calo towers in the barrel 327 Double_t vertices[16] = {0., 0., 0., 0., 0., 0., 0., 0.}; // summit of the pyramid 328 Double_t R = tk_radius_ + contingency_ + (contingency_ + calo_barrel_thickness_) * calorimeters_.size(); // radius of the muons system = height of the pyramid 329 Int_t nEtaBins = caloBinning.size(); 330 // this rotation is to make the tower point "up" 331 TGeoRotation *initTowerRot = new TGeoRotation(Form("%s_initTowerRot", name), 0., 90., 0.); 332 TGeoCombiTrans *initTower = new TGeoCombiTrans(Form("%s_initTower", name), 0., -R / 2., 0., initTowerRot); 333 initTower->RegisterYourself(); 334 // eta bins... we build one pyramid per eta slice and then translate it nphi times. 335 // phi bins represented by rotations around z 336 Double_t *y = new Double_t[nEtaBins]; 337 Double_t *dx = new Double_t[nEtaBins]; 338 Int_t *nphi = new Int_t[nEtaBins]; 339 Int_t etaslice = 0; 340 std::map<std::pair<int, int>, TGeoRotation *> phirotations; 341 for(set<pair<Double_t, Int_t>>::const_iterator bin = caloBinning.begin(); bin != caloBinning.end(); ++bin) 342 { 343 if(abs(bin->first) > calo_endcap_etamin) continue; // only in the barrel 344 nphi[etaslice] = bin->second; 345 y[etaslice] = 0.5 * R * (1 - exp(-2 * bin->first)) / exp(-bin->first); 346 Double_t phiRotationAngle = 360. / nphi[etaslice]; 347 dx[etaslice] = R * tan(TMath::Pi() * phiRotationAngle / 360.); 348 for(int phislice = 0; phislice < nphi[etaslice]; ++phislice) 349 { 350 phirotations[make_pair(etaslice, phislice)] = new TGeoRotation(Form("%s_phi%d_%d", name, etaslice, phislice), phiRotationAngle * phislice, 0., 0.); 351 phirotations[make_pair(etaslice, phislice)]->RegisterYourself(); 352 } 353 ++etaslice; 354 } 355 nEtaBins = etaslice; 356 for(int i = 0; i < nEtaBins - 1; ++i) 357 { // loop on the eta slices 358 vertices[8] = -dx[i]; 359 vertices[9] = y[i]; 360 vertices[10] = -dx[i]; 361 vertices[11] = y[i + 1]; 362 vertices[12] = dx[i]; 363 vertices[13] = y[i + 1]; 364 vertices[14] = dx[i]; 365 vertices[15] = y[i]; 366 new TGeoArb8(Form("%s_tower%d", name, i), R / 2., vertices); // tower in the proper eta slice, at phi=0 367 // intersection between the tower and the calo_barrel 368 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)); 369 TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d", name, i), finaltower_cs, calomed_); 370 finaltower->SetLineColor(kRed); 371 for(int j = 0; j < nphi[i]; ++j) 372 { // loop on the phi slices 373 calo_barrel->AddNode(finaltower, j, phirotations[make_pair(i, j)]); 374 } 375 } 376 delete[] y; 377 delete[] dx; 378 delete[] nphi; 379 //the towers in the forward region 380 R = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size(); // Z of the muons system = height of the pyramid 381 nEtaBins = caloBinning.size(); 382 // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place) 383 TGeoTranslation *towerdz = new TGeoTranslation(Form("%s_towerdz", name), 0., 0., R / 2. - (innerBarrelLength + calo_endcap_coneThickness / 2.)); 384 towerdz->RegisterYourself(); 385 // eta bins... we build one pyramid per eta slice and then translate it nphi times. 386 Double_t *r = new Double_t[nEtaBins]; 387 nphi = new Int_t[nEtaBins]; 388 etaslice = 0; 389 phirotations.clear(); 390 for(set<pair<Double_t, Int_t>>::const_iterator bin = caloBinning.begin(); bin != caloBinning.end(); ++bin) 391 { 392 if(bin->first < calo_endcap_etamin) continue; // only in the + endcap 393 r[etaslice] = R * 2 * exp(-bin->first) / (1 - exp(-2 * bin->first)); 394 nphi[etaslice] = bin->second; 395 Double_t phiRotationAngle = 360. / nphi[etaslice]; 396 for(int phislice = 0; phislice < nphi[etaslice]; ++phislice) 397 { 398 phirotations[make_pair(etaslice, phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d", name, etaslice, phislice), phiRotationAngle * phislice, 0., 0.); 399 phirotations[make_pair(etaslice, phislice)]->RegisterYourself(); 400 } 401 ++etaslice; 402 } 403 nEtaBins = etaslice; 404 for(int i = 0; i < nEtaBins - 1; ++i) 405 { // loop on the eta slices 406 vertices[8] = -r[i + 1] * sin(TMath::Pi() / nphi[i]); 407 vertices[9] = r[i + 1] * cos(TMath::Pi() / nphi[i]); 408 vertices[10] = -r[i] * sin(TMath::Pi() / nphi[i]); 409 vertices[11] = r[i] * cos(TMath::Pi() / nphi[i]); 410 vertices[12] = r[i] * sin(TMath::Pi() / nphi[i]); 411 vertices[13] = r[i] * cos(TMath::Pi() / nphi[i]); 412 vertices[14] = r[i + 1] * sin(TMath::Pi() / nphi[i]); 413 vertices[15] = r[i + 1] * cos(TMath::Pi() / nphi[i]); 414 new TGeoArb8(Form("%sfwdtower%d", name, i), R / 2., vertices); // tower in the proper eta slice, at phi=0 415 // intersection between the tower and the calo_endcap 416 TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs", name, i), Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs", name, i, name, name)); 417 TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d", name, i), finalfwdtower_cs, calomed_); 418 finalfwdtower->SetLineColor(kViolet); 419 for(int j = 0; j < nphi[i]; ++j) 420 { // loop on the phi slices 421 calo_endcap->AddNode(finalfwdtower, j, phirotations[make_pair(i, j)]); 422 } 423 } 424 delete[] r; 425 delete[] nphi; 426 } -
display/Delphes3DGeometry.h
r45e58be r341014c 20 20 #define Delphes3DGeometry_h 21 21 22 #include <map> 22 23 #include <set> 23 #include <map>24 24 #include <vector> 25 25 … … 33 33 // TODO: asymmetric detector 34 34 35 class Delphes3DGeometry { 36 public: 37 Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false); 38 ~Delphes3DGeometry() {} 35 class Delphes3DGeometry 36 { 37 public: 38 Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false); 39 ~Delphes3DGeometry() {} 39 40 40 void readFile(const char *filename, const char *ParticlePropagator="ParticlePropagator",41 const char *TrackingEfficiency="ChargedHadronTrackingEfficiency",42 const char *MuonEfficiency="MuonEfficiency",43 const char *Calorimeters="Calorimeter");41 void readFile(const char *filename, const char *ParticlePropagator = "ParticlePropagator", 42 const char *TrackingEfficiency = "ChargedHadronTrackingEfficiency", 43 const char *MuonEfficiency = "MuonEfficiency", 44 const char *Calorimeters = "Calorimeter"); 44 45 45 46 47 48 46 void setContingency(Double_t contingency) { contingency_ = contingency; } 47 void setCaloBarrelThickness(Double_t thickness) { calo_barrel_thickness_ = thickness; } 48 void setCaloEndcapThickness(Double_t thickness) { calo_endcap_thickness_ = thickness; } 49 void setMuonSystemThickness(Double_t thickness) { muonSystem_thickn_ = thickness; } 49 50 50 51 TGeoVolume *getDetector(bool withTowers = true); 51 52 52 53 54 55 56 57 std::pair<TAxis*, TAxis*> getCaloAxes() { return std::make_pair(etaAxis_,phiAxis_); }53 Double_t getTrackerRadius() const { return tk_radius_; } 54 Double_t getDetectorRadius() const { return muonSystem_radius_; } 55 Double_t getTrackerHalfLength() const { return tk_length_; } 56 Double_t getDetectorHalfLength() const { return muonSystem_length_; } 57 Double_t getBField() const { return tk_Bz_; } 58 std::pair<TAxis *, TAxis *> getCaloAxes() { return std::make_pair(etaAxis_, phiAxis_); } 58 59 59 60 61 std::pair<Double_t, Double_t> addCalorimeter(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set< std::pair<Double_t, Int_t> >&caloBinning);62 63 void addCaloTowers(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set< std::pair<Double_t, Int_t> >&caloBinning);60 private: 61 std::pair<Double_t, Double_t> addTracker(TGeoVolume *top); 62 std::pair<Double_t, Double_t> addCalorimeter(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set<std::pair<Double_t, Int_t>> &caloBinning); 63 std::pair<Double_t, Double_t> addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength); 64 void addCaloTowers(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set<std::pair<Double_t, Int_t>> &caloBinning); 64 65 65 private: 66 private: 67 TGeoManager *geom_; 66 68 67 TGeoManager *geom_; 69 TGeoMedium *vacuum_; 70 TGeoMedium *tkmed_; 71 TGeoMedium *calomed_; 72 TGeoMedium *mudetmed_; 68 73 69 TGeoMedium *vacuum_; 70 TGeoMedium *tkmed_; 71 TGeoMedium *calomed_; 72 TGeoMedium *mudetmed_; 74 TAxis *etaAxis_; 75 TAxis *phiAxis_; 73 76 74 TAxis *etaAxis_; 75 TAxis *phiAxis_; 77 Double_t contingency_; 78 Double_t calo_barrel_thickness_; 79 Double_t calo_endcap_thickness_; 80 Double_t muonSystem_thickn_; 81 Double_t muonSystem_radius_; 82 Double_t muonSystem_length_; 83 Double_t tk_radius_; 84 Double_t tk_length_; 85 Double_t tk_etamax_; 86 Double_t tk_Bz_; 76 87 77 Double_t contingency_; 78 Double_t calo_barrel_thickness_; 79 Double_t calo_endcap_thickness_; 80 Double_t muonSystem_thickn_; 81 Double_t muonSystem_radius_; 82 Double_t muonSystem_length_; 83 Double_t tk_radius_; 84 Double_t tk_length_; 85 Double_t tk_etamax_; 86 Double_t tk_Bz_; 88 std::vector<std::string> calorimeters_; 89 std::vector<std::string> muondets_; 87 90 88 std::vector<std::string> calorimeters_; 89 std::vector<std::string> muondets_; 90 91 std::map<std::string, Double_t> muonSystem_etamax_; 92 std::map<std::string, std::set< std::pair<Double_t, Int_t> > > caloBinning_; 93 91 std::map<std::string, Double_t> muonSystem_etamax_; 92 std::map<std::string, std::set<std::pair<Double_t, Int_t>>> caloBinning_; 94 93 }; 95 94 -
display/DelphesBranchElement.cc
r45e58be r341014c 18 18 19 19 #include "display/DelphesBranchElement.h" 20 #include " classes/DelphesClasses.h"20 #include "TEveArrow.h" 21 21 #include "TEveJetCone.h" 22 22 #include "TEveTrack.h" 23 23 #include "TEveTrackPropagator.h" 24 #include "TEveArrow.h"25 24 #include "TEveVector.h" 25 #include "classes/DelphesClasses.h" 26 26 #include <iostream> 27 27 28 28 // special case for calo towers 29 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) { 30 data_ = new DelphesCaloData(2); 31 data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed); 32 data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue); 33 data_->IncDenyDestroy(); 34 } 35 template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); } 36 template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() { 37 if(TString(GetType())=="Tower") { 29 template <> 30 DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) : 31 DelphesBranchBase(name, branch, color, maxPt) 32 { 33 data_ = new DelphesCaloData(2); 34 data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed); 35 data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue); 36 data_->IncDenyDestroy(); 37 } 38 template <> 39 void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); } 40 template <> 41 void DelphesBranchElement<DelphesCaloData>::ReadBranch() 42 { 43 if(TString(GetType()) == "Tower") 44 { 38 45 // Loop over all towers 39 46 TIter itTower(branch_); 40 47 Tower *tower; 41 while((tower = (Tower *) itTower.Next())) { 48 while((tower = (Tower *)itTower.Next())) 49 { 42 50 data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]); 43 51 data_->FillSlice(0, tower->Eem); … … 47 55 } 48 56 } 49 template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() { 57 template <> 58 std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() 59 { 50 60 std::vector<TLorentzVector> output; 51 if(TString(GetType())=="Tower") { 61 if(TString(GetType()) == "Tower") 62 { 52 63 TIter itTower(branch_); 53 64 Tower *tower; 54 while((tower = (Tower *) itTower.Next())) { 65 while((tower = (Tower *)itTower.Next())) 66 { 55 67 TLorentzVector v; 56 v.SetPtEtaPhiM(tower->Eem +tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.);68 v.SetPtEtaPhiM(tower->Eem + tower->Ehad, (tower->Edges[0] + tower->Edges[1]) / 2., (tower->Edges[2] + tower->Edges[3]) / 2., 0.); 57 69 output.push_back(v); 58 70 } … … 62 74 63 75 // special case for element lists 64 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) { 65 data_ = new TEveElementList(name); 66 data_->SetMainColor(color_); 67 } 68 template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); } 69 template<> void DelphesBranchElement<TEveElementList>::ReadBranch() { 70 if(TString(GetType())=="Jet") { 76 template <> 77 DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) : 78 DelphesBranchBase(name, branch, color, maxPt) 79 { 80 data_ = new TEveElementList(name); 81 data_->SetMainColor(color_); 82 } 83 template <> 84 void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); } 85 template <> 86 void DelphesBranchElement<TEveElementList>::ReadBranch() 87 { 88 if(TString(GetType()) == "Jet") 89 { 71 90 TIter itJet(branch_); 72 91 Jet *jet; … … 74 93 // Loop over all jets 75 94 Int_t counter = 0; 76 while((jet = (Jet *) itJet.Next())) { 95 while((jet = (Jet *)itJet.Next())) 96 { 77 97 eveJetCone = new TEveJetCone(); 78 eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));98 eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter, jet->PT, jet->Eta, jet->Phi, jet->Mass)); 79 99 eveJetCone->SetName(Form("jet [%d]", counter++)); 80 100 eveJetCone->SetMainTransparency(60); … … 86 106 data_->AddElement(eveJetCone); 87 107 } 88 } else if(TString(GetType())=="MissingET") { 108 } 109 else if(TString(GetType()) == "MissingET") 110 { 89 111 // MissingET as invisible track (like a photon) 90 112 MissingET *MET; … … 94 116 trkProp->SetMaxR(tkRadius_); 95 117 trkProp->SetMaxZ(tkHalfLength_); 96 if(branch_->GetEntriesFast() > 0) { 97 MET = (MissingET*) branch_->At(0); 118 if(branch_->GetEntriesFast() > 0) 119 { 120 MET = (MissingET *)branch_->At(0); 98 121 TParticle pb(13, 1, 0, 0, 0, 0, 99 (tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi),100 (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi),101 122 (tkRadius_ * MET->MET / maxPt_) * cos(MET->Phi), 123 (tkRadius_ * MET->MET / maxPt_) * sin(MET->Phi), 124 0., MET->MET, 0.0, 0.0, 0.0, 0.0); 102 125 eveMet = new TEveTrack(&pb, 0, trkProp); 103 126 eveMet->SetName("Missing Et"); … … 115 138 } 116 139 } 117 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() { 140 template <> 141 std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() 142 { 118 143 std::vector<TLorentzVector> output; 119 if(TString(GetType())=="Jet") { 144 if(TString(GetType()) == "Jet") 145 { 120 146 TIter itJet(branch_); 121 147 Jet *jet; 122 148 // Loop over all jets 123 while((jet = (Jet *) itJet.Next())) { 149 while((jet = (Jet *)itJet.Next())) 150 { 124 151 TLorentzVector v; 125 152 v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass); 126 153 output.push_back(v); 127 154 } 128 } else if(TString(GetType())=="MissingET") { 155 } 156 else if(TString(GetType()) == "MissingET") 157 { 129 158 TIter itMet(branch_); 130 159 MissingET *MET; 131 160 // Missing Et 132 while((MET = (MissingET*) itMet.Next())) { 161 while((MET = (MissingET *)itMet.Next())) 162 { 133 163 TLorentzVector v; 134 v.SetPtEtaPhiM(MET->MET, MET->Eta,MET->Phi,0.);164 v.SetPtEtaPhiM(MET->MET, MET->Eta, MET->Phi, 0.); 135 165 output.push_back(v); 136 166 } … … 140 170 141 171 // special case for track lists 142 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) { 172 template <> 173 DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) : 174 DelphesBranchBase(name, branch, color, maxPt) 175 { 143 176 data_ = new TEveTrackList(name); 144 177 data_->SetMainColor(color_); … … 147 180 data_->SetMarkerSize(0.5); 148 181 } 149 template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) { 150 tkRadius_ = r; 182 template <> 183 void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) 184 { 185 tkRadius_ = r; 151 186 tkHalfLength_ = l; 152 187 tk_Bz_ = Bz; … … 156 191 trkProp->SetMaxZ(tkHalfLength_); 157 192 } 158 template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); } 159 template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() { 193 template <> 194 void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); } 195 template <> 196 void DelphesBranchElement<TEveTrackList>::ReadBranch() 197 { 160 198 TString type = GetType(); 161 199 TIter itTrack(branch_); … … 167 205 trkProp->SetMaxZ(tkHalfLength_); 168 206 GenParticle *particle; 169 if(type=="Track") { // CASE 1: TRACKS 207 if(type == "Track") 208 { // CASE 1: TRACKS 170 209 Track *track; 171 while((track = (Track *) itTrack.Next())) { 210 while((track = (Track *)itTrack.Next())) 211 { 172 212 TParticle pb(track->PID, 1, 0, 0, 0, 0, 173 track->P4().Px(), track->P4().Py(), 174 track->P4().Pz(), track->P4().E(), 175 track->X/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0); 176 eveTrack = new TEveTrack(&pb, counter, trkProp); 177 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 178 eveTrack->SetStdTitle(); 179 eveTrack->SetAttLineAttMarker(data_); 180 data_->AddElement(eveTrack); 181 eveTrack->SetLineColor(GetColor()); 182 eveTrack->MakeTrack(); 183 } 184 } else if(type=="Electron") { // CASE 2: ELECTRONS 213 track->P4().Px(), track->P4().Py(), 214 track->P4().Pz(), track->P4().E(), 215 track->X / 10.0, track->Y / 10.0, track->Z / 10.0, track->T / 10.0); 216 eveTrack = new TEveTrack(&pb, counter, trkProp); 217 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 218 eveTrack->SetStdTitle(); 219 eveTrack->SetAttLineAttMarker(data_); 220 data_->AddElement(eveTrack); 221 eveTrack->SetLineColor(GetColor()); 222 eveTrack->MakeTrack(); 223 } 224 } 225 else if(type == "Electron") 226 { // CASE 2: ELECTRONS 185 227 Electron *electron; 186 while((electron = (Electron *) itTrack.Next())) { 187 particle = (GenParticle*) electron->Particle.GetObject(); 188 TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0, 189 electron->P4().Px(), electron->P4().Py(), 190 electron->P4().Pz(), electron->P4().E(), 191 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0); 192 eveTrack = new TEveTrack(&pb, counter, trkProp); 193 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 194 eveTrack->SetStdTitle(); 195 eveTrack->SetAttLineAttMarker(data_); 196 data_->AddElement(eveTrack); 197 eveTrack->SetLineColor(GetColor()); 198 eveTrack->MakeTrack(); 199 } 200 } else if(type=="Muon") { // CASE 3: MUONS 228 while((electron = (Electron *)itTrack.Next())) 229 { 230 particle = (GenParticle *)electron->Particle.GetObject(); 231 TParticle pb(electron->Charge < 0 ? 11 : -11, 1, 0, 0, 0, 0, 232 electron->P4().Px(), electron->P4().Py(), 233 electron->P4().Pz(), electron->P4().E(), 234 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0); 235 eveTrack = new TEveTrack(&pb, counter, trkProp); 236 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 237 eveTrack->SetStdTitle(); 238 eveTrack->SetAttLineAttMarker(data_); 239 data_->AddElement(eveTrack); 240 eveTrack->SetLineColor(GetColor()); 241 eveTrack->MakeTrack(); 242 } 243 } 244 else if(type == "Muon") 245 { // CASE 3: MUONS 201 246 Muon *muon; 202 while((muon = (Muon *) itTrack.Next())) { 203 particle = (GenParticle*) muon->Particle.GetObject(); 204 TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0, 205 muon->P4().Px(), muon->P4().Py(), 206 muon->P4().Pz(), muon->P4().E(), 207 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0); 208 eveTrack = new TEveTrack(&pb, counter, trkProp); 209 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 210 eveTrack->SetStdTitle(); 211 eveTrack->SetAttLineAttMarker(data_); 212 data_->AddElement(eveTrack); 213 eveTrack->SetLineColor(GetColor()); 214 eveTrack->MakeTrack(); 215 } 216 } else if(type=="Photon") { // CASE 4: PHOTONS 247 while((muon = (Muon *)itTrack.Next())) 248 { 249 particle = (GenParticle *)muon->Particle.GetObject(); 250 TParticle pb(muon->Charge < 0 ? 13 : -13, 1, 0, 0, 0, 0, 251 muon->P4().Px(), muon->P4().Py(), 252 muon->P4().Pz(), muon->P4().E(), 253 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0); 254 eveTrack = new TEveTrack(&pb, counter, trkProp); 255 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 256 eveTrack->SetStdTitle(); 257 eveTrack->SetAttLineAttMarker(data_); 258 data_->AddElement(eveTrack); 259 eveTrack->SetLineColor(GetColor()); 260 eveTrack->MakeTrack(); 261 } 262 } 263 else if(type == "Photon") 264 { // CASE 4: PHOTONS 217 265 Photon *photon; 218 while((photon = (Photon *) itTrack.Next())) { 266 while((photon = (Photon *)itTrack.Next())) 267 { 219 268 TParticle pb(22, 1, 0, 0, 0, 0, 220 221 222 269 photon->P4().Px(), photon->P4().Py(), 270 photon->P4().Pz(), photon->P4().E(), 271 0.0, 0.0, 0.0, 0.0); 223 272 eveTrack = new TEveTrack(&pb, counter, trkProp); 224 273 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); … … 230 279 eveTrack->MakeTrack(); 231 280 } 232 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES 281 } 282 else if(type == "GenParticle") 283 { // CASE 5: GENPARTICLES 233 284 GenParticle *particle; 234 while((particle = (GenParticle *) itTrack.Next())) { 285 while((particle = (GenParticle *)itTrack.Next())) 286 { 235 287 if(particle->Status != 1) continue; 236 288 TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2, 237 particle->P4().Px(), particle->P4().Py(), 238 particle->P4().Pz(), particle->P4().E(), 239 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0); 240 eveTrack = new TEveTrack(&pb, counter, trkProp); 241 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 242 eveTrack->SetStdTitle(); 243 eveTrack->SetAttLineAttMarker(data_); 244 data_->AddElement(eveTrack); 245 eveTrack->SetLineColor(GetColor()); 246 if(particle->Charge==0) eveTrack->SetLineStyle(7); 247 eveTrack->MakeTrack(); 248 } 249 } 250 } 251 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() { 289 particle->P4().Px(), particle->P4().Py(), 290 particle->P4().Pz(), particle->P4().E(), 291 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0); 292 eveTrack = new TEveTrack(&pb, counter, trkProp); 293 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 294 eveTrack->SetStdTitle(); 295 eveTrack->SetAttLineAttMarker(data_); 296 data_->AddElement(eveTrack); 297 eveTrack->SetLineColor(GetColor()); 298 if(particle->Charge == 0) eveTrack->SetLineStyle(7); 299 eveTrack->MakeTrack(); 300 } 301 } 302 } 303 template <> 304 std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() 305 { 252 306 std::vector<TLorentzVector> output; 253 307 TString type = GetType(); 254 308 TIter itTrack(branch_); 255 if(type=="Track") { // CASE 1: TRACKS 309 if(type == "Track") 310 { // CASE 1: TRACKS 256 311 Track *track; 257 while((track = (Track *) itTrack.Next())) { 312 while((track = (Track *)itTrack.Next())) 313 { 258 314 output.push_back(track->P4()); 259 315 } 260 } else if(type=="Electron") { // CASE 2: ELECTRONS 316 } 317 else if(type == "Electron") 318 { // CASE 2: ELECTRONS 261 319 Electron *electron; 262 while((electron = (Electron *) itTrack.Next())) { 320 while((electron = (Electron *)itTrack.Next())) 321 { 263 322 output.push_back(electron->P4()); 264 323 } 265 } else if(type=="Muon") { // CASE 3: MUONS 324 } 325 else if(type == "Muon") 326 { // CASE 3: MUONS 266 327 Muon *muon; 267 while((muon = (Muon *) itTrack.Next())) { 328 while((muon = (Muon *)itTrack.Next())) 329 { 268 330 output.push_back(muon->P4()); 269 331 } 270 } else if(type=="Photon") { // CASE 4: PHOTONS 332 } 333 else if(type == "Photon") 334 { // CASE 4: PHOTONS 271 335 Photon *photon; 272 while((photon = (Photon *) itTrack.Next())) { 336 while((photon = (Photon *)itTrack.Next())) 337 { 273 338 output.push_back(photon->P4()); 274 339 } 275 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES 340 } 341 else if(type == "GenParticle") 342 { // CASE 5: GENPARTICLES 276 343 GenParticle *particle; 277 while((particle = (GenParticle *) itTrack.Next())) { 344 while((particle = (GenParticle *)itTrack.Next())) 345 { 278 346 if(particle->Status != 1) continue; 279 347 output.push_back(particle->P4()); 280 348 } 281 349 } -
display/DelphesBranchElement.h
r45e58be r341014c 20 20 #define DelphesBranchElement_h 21 21 22 #include "TClass.h" 23 #include "TClonesArray.h" 22 24 #include "TColor.h" 25 #include "TEveElement.h" 26 #include "TEveTrack.h" 23 27 #include "TString.h" 24 #include "TClonesArray.h" 25 #include "TClass.h" 28 #include "display/DelphesCaloData.h" 26 29 #include <exception> 27 30 #include <iostream> 28 #include "display/DelphesCaloData.h"29 #include "TEveElement.h"30 #include "TEveTrack.h"31 31 32 32 // virtual class to represent objects from a Delphes-tree branch 33 33 class DelphesBranchBase 34 34 { 35 public: 36 DelphesBranchBase(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):name_(name),maxPt_(maxPt),branch_(branch),color_(color) {} 37 virtual ~DelphesBranchBase() {} 38 const char* GetName() const { return (const char*)name_; } 39 const char* GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; } 40 virtual const char* GetClassName() = 0; 41 enum EColor GetColor() const { return color_; } 42 virtual void Reset() = 0; 43 virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; } 44 virtual void ReadBranch() = 0; 45 virtual std::vector<TLorentzVector> GetVectors() = 0; 35 public: 36 DelphesBranchBase(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) : 37 name_(name), maxPt_(maxPt), branch_(branch), color_(color) {} 38 virtual ~DelphesBranchBase() {} 39 const char *GetName() const { return (const char *)name_; } 40 const char *GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; } 41 virtual const char *GetClassName() = 0; 42 enum EColor GetColor() const { return color_; } 43 virtual void Reset() = 0; 44 virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.) 45 { 46 tkRadius_ = r; 47 tkHalfLength_ = l; 48 tk_Bz_ = Bz; 49 } 50 virtual void ReadBranch() = 0; 51 virtual std::vector<TLorentzVector> GetVectors() = 0; 46 52 47 48 49 50 TClonesArray*branch_;51 52 Float_t tkRadius_,tkHalfLength_, tk_Bz_;53 protected: 54 TString name_; 55 Float_t maxPt_; 56 TClonesArray *branch_; 57 const enum EColor color_; 58 Float_t tkRadius_, tkHalfLength_, tk_Bz_; 53 59 }; 54 60 55 61 // concrete implementations. EveContainer can be a TrackList, ElementList or CaloData. 56 template<typename EveContainer> class DelphesBranchElement: public DelphesBranchBase 62 template <typename EveContainer> 63 class DelphesBranchElement: public DelphesBranchBase 57 64 { 58 public: 59 // constructor 60 DelphesBranchElement(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):DelphesBranchBase(name, branch, color, maxPt) { 61 throw std::exception(); 62 } 65 public: 66 // constructor 67 DelphesBranchElement(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) : 68 DelphesBranchBase(name, branch, color, maxPt) 69 { 70 throw std::exception(); 71 } 63 72 64 65 73 // destructor 74 virtual ~DelphesBranchElement() { delete data_; } 66 75 67 68 EveContainer*GetContainer() { return data_; }76 // get the container (ElementList, TrackList, or CaloData) 77 EveContainer *GetContainer() { return data_; } 69 78 70 // tracking volume 71 virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; } 79 // tracking volume 80 virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.) 81 { 82 tkRadius_ = r; 83 tkHalfLength_ = l; 84 tk_Bz_ = Bz; 85 } 72 86 73 74 virtual void Reset(){};87 // resets the collection (before moving to the next event) 88 virtual void Reset(){}; 75 89 76 77 virtual const char*GetClassName() { return data_->ClassName(); }90 // template class name 91 virtual const char *GetClassName() { return data_->ClassName(); } 78 92 79 80 93 // read the branch and fill elements for display 94 virtual void ReadBranch() {} 81 95 82 // return the vector for all elements 83 virtual std::vector<TLorentzVector> GetVectors() { std::vector<TLorentzVector> v; return v; } 96 // return the vector for all elements 97 virtual std::vector<TLorentzVector> GetVectors() 98 { 99 std::vector<TLorentzVector> v; 100 return v; 101 } 84 102 85 86 EveContainer*data_;103 private: 104 EveContainer *data_; 87 105 }; 88 106 … … 90 108 91 109 // special case for calo towers 92 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt); 93 template<> void DelphesBranchElement<DelphesCaloData>::Reset(); 94 template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch(); 95 template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors(); 110 template <> 111 DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt); 112 template <> 113 void DelphesBranchElement<DelphesCaloData>::Reset(); 114 template <> 115 void DelphesBranchElement<DelphesCaloData>::ReadBranch(); 116 template <> 117 std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors(); 96 118 97 119 // special case for element lists 98 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt); 99 template<> void DelphesBranchElement<TEveElementList>::Reset(); 100 template<> void DelphesBranchElement<TEveElementList>::ReadBranch(); 101 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors(); 120 template <> 121 DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt); 122 template <> 123 void DelphesBranchElement<TEveElementList>::Reset(); 124 template <> 125 void DelphesBranchElement<TEveElementList>::ReadBranch(); 126 template <> 127 std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors(); 102 128 103 129 // special case for track lists 104 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt); 105 template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz); 106 template<> void DelphesBranchElement<TEveTrackList>::Reset(); 107 template<> void DelphesBranchElement<TEveTrackList>::ReadBranch(); 108 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors(); 130 template <> 131 DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt); 132 template <> 133 void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz); 134 template <> 135 void DelphesBranchElement<TEveTrackList>::Reset(); 136 template <> 137 void DelphesBranchElement<TEveTrackList>::ReadBranch(); 138 template <> 139 std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors(); 109 140 110 141 #endif // CINT, CLING -
display/DelphesCaloData.cc
r45e58be r341014c 16 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 19 18 20 19 #include "display/DelphesCaloData.h" … … 37 36 void DelphesCaloData::ClearTowers() 38 37 { 39 38 fGeomVec.clear(); 40 39 } 41 40 -
display/DelphesCaloData.h
r45e58be r341014c 22 22 #include "TEveCaloData.h" 23 23 24 class DelphesCaloData: public TEveCaloDataVec 24 class DelphesCaloData: public TEveCaloDataVec 25 25 { 26 26 public: 27 28 27 DelphesCaloData(Int_t nslices); 29 28 … … 36 35 37 36 #endif /* DelphesCaloData_h */ 38 -
display/DelphesDisplay.cc
r45e58be r341014c 17 17 */ 18 18 19 19 #include "TEveBrowser.h" 20 20 #include "TEveManager.h" 21 #include "TEveProjectionAxes.h" 22 #include "TEveProjectionManager.h" 23 #include "TEveScene.h" 21 24 #include "TEveViewer.h" 25 #include "TEveWindow.h" 22 26 #include "TGLViewer.h" 23 27 #include "TGLWidget.h" 24 #include "TEveScene.h"25 #include "TEveProjectionManager.h"26 #include "TEveProjectionAxes.h"27 #include "TEveBrowser.h"28 #include "TEveWindow.h"29 28 #include "TGTab.h" 30 29 31 30 #include "TEveCalo2DGL.h" 32 #include "TEveCalo3DGL.h" 31 #include "TEveCalo3DGL.h" 33 32 #include "TEveCaloLegoGL.h" 34 33 #include "TEveCaloLegoOverlay.h" … … 48 47 fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ); 49 48 50 51 49 fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry"); 50 fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry"); 52 51 53 54 55 52 fRPhiCaloScene = gEve->SpawnNewScene("RPhi Calorimeter"); 53 fRhoZCaloScene = gEve->SpawnNewScene("RhoZ Calorimeter"); 54 fLegoCaloScene = gEve->SpawnNewScene("Lego Calorimeter"); 56 55 57 58 59 56 fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data"); 57 fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data"); 58 60 59 axes = new TEveProjectionAxes(fRPhiMgr); 61 60 fRPhiGeomScene->AddElement(axes); … … 85 84 f3DimView->AddScene(gEve->GetGlobalScene()); 86 85 f3DimView->AddScene(gEve->GetEventScene()); 87 86 88 87 pack1->NewSlot()->MakeCurrent(); 89 88 fLegoView = gEve->SpawnNewViewer("Lego View", ""); 90 89 fLegoView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY); 91 90 fLegoView->AddScene(fLegoCaloScene); 92 91 93 92 pack0->NewSlot()->MakeCurrent(); 94 93 fRPhiView = gEve->SpawnNewViewer("RPhi View", ""); … … 97 96 fRPhiView->AddScene(fRPhiCaloScene); 98 97 fRPhiView->AddScene(fRPhiEventScene); 99 98 100 99 pack0->NewSlot()->MakeCurrent(); 101 100 fRhoZView = gEve->SpawnNewViewer("RhoZ View", ""); … … 114 113 //------------------------------------------------------------------------------ 115 114 116 void DelphesDisplay::ImportGeomRPhi(TEveElement *el)117 { 115 void DelphesDisplay::ImportGeomRPhi(TEveElement *el) 116 { 118 117 fRPhiMgr->ImportElements(el, fRPhiGeomScene); 119 118 } 120 119 121 void DelphesDisplay::ImportGeomRhoZ(TEveElement *el)122 { 120 void DelphesDisplay::ImportGeomRhoZ(TEveElement *el) 121 { 123 122 fRhoZMgr->ImportElements(el, fRhoZGeomScene); 124 123 } … … 137 136 { 138 137 TEveCaloLegoOverlay *overlay = new TEveCaloLegoOverlay(); 139 138 140 139 overlay->SetCaloLego(calo); 141 140 fLegoView->GetGLViewer()->AddOverlayElement(overlay); … … 144 143 } 145 144 146 void DelphesDisplay::ImportEventRPhi(TEveElement *el)147 { 145 void DelphesDisplay::ImportEventRPhi(TEveElement *el) 146 { 148 147 fRPhiMgr->ImportElements(el, fRPhiEventScene); 149 148 } 150 149 151 void DelphesDisplay::ImportEventRhoZ(TEveElement *el)152 { 150 void DelphesDisplay::ImportEventRhoZ(TEveElement *el) 151 { 153 152 fRhoZMgr->ImportElements(el, fRhoZEventScene); 154 153 } … … 166 165 } 167 166 //------------------------------------------------------------------------------ 168 -
display/DelphesDisplay.h
r45e58be r341014c 30 30 { 31 31 public: 32 33 32 DelphesDisplay(); 34 33 35 34 virtual ~DelphesDisplay(); 36 35 37 void ImportGeomRPhi(TEveElement *el);38 void ImportGeomRhoZ(TEveElement *el);36 void ImportGeomRPhi(TEveElement *el); 37 void ImportGeomRhoZ(TEveElement *el); 39 38 40 39 void ImportCaloRPhi(TEveCalo3D *calo); … … 42 41 void ImportCaloLego(TEveCaloLego *calo); 43 42 44 void ImportEventRPhi(TEveElement *el);45 void ImportEventRhoZ(TEveElement *el);43 void ImportEventRPhi(TEveElement *el); 44 void ImportEventRhoZ(TEveElement *el); 46 45 47 46 void DestroyEventRPhi(); … … 49 48 50 49 private: 51 52 50 TEveProjectionManager *fRPhiMgr; 53 51 TEveProjectionManager *fRhoZMgr; … … 70 68 71 69 #endif /* DelphesDisplay_h */ 72 -
display/DelphesEventDisplay.cc
r45e58be r341014c 17 17 */ 18 18 19 #include <algorithm> 19 20 #include <cassert> 20 21 #include <iostream> 21 22 #include <utility> 22 #include <algorithm> 23 23 24 #include "TAxis.h" 25 #include "TCanvas.h" 26 #include "TChain.h" 27 #include "TClonesArray.h" 28 #include "TEveArrow.h" 29 #include "TEveBrowser.h" 30 #include "TEveCalo.h" 31 #include "TEveElement.h" 32 #include "TEveEventManager.h" 33 #include "TEveGeoNode.h" 34 #include "TEveJetCone.h" 35 #include "TEveManager.h" 36 #include "TEveTrack.h" 37 #include "TEveTrackPropagator.h" 38 #include "TEveTrans.h" 39 #include "TEveViewer.h" 40 #include "TGButton.h" 41 #include "TGHtml.h" 42 #include "TGNumberEntry.h" 43 #include "TGProgressBar.h" 44 #include "TGStatusBar.h" 45 #include "TGTextEntry.h" 24 46 #include "TGeoManager.h" 25 47 #include "TGeoVolume.h" 26 #include "TEveElement.h" 27 #include "TEveJetCone.h" 28 #include "TEveTrack.h" 29 #include "TEveTrackPropagator.h" 30 #include "TEveCalo.h" 31 #include "TEveManager.h" 32 #include "TEveGeoNode.h" 33 #include "TEveTrans.h" 34 #include "TEveViewer.h" 35 #include "TEveBrowser.h" 36 #include "TEveArrow.h" 48 #include "TH1F.h" 37 49 #include "TMath.h" 50 #include "TRootBrowser.h" 51 #include "TRootEmbeddedCanvas.h" 38 52 #include "TSystem.h" 39 #include "TRootBrowser.h" 40 #include "TGButton.h" 41 #include "TGTextEntry.h" 42 #include "TGProgressBar.h" 43 #include "TGNumberEntry.h" 44 #include "TRootEmbeddedCanvas.h" 45 #include "TClonesArray.h" 46 #include "TEveEventManager.h" 47 #include "TCanvas.h" 48 #include "TH1F.h" 49 #include "TAxis.h" 50 #include "TChain.h" 51 #include "TGHtml.h" 52 #include "TGStatusBar.h" 53 53 54 #include "display/Delphes3DGeometry.h" 55 #include "display/DelphesBranchElement.h" 54 56 #include "display/DelphesCaloData.h" 55 #include "display/DelphesBranchElement.h" 56 #include "display/Delphes3DGeometry.h" 57 #include "display/DelphesDisplay.h" 57 58 #include "display/DelphesEventDisplay.h" 58 #include "display/DelphesDisplay.h"59 #include "display/Delphes3DGeometry.h"60 59 #include "display/DelphesHtmlSummary.h" 61 60 #include "display/DelphesPlotSummary.h" … … 67 66 DelphesEventDisplay::DelphesEventDisplay() 68 67 { 69 70 71 72 73 74 75 76 77 78 79 68 event_id_ = 0; 69 tkRadius_ = 1.29; 70 totRadius_ = 2.0; 71 tkHalfLength_ = 3.0; 72 muHalfLength_ = 6.0; 73 bz_ = 3.8; 74 chain_ = new TChain("Delphes"); 75 treeReader_ = 0; 76 delphesDisplay_ = 0; 77 etaAxis_ = 0; 78 phiAxis_ = 0; 80 79 } 81 80 82 81 DelphesEventDisplay::~DelphesEventDisplay() 83 82 { 84 83 delete chain_; 85 84 } 86 85 87 86 void DelphesEventDisplay::EventChanged(Int_t e) 88 87 { 89 if( e!= event_id_ ) { 88 if(e != event_id_) 89 { 90 90 event_id_ = e; 91 Emit("EventChanged(Int_t)", e);91 Emit("EventChanged(Int_t)", e); 92 92 load_event(); 93 93 } 94 94 } 95 95 96 97 DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D) 98 { 99 event_id_ = 0; 100 tkRadius_ = 1.29; 101 totRadius_ = 2.0; 102 tkHalfLength_ = 3.0; 103 bz_ = 3.8; 104 chain_ = new TChain("Delphes"); 105 treeReader_ = 0; 106 delphesDisplay_ = 0; 107 108 // initialize the application 109 TEveManager::Create(kTRUE, "IV"); 110 fStatusBar_ = gEve->GetBrowser()->GetStatusBar(); 111 TGeoManager *geom = gGeoManager; 112 113 // build the detector 114 tkRadius_ = det3D.getTrackerRadius(); 115 totRadius_ = det3D.getDetectorRadius(); 116 tkHalfLength_ = det3D.getTrackerHalfLength(); 117 muHalfLength_ = det3D.getDetectorHalfLength(); 118 bz_ = det3D.getBField(); 119 etaAxis_ = det3D.getCaloAxes().first; 120 phiAxis_ = det3D.getCaloAxes().second; 121 TGeoVolume *top = det3D.getDetector(false); 122 geom->SetTopVolume(top); 123 TEveElementList *geometry = new TEveElementList("Geometry"); 124 TObjArray *nodes = top->GetNodes(); 125 TIter itNodes(nodes); 126 TGeoNode *nodeobj; 127 TEveGeoTopNode *node; 128 while((nodeobj = (TGeoNode*)itNodes.Next())) { 129 node = new TEveGeoTopNode(gGeoManager,nodeobj); 130 node->UseNodeTrans(); 131 geometry->AddElement(node); 132 } 133 134 // Create chain of root trees 135 chain_->Add(inputFile); 136 137 // Create object of class ExRootTreeReader 138 fStatusBar_->SetText("Opening Delphes data file", 1); 139 gSystem->ProcessEvents(); 140 treeReader_ = new ExRootTreeReader(chain_); 141 142 // prepare data collections 143 readConfig(configFile, elements_); 144 for(std::vector<DelphesBranchBase *>::iterator element = elements_.begin(); element<elements_.end(); ++element) { 145 DelphesBranchElement<TEveTrackList> *item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element); 146 DelphesBranchElement<TEveElementList> *item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element); 147 if(item_v1) gEve->AddElement(item_v1->GetContainer()); 148 if(item_v2) gEve->AddElement(item_v2->GetContainer()); 149 } 150 151 // viewers and scenes 152 delphesDisplay_ = new DelphesDisplay; 153 gEve->AddGlobalElement(geometry); 154 delphesDisplay_->ImportGeomRPhi(geometry); 155 delphesDisplay_->ImportGeomRhoZ(geometry); 156 // find the first calo data and use that to initialize the calo display 157 for(std::vector<DelphesBranchBase *>::iterator data=elements_.begin();data<elements_.end();++data) { 158 if(TString((*data)->GetType())=="Tower") { // we could also use GetClassName()=="DelphesCaloData" 159 DelphesCaloData *container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer(); 160 assert(container); 161 TEveCalo3D *calo3d = new TEveCalo3D(container); 162 calo3d->SetBarrelRadius(tkRadius_); 163 calo3d->SetEndCapPos(tkHalfLength_); 164 gEve->AddGlobalElement(calo3d); 165 delphesDisplay_->ImportCaloRPhi(calo3d); 166 delphesDisplay_->ImportCaloRhoZ(calo3d); 167 TEveCaloLego *lego = new TEveCaloLego(container); 168 lego->InitMainTrans(); 169 // lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi()); 170 lego->RefMainTrans().SetScale(100, 100, TMath::Pi()); 171 lego->SetAutoRebin(kFALSE); 172 lego->Set2DMode(TEveCaloLego::kValSizeOutline); 173 delphesDisplay_->ImportCaloLego(lego); 174 break; 175 } 176 } 177 178 // the GUI: control panel, summary tab 179 make_gui(); 180 181 //ready... 182 fStatusBar_->SetText("Ready.", 1); 183 gSystem->ProcessEvents(); 184 load_event(); 185 gEve->Redraw3D(kTRUE); 186 96 DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry &det3D) 97 { 98 event_id_ = 0; 99 tkRadius_ = 1.29; 100 totRadius_ = 2.0; 101 tkHalfLength_ = 3.0; 102 bz_ = 3.8; 103 chain_ = new TChain("Delphes"); 104 treeReader_ = 0; 105 delphesDisplay_ = 0; 106 107 // initialize the application 108 TEveManager::Create(kTRUE, "IV"); 109 fStatusBar_ = gEve->GetBrowser()->GetStatusBar(); 110 TGeoManager *geom = gGeoManager; 111 112 // build the detector 113 tkRadius_ = det3D.getTrackerRadius(); 114 totRadius_ = det3D.getDetectorRadius(); 115 tkHalfLength_ = det3D.getTrackerHalfLength(); 116 muHalfLength_ = det3D.getDetectorHalfLength(); 117 bz_ = det3D.getBField(); 118 etaAxis_ = det3D.getCaloAxes().first; 119 phiAxis_ = det3D.getCaloAxes().second; 120 TGeoVolume *top = det3D.getDetector(false); 121 geom->SetTopVolume(top); 122 TEveElementList *geometry = new TEveElementList("Geometry"); 123 TObjArray *nodes = top->GetNodes(); 124 TIter itNodes(nodes); 125 TGeoNode *nodeobj; 126 TEveGeoTopNode *node; 127 while((nodeobj = (TGeoNode *)itNodes.Next())) 128 { 129 node = new TEveGeoTopNode(gGeoManager, nodeobj); 130 node->UseNodeTrans(); 131 geometry->AddElement(node); 132 } 133 134 // Create chain of root trees 135 chain_->Add(inputFile); 136 137 // Create object of class ExRootTreeReader 138 fStatusBar_->SetText("Opening Delphes data file", 1); 139 gSystem->ProcessEvents(); 140 treeReader_ = new ExRootTreeReader(chain_); 141 142 // prepare data collections 143 readConfig(configFile, elements_); 144 for(std::vector<DelphesBranchBase *>::iterator element = elements_.begin(); element < elements_.end(); ++element) 145 { 146 DelphesBranchElement<TEveTrackList> *item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList> *>(*element); 147 DelphesBranchElement<TEveElementList> *item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList> *>(*element); 148 if(item_v1) gEve->AddElement(item_v1->GetContainer()); 149 if(item_v2) gEve->AddElement(item_v2->GetContainer()); 150 } 151 152 // viewers and scenes 153 delphesDisplay_ = new DelphesDisplay; 154 gEve->AddGlobalElement(geometry); 155 delphesDisplay_->ImportGeomRPhi(geometry); 156 delphesDisplay_->ImportGeomRhoZ(geometry); 157 // find the first calo data and use that to initialize the calo display 158 for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data) 159 { 160 if(TString((*data)->GetType()) == "Tower") 161 { // we could also use GetClassName()=="DelphesCaloData" 162 DelphesCaloData *container = dynamic_cast<DelphesBranchElement<DelphesCaloData> *>((*data))->GetContainer(); 163 assert(container); 164 TEveCalo3D *calo3d = new TEveCalo3D(container); 165 calo3d->SetBarrelRadius(tkRadius_); 166 calo3d->SetEndCapPos(tkHalfLength_); 167 gEve->AddGlobalElement(calo3d); 168 delphesDisplay_->ImportCaloRPhi(calo3d); 169 delphesDisplay_->ImportCaloRhoZ(calo3d); 170 TEveCaloLego *lego = new TEveCaloLego(container); 171 lego->InitMainTrans(); 172 // lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi()); 173 lego->RefMainTrans().SetScale(100, 100, TMath::Pi()); 174 lego->SetAutoRebin(kFALSE); 175 lego->Set2DMode(TEveCaloLego::kValSizeOutline); 176 delphesDisplay_->ImportCaloLego(lego); 177 break; 178 } 179 } 180 181 // the GUI: control panel, summary tab 182 make_gui(); 183 184 //ready... 185 fStatusBar_->SetText("Ready.", 1); 186 gSystem->ProcessEvents(); 187 load_event(); 188 gEve->Redraw3D(kTRUE); 187 189 } 188 190 189 191 // function that parses the config to extract the branches of interest and prepare containers 190 void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements) { 191 ExRootConfReader *confReader = new ExRootConfReader; 192 confReader->ReadFile(configFile); 193 ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch"); 194 Int_t nBranches = branches.GetSize()/3; 195 DelphesBranchElement<TEveTrackList> *tlist; 196 DelphesBranchElement<DelphesCaloData> *clist; 197 DelphesBranchElement<TEveElementList> *elist; 198 // first loop with all but tracks 199 for(Int_t b = 0; b<nBranches; ++b) { 200 TString input = branches[b*3].GetString(); 201 TString name = branches[b*3+1].GetString(); 202 TString className = branches[b*3+2].GetString(); 203 if(className=="Tower") { 204 if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow 205 clist = new DelphesBranchElement<DelphesCaloData>(name,treeReader_->UseBranch(name),kBlack); 206 clist->GetContainer()->SetEtaBins(etaAxis_); 207 clist->GetContainer()->SetPhiBins(phiAxis_); 208 elements.push_back(clist); 209 } else if(className=="Jet") { 210 if(input.Contains("GenJetFinder")) { 211 elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kCyan); 212 elist->GetContainer()->SetRnrSelf(false); 213 elist->GetContainer()->SetRnrChildren(false); 214 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 215 elements.push_back(elist); 216 } else { 217 elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kYellow); 218 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 219 elements.push_back(elist); 220 } 221 } else if(className=="Electron") { 222 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kRed); 223 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 224 elements.push_back(tlist); 225 } else if(className=="Photon") { 226 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kYellow); 227 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 228 elements.push_back(tlist); 229 } else if(className=="Muon") { 230 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kGreen); 231 tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_); 232 elements.push_back(tlist); 233 } else if(className=="MissingET") { 234 elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kViolet); 235 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 236 elements.push_back(elist); 237 } else if(className=="GenParticle") { 238 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kCyan); 239 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 240 tlist->GetContainer()->SetRnrSelf(false); 241 tlist->GetContainer()->SetRnrChildren(false); 242 elements.push_back(tlist); 243 } else { 244 continue; 245 } 246 } 247 // second loop for tracks 248 for(Int_t b = 0; b<nBranches; ++b) { 249 TString input = branches[b*3].GetString(); 250 TString name = branches[b*3+1].GetString(); 251 TString className = branches[b*3+2].GetString(); 252 if(className=="Track") { 253 if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow 254 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kBlue); 255 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 256 elements.push_back(tlist); 257 } 258 } 192 void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase *> &elements) 193 { 194 ExRootConfReader *confReader = new ExRootConfReader; 195 confReader->ReadFile(configFile); 196 ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch"); 197 Int_t nBranches = branches.GetSize() / 3; 198 DelphesBranchElement<TEveTrackList> *tlist; 199 DelphesBranchElement<DelphesCaloData> *clist; 200 DelphesBranchElement<TEveElementList> *elist; 201 // first loop with all but tracks 202 for(Int_t b = 0; b < nBranches; ++b) 203 { 204 TString input = branches[b * 3].GetString(); 205 TString name = branches[b * 3 + 1].GetString(); 206 TString className = branches[b * 3 + 2].GetString(); 207 if(className == "Tower") 208 { 209 if(input.Contains("eflow", TString::kIgnoreCase) || name.Contains("eflow", TString::kIgnoreCase)) continue; //no eflow 210 clist = new DelphesBranchElement<DelphesCaloData>(name, treeReader_->UseBranch(name), kBlack); 211 clist->GetContainer()->SetEtaBins(etaAxis_); 212 clist->GetContainer()->SetPhiBins(phiAxis_); 213 elements.push_back(clist); 214 } 215 else if(className == "Jet") 216 { 217 if(input.Contains("GenJetFinder")) 218 { 219 elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kCyan); 220 elist->GetContainer()->SetRnrSelf(false); 221 elist->GetContainer()->SetRnrChildren(false); 222 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 223 elements.push_back(elist); 224 } 225 else 226 { 227 elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kYellow); 228 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 229 elements.push_back(elist); 230 } 231 } 232 else if(className == "Electron") 233 { 234 tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kRed); 235 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 236 elements.push_back(tlist); 237 } 238 else if(className == "Photon") 239 { 240 tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kYellow); 241 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 242 elements.push_back(tlist); 243 } 244 else if(className == "Muon") 245 { 246 tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kGreen); 247 tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_); 248 elements.push_back(tlist); 249 } 250 else if(className == "MissingET") 251 { 252 elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kViolet); 253 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 254 elements.push_back(elist); 255 } 256 else if(className == "GenParticle") 257 { 258 tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kCyan); 259 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 260 tlist->GetContainer()->SetRnrSelf(false); 261 tlist->GetContainer()->SetRnrChildren(false); 262 elements.push_back(tlist); 263 } 264 else 265 { 266 continue; 267 } 268 } 269 // second loop for tracks 270 for(Int_t b = 0; b < nBranches; ++b) 271 { 272 TString input = branches[b * 3].GetString(); 273 TString name = branches[b * 3 + 1].GetString(); 274 TString className = branches[b * 3 + 2].GetString(); 275 if(className == "Track") 276 { 277 if(input.Contains("eflow", TString::kIgnoreCase) || name.Contains("eflow", TString::kIgnoreCase)) continue; //no eflow 278 tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kBlue); 279 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 280 elements.push_back(tlist); 281 } 282 } 259 283 } 260 284 261 285 void DelphesEventDisplay::load_event() 262 286 { 263 // Load event specified in global event_id_. 264 // The contents of previous event are removed. 265 266 // safety 267 if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return; 268 269 // message 270 fStatusBar_->SetText(Form("Loading event %d.", event_id_), 1); 271 gSystem->ProcessEvents(); 272 273 // clear the previous event 274 gEve->GetViewers()->DeleteAnnotations(); 275 for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) { 276 (*data)->Reset(); 277 } 278 279 // Load selected branches with data from specified event 280 treeReader_->ReadEntry(event_id_); 281 for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) { 282 (*data)->ReadBranch(); 283 } 284 285 // update display 286 TEveElement *top = (TEveElement*)gEve->GetCurrentEvent(); 287 delphesDisplay_->DestroyEventRPhi(); 288 delphesDisplay_->ImportEventRPhi(top); 289 delphesDisplay_->DestroyEventRhoZ(); 290 delphesDisplay_->ImportEventRhoZ(top); 291 update_html_summary(); 292 plotSummary_->FillEvent(); 293 plotSummary_->Draw(); 294 295 gEve->Redraw3D(kFALSE, kTRUE); 296 fStatusBar_->SetText(Form("Loaded event %d.", event_id_), 1); 297 gSystem->ProcessEvents(); 287 // Load event specified in global event_id_. 288 // The contents of previous event are removed. 289 290 // safety 291 if(event_id_ >= treeReader_->GetEntries() || event_id_ < 0) return; 292 293 // message 294 fStatusBar_->SetText(Form("Loading event %d.", event_id_), 1); 295 gSystem->ProcessEvents(); 296 297 // clear the previous event 298 gEve->GetViewers()->DeleteAnnotations(); 299 for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data) 300 { 301 (*data)->Reset(); 302 } 303 304 // Load selected branches with data from specified event 305 treeReader_->ReadEntry(event_id_); 306 for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data) 307 { 308 (*data)->ReadBranch(); 309 } 310 311 // update display 312 TEveElement *top = (TEveElement *)gEve->GetCurrentEvent(); 313 delphesDisplay_->DestroyEventRPhi(); 314 delphesDisplay_->ImportEventRPhi(top); 315 delphesDisplay_->DestroyEventRhoZ(); 316 delphesDisplay_->ImportEventRhoZ(top); 317 update_html_summary(); 318 plotSummary_->FillEvent(); 319 plotSummary_->Draw(); 320 321 gEve->Redraw3D(kFALSE, kTRUE); 322 fStatusBar_->SetText(Form("Loaded event %d.", event_id_), 1); 323 gSystem->ProcessEvents(); 298 324 } 299 325 300 326 void DelphesEventDisplay::update_html_summary() 301 327 { 302 // Update summary of current event. 303 304 TEveElement::List_i i; 305 TEveElement::List_i j; 306 Int_t k; 307 TEveElement *el; 308 DelphesHtmlObjTable *table; 309 TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0; 310 if (mgr) { 311 htmlSummary_->Clear("D"); 312 for (i=mgr->BeginChildren(); i!=mgr->EndChildren(); ++i) { 313 el = ((TEveElement*)(*i)); 314 if (el->IsA() == TEvePointSet::Class()) { 315 TEvePointSet *ps = (TEvePointSet *)el; 316 TString ename = ps->GetElementName(); 317 TString etitle = ps->GetElementTitle(); 318 if (ename.First('\'') != kNPOS) 319 ename.Remove(ename.First('\'')); 320 etitle.Remove(0, 2); 321 Int_t nel = atoi(etitle.Data()); 322 table = htmlSummary_->AddTable(ename, 0, nel); 323 } 324 else if (el->IsA() == TEveTrackList::Class()) { 325 TEveTrackList *tracks = (TEveTrackList *)el; 326 TString ename = tracks->GetElementName(); 327 if (ename.First('\'') != kNPOS) 328 ename.Remove(ename.First('\'')); 329 table = htmlSummary_->AddTable(ename.Data(), 5, 330 tracks->NumChildren(), kTRUE, "first"); 331 table->SetLabel(0, "Momentum"); 332 table->SetLabel(1, "P_t"); 333 table->SetLabel(2, "Phi"); 334 table->SetLabel(3, "Theta"); 335 table->SetLabel(4, "Eta"); 336 k=0; 337 for (j=tracks->BeginChildren(); j!=tracks->EndChildren(); ++j) { 338 Float_t p = ((TEveTrack*)(*j))->GetMomentum().Mag(); 339 table->SetValue(0, k, p); 340 Float_t pt = ((TEveTrack*)(*j))->GetMomentum().Perp(); 341 table->SetValue(1, k, pt); 342 Float_t phi = ((TEveTrack*)(*j))->GetMomentum().Phi(); 343 table->SetValue(2, k, phi); 344 Float_t theta = ((TEveTrack*)(*j))->GetMomentum().Theta(); 345 table->SetValue(3, k, theta); 346 Float_t eta = theta>0.0005 && theta<3.1413 ? ((TEveTrack*)(*j))->GetMomentum().Eta() : 1e10; 347 table->SetValue(4, k, eta); 348 ++k; 349 } 350 } 328 // Update summary of current event. 329 330 TEveElement::List_i i; 331 TEveElement::List_i j; 332 Int_t k; 333 TEveElement *el; 334 DelphesHtmlObjTable *table; 335 TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0; 336 if(mgr) 337 { 338 htmlSummary_->Clear("D"); 339 for(i = mgr->BeginChildren(); i != mgr->EndChildren(); ++i) 340 { 341 el = ((TEveElement *)(*i)); 342 if(el->IsA() == TEvePointSet::Class()) 343 { 344 TEvePointSet *ps = (TEvePointSet *)el; 345 TString ename = ps->GetElementName(); 346 TString etitle = ps->GetElementTitle(); 347 if(ename.First('\'') != kNPOS) 348 ename.Remove(ename.First('\'')); 349 etitle.Remove(0, 2); 350 Int_t nel = atoi(etitle.Data()); 351 table = htmlSummary_->AddTable(ename, 0, nel); 351 352 } 352 htmlSummary_->Build(); 353 gHtml_->Clear(); 354 gHtml_->ParseText((char*)htmlSummary_->Html().Data()); 355 gHtml_->Layout(); 356 } 357 353 else if(el->IsA() == TEveTrackList::Class()) 354 { 355 TEveTrackList *tracks = (TEveTrackList *)el; 356 TString ename = tracks->GetElementName(); 357 if(ename.First('\'') != kNPOS) 358 ename.Remove(ename.First('\'')); 359 table = htmlSummary_->AddTable(ename.Data(), 5, 360 tracks->NumChildren(), kTRUE, "first"); 361 table->SetLabel(0, "Momentum"); 362 table->SetLabel(1, "P_t"); 363 table->SetLabel(2, "Phi"); 364 table->SetLabel(3, "Theta"); 365 table->SetLabel(4, "Eta"); 366 k = 0; 367 for(j = tracks->BeginChildren(); j != tracks->EndChildren(); ++j) 368 { 369 Float_t p = ((TEveTrack *)(*j))->GetMomentum().Mag(); 370 table->SetValue(0, k, p); 371 Float_t pt = ((TEveTrack *)(*j))->GetMomentum().Perp(); 372 table->SetValue(1, k, pt); 373 Float_t phi = ((TEveTrack *)(*j))->GetMomentum().Phi(); 374 table->SetValue(2, k, phi); 375 Float_t theta = ((TEveTrack *)(*j))->GetMomentum().Theta(); 376 table->SetValue(3, k, theta); 377 Float_t eta = theta > 0.0005 && theta < 3.1413 ? ((TEveTrack *)(*j))->GetMomentum().Eta() : 1e10; 378 table->SetValue(4, k, eta); 379 ++k; 380 } 381 } 382 } 383 htmlSummary_->Build(); 384 gHtml_->Clear(); 385 gHtml_->ParseText((char *)htmlSummary_->Html().Data()); 386 gHtml_->Layout(); 387 } 358 388 } 359 389 … … 364 394 void DelphesEventDisplay::make_gui() 365 395 { 366 // Create minimal GUI for event navigation. 367 368 // add a tab on the left 369 TEveBrowser *browser = gEve->GetBrowser(); 370 browser->SetWindowName("Delphes Event Display"); 371 browser->StartEmbedding(TRootBrowser::kLeft); 372 373 // set the main title 374 TGMainFrame *frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); 375 frmMain->SetWindowName("Delphes Event Display"); 376 frmMain->SetCleanup(kDeepCleanup); 377 378 // build the navigation menu 379 TString icondir; 380 if(gSystem->Getenv("ROOTSYS")) 381 icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS")); 382 if(!gSystem->OpenDirectory(icondir)) 383 icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") ); 384 TGGroupFrame *vf = new TGGroupFrame(frmMain,"Event navigation",kVerticalFrame | kFitWidth ); 385 { 386 TGHorizontalFrame *hf = new TGHorizontalFrame(frmMain); 387 { 388 TGPictureButton *b = 0; 389 390 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif")); 391 hf->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 10, 2, 10, 10)); 392 b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()"); 393 394 TGNumberEntry *numberEntry = new TGNumberEntry(hf,0,9,-1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, treeReader_->GetEntries()); 395 hf->AddFrame(numberEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY , 2, 0, 10, 10)); 396 this->Connect("EventChanged(Int_t)","TGNumberEntry",numberEntry,"SetIntNumber(Long_t)"); 397 numberEntry->GetNumberEntry()->Connect("TextChanged(char*)", "DelphesEventDisplay", this, "PreSetEv(char*)"); 398 numberEntry->GetNumberEntry()->Connect("ReturnPressed()", "DelphesEventDisplay", this, "GoTo()"); 399 400 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif")); 401 hf->AddFrame(b, new TGLayoutHints(kLHintsRight | kLHintsCenterY , 2, 10, 10, 10)); 402 b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()"); 403 404 } 405 vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX , 2, 2, 2, 2)); 406 407 TGHProgressBar *progress = new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100); 408 progress->SetMax( treeReader_->GetEntries()); 409 progress->ShowPosition(kTRUE, kFALSE, "Event %.0f"); 410 progress->SetBarColor("green"); 411 vf->AddFrame(progress, new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5)); 412 this->Connect("EventChanged(Int_t)","TGHProgressBar",progress,"SetPosition(Float_t)"); 413 } 414 frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5)); 415 vf = new TGGroupFrame(frmMain,"Batch operations",kVerticalFrame | kFitWidth ); 416 { 417 TGTextButton *b = new TGTextButton(vf, "Initialize Summary Plots"); 418 vf->AddFrame(b, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX, 10, 10, 10, 10)); 419 b->Connect("Clicked()", "DelphesEventDisplay", this, "InitSummaryPlots()"); 420 } 421 frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5)); 422 423 frmMain->MapSubwindows(); 424 frmMain->Resize(); 425 frmMain->MapWindow(); 426 browser->StopEmbedding(); 427 browser->SetTabTitle("Event Control", 0); 428 429 // the summary tab 430 htmlSummary_ = new DelphesHtmlSummary("Delphes Event Display Summary Table"); 431 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); 432 gHtml_ = new TGHtml(0, 100, 100); 433 TEveWindowFrame *wf = slot->MakeFrame(gHtml_); 434 gHtml_->MapSubwindows(); 435 wf->SetElementName("Summary tables"); 436 437 // plot tab 438 slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); 439 TEveWindowTab *tab = slot->MakeTab(); 440 tab->SetElementName("Summary plots"); 441 tab->SetShowTitleBar(kFALSE); 442 plotSummary_ = new DelphesPlotSummary(tab); 443 plotSummary_->Init(elements_); 444 plotSummary_->Connect("Progress(Int_t)", "DelphesEventDisplay", this, "DisplayProgress(Int_t)"); 445 446 } 447 448 void DelphesEventDisplay::Fwd() { 449 if (event_id_ < treeReader_->GetEntries() - 2) { 450 EventChanged(event_id_+1); 451 } else { 452 printf("Already at last event.\n"); 453 } 454 } 455 456 void DelphesEventDisplay::Bck() { 457 if (event_id_ > 0) { 458 EventChanged(event_id_-1); 459 } else { 460 printf("Already at first event.\n"); 461 } 462 } 463 464 void DelphesEventDisplay::PreSetEv(char *ev) { 396 // Create minimal GUI for event navigation. 397 398 // add a tab on the left 399 TEveBrowser *browser = gEve->GetBrowser(); 400 browser->SetWindowName("Delphes Event Display"); 401 browser->StartEmbedding(TRootBrowser::kLeft); 402 403 // set the main title 404 TGMainFrame *frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); 405 frmMain->SetWindowName("Delphes Event Display"); 406 frmMain->SetCleanup(kDeepCleanup); 407 408 // build the navigation menu 409 TString icondir; 410 if(gSystem->Getenv("ROOTSYS")) 411 icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS")); 412 if(!gSystem->OpenDirectory(icondir)) 413 icondir = Form("%s/icons/", (const char *)gSystem->GetFromPipe("root-config --etcdir")); 414 TGGroupFrame *vf = new TGGroupFrame(frmMain, "Event navigation", kVerticalFrame | kFitWidth); 415 { 416 TGHorizontalFrame *hf = new TGHorizontalFrame(frmMain); 417 { 418 TGPictureButton *b = 0; 419 420 b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoBack.gif")); 421 hf->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 10, 10)); 422 b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()"); 423 424 TGNumberEntry *numberEntry = new TGNumberEntry(hf, 0, 9, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, treeReader_->GetEntries()); 425 hf->AddFrame(numberEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 0, 10, 10)); 426 this->Connect("EventChanged(Int_t)", "TGNumberEntry", numberEntry, "SetIntNumber(Long_t)"); 427 numberEntry->GetNumberEntry()->Connect("TextChanged(char*)", "DelphesEventDisplay", this, "PreSetEv(char*)"); 428 numberEntry->GetNumberEntry()->Connect("ReturnPressed()", "DelphesEventDisplay", this, "GoTo()"); 429 430 b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoForward.gif")); 431 hf->AddFrame(b, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 2, 10, 10, 10)); 432 b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()"); 433 } 434 vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2)); 435 436 TGHProgressBar *progress = new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100); 437 progress->SetMax(treeReader_->GetEntries()); 438 progress->ShowPosition(kTRUE, kFALSE, "Event %.0f"); 439 progress->SetBarColor("green"); 440 vf->AddFrame(progress, new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5)); 441 this->Connect("EventChanged(Int_t)", "TGHProgressBar", progress, "SetPosition(Float_t)"); 442 } 443 frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5)); 444 vf = new TGGroupFrame(frmMain, "Batch operations", kVerticalFrame | kFitWidth); 445 { 446 TGTextButton *b = new TGTextButton(vf, "Initialize Summary Plots"); 447 vf->AddFrame(b, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX, 10, 10, 10, 10)); 448 b->Connect("Clicked()", "DelphesEventDisplay", this, "InitSummaryPlots()"); 449 } 450 frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5)); 451 452 frmMain->MapSubwindows(); 453 frmMain->Resize(); 454 frmMain->MapWindow(); 455 browser->StopEmbedding(); 456 browser->SetTabTitle("Event Control", 0); 457 458 // the summary tab 459 htmlSummary_ = new DelphesHtmlSummary("Delphes Event Display Summary Table"); 460 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); 461 gHtml_ = new TGHtml(0, 100, 100); 462 TEveWindowFrame *wf = slot->MakeFrame(gHtml_); 463 gHtml_->MapSubwindows(); 464 wf->SetElementName("Summary tables"); 465 466 // plot tab 467 slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); 468 TEveWindowTab *tab = slot->MakeTab(); 469 tab->SetElementName("Summary plots"); 470 tab->SetShowTitleBar(kFALSE); 471 plotSummary_ = new DelphesPlotSummary(tab); 472 plotSummary_->Init(elements_); 473 plotSummary_->Connect("Progress(Int_t)", "DelphesEventDisplay", this, "DisplayProgress(Int_t)"); 474 } 475 476 void DelphesEventDisplay::Fwd() 477 { 478 if(event_id_ < treeReader_->GetEntries() - 2) 479 { 480 EventChanged(event_id_ + 1); 481 } 482 else 483 { 484 printf("Already at last event.\n"); 485 } 486 } 487 488 void DelphesEventDisplay::Bck() 489 { 490 if(event_id_ > 0) 491 { 492 EventChanged(event_id_ - 1); 493 } 494 else 495 { 496 printf("Already at first event.\n"); 497 } 498 } 499 500 void DelphesEventDisplay::PreSetEv(char *ev) 501 { 465 502 event_id_tmp_ = Int_t(atoi(ev)); 466 503 } 467 504 468 void DelphesEventDisplay::GoTo() { 469 if (event_id_tmp_>=0 && event_id_tmp_ < treeReader_->GetEntries()-1) { 505 void DelphesEventDisplay::GoTo() 506 { 507 if(event_id_tmp_ >= 0 && event_id_tmp_ < treeReader_->GetEntries() - 1) 508 { 470 509 EventChanged(event_id_tmp_); 471 } else { 510 } 511 else 512 { 472 513 printf("Error: no such event.\n"); 473 514 } 474 515 } 475 516 476 void DelphesEventDisplay::InitSummaryPlots() { 517 void DelphesEventDisplay::InitSummaryPlots() 518 { 477 519 plotSummary_->FillSample(treeReader_, event_id_); 478 520 plotSummary_->FillEvent(); … … 480 522 } 481 523 482 void DelphesEventDisplay::DisplayProgress(Int_t p) { 483 fStatusBar_->SetText(Form("Processing... %d %%",p), 1); 524 void DelphesEventDisplay::DisplayProgress(Int_t p) 525 { 526 fStatusBar_->SetText(Form("Processing... %d %%", p), 1); 484 527 gSystem->ProcessEvents(); 485 528 } -
display/DelphesEventDisplay.h
r45e58be r341014c 22 22 #include <vector> 23 23 24 #include "RQ_OBJECT.h" 24 25 #include "Rtypes.h" 25 #include "RQ_OBJECT.h"26 26 27 27 class TAxis; … … 45 45 class DelphesEventDisplay 46 46 { 47 48 49 50 DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry&det3D);51 52 47 RQ_OBJECT("DelphesEventDisplay") 48 public: 49 DelphesEventDisplay(); 50 DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry &det3D); 51 ~DelphesEventDisplay(); 52 void EventChanged(Int_t); // *SIGNAL* 53 53 54 55 56 57 58 void readConfig(const char *configFile, std::vector<DelphesBranchBase *>&elements);54 private: 55 void update_html_summary(); 56 void make_gui(); 57 void load_event(); 58 void readConfig(const char *configFile, std::vector<DelphesBranchBase *> &elements); 59 59 60 // Configuration and global variables. 61 Int_t event_id_; 62 Int_t event_id_tmp_; 63 ExRootTreeReader *treeReader_; 64 Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_; 65 TAxis *etaAxis_, *phiAxis_; 66 TChain *chain_; 67 std::vector<DelphesBranchBase *> elements_; 68 DelphesDisplay *delphesDisplay_; 69 DelphesHtmlSummary *htmlSummary_; 70 TGHtml *gHtml_; 71 DelphesPlotSummary *plotSummary_; 72 TGStatusBar *fStatusBar_; 73 74 // gui controls 75 public: 76 void Fwd(); 60 // Configuration and global variables. 61 Int_t event_id_; 62 Int_t event_id_tmp_; 63 ExRootTreeReader *treeReader_; 64 Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_; 65 TAxis *etaAxis_, *phiAxis_; 66 TChain *chain_; 67 std::vector<DelphesBranchBase *> elements_; 68 DelphesDisplay *delphesDisplay_; 69 DelphesHtmlSummary *htmlSummary_; 70 TGHtml *gHtml_; 71 DelphesPlotSummary *plotSummary_; 72 TGStatusBar *fStatusBar_; 77 73 78 void Bck(); 74 // gui controls 75 public: 76 void Fwd(); 79 77 80 void PreSetEv(char *ev);78 void Bck(); 81 79 82 void GoTo();80 void PreSetEv(char *ev); 83 81 84 void InitSummaryPlots();82 void GoTo(); 85 83 86 void DisplayProgress(Int_t p); 84 void InitSummaryPlots(); 85 86 void DisplayProgress(Int_t p); 87 87 }; 88 88 -
display/DelphesHtmlSummary.cc
r45e58be r341014c 18 18 19 19 #include "display/DelphesHtmlSummary.h" 20 #include "TGHtml.h"21 20 #include "TEveElement.h" 21 #include "TEveEventManager.h" 22 22 #include "TEveManager.h" 23 #include "TEveEventManager.h"24 23 #include "TEvePointSet.h" 25 24 #include "TEveTrack.h" 25 #include "TGHtml.h" 26 26 27 27 //============================================================================== 28 28 29 29 DelphesHtmlSummary *fgDelphesHtmlSummary = 0; 30 TGHtml *fgHtml= 0;30 TGHtml *fgHtml = 0; 31 31 32 32 //============================================================================== 33 33 34 34 //______________________________________________________________________________ 35 DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) : 36 37 { 38 39 40 41 for (int i=0;i<fNFields;i++)42 43 35 DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) : 36 fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp) 37 { 38 // Constructor. 39 40 fValues = new TArrayF[fNFields]; 41 for(int i = 0; i < fNFields; i++) 42 fValues[i].Set(nvals); 43 fLabels = new TString[fNFields]; 44 44 } 45 45 … … 47 47 DelphesHtmlObjTable::~DelphesHtmlObjTable() 48 48 { 49 50 51 delete[] fValues;52 delete[] fLabels;49 // Destructor. 50 51 delete[] fValues; 52 delete[] fLabels; 53 53 } 54 54 … … 56 56 void DelphesHtmlObjTable::Build() 57 57 { 58 // Build HTML code. 59 60 fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ", 61 62 BuildTitle(); 63 if (fExpand && (fNFields > 0) && (fNValues > 0)) { 64 BuildLabels(); 65 BuildTable(); 66 } 67 68 fHtml += "</table>"; 58 // Build HTML code. 59 60 fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ", 61 62 BuildTitle(); 63 if(fExpand && (fNFields > 0) && (fNValues > 0)) 64 { 65 BuildLabels(); 66 BuildTable(); 67 } 68 69 fHtml += "</table>"; 69 70 } 70 71 … … 72 73 void DelphesHtmlObjTable::BuildTitle() 73 74 { 74 75 76 77 fHtml += Form("%d>", fNFields+1);78 79 80 81 82 83 84 85 86 87 88 89 75 // Build table title. 76 77 fHtml += "<tr><td colspan="; 78 fHtml += Form("%d>", fNFields + 1); 79 fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>"; 80 fHtml += "<tr><td align=left>"; 81 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>"; 82 fHtml += fName; 83 fHtml += "</i></b></font></td>"; 84 fHtml += "<td>"; 85 fHtml += "<td align=right> "; 86 fHtml += "<font face=Verdana size=3 color=ffffff><b><i>"; 87 fHtml += Form("Size = %d", fNValues); 88 fHtml += "</i></b></font></td></tr>"; 89 fHtml += "</table>"; 90 fHtml += "</td></tr>"; 90 91 } 91 92 … … 93 94 void DelphesHtmlObjTable::BuildLabels() 94 95 { 95 // Build table labels. 96 97 Int_t i; 98 fHtml += "<tr bgcolor=c0c0ff>"; 99 fHtml += "<th> </th>"; // for the check boxes 100 for (i=0;i<fNFields;i++) { 101 fHtml += "<th> "; 102 fHtml += fLabels[i]; 103 fHtml += " </th>"; // for the check boxes 104 } 105 fHtml += "</tr>"; 96 // Build table labels. 97 98 Int_t i; 99 fHtml += "<tr bgcolor=c0c0ff>"; 100 fHtml += "<th> </th>"; // for the check boxes 101 for(i = 0; i < fNFields; i++) 102 { 103 fHtml += "<th> "; 104 fHtml += fLabels[i]; 105 fHtml += " </th>"; // for the check boxes 106 } 107 fHtml += "</tr>"; 106 108 } 107 109 … … 109 111 void DelphesHtmlObjTable::BuildTable() 110 112 { 111 // Build part of table with values. 112 113 for (int i = 0; i < fNValues; i++) { 114 if (i%2) 115 fHtml += "<tr bgcolor=e0e0ff>"; 116 else 117 fHtml += "<tr bgcolor=ffffff>"; 118 119 TString name = fName; 120 name.ReplaceAll(" ", "_"); 121 // checkboxes 122 fHtml += "<td bgcolor=d0d0ff align=\"center\">"; 123 fHtml += "<input type=\"checkbox\" name=\""; 124 fHtml += name; 125 fHtml += Form("[%d]\">",i); 113 // Build part of table with values. 114 115 for(int i = 0; i < fNValues; i++) 116 { 117 if(i % 2) 118 fHtml += "<tr bgcolor=e0e0ff>"; 119 else 120 fHtml += "<tr bgcolor=ffffff>"; 121 122 TString name = fName; 123 name.ReplaceAll(" ", "_"); 124 // checkboxes 125 fHtml += "<td bgcolor=d0d0ff align=\"center\">"; 126 fHtml += "<input type=\"checkbox\" name=\""; 127 fHtml += name; 128 fHtml += Form("[%d]\">", i); 129 fHtml += "</td>"; 130 131 for(int j = 0; j < fNFields; j++) 132 { 133 fHtml += "<td width="; 134 fHtml += Form("%d%%", 100 / fNFields); 135 fHtml += " align=\"center\""; 136 fHtml += ">"; 137 fHtml += Form("%1.4f", fValues[j][i]); 126 138 fHtml += "</td>"; 127 128 for (int j = 0; j < fNFields; j++) { 129 fHtml += "<td width="; 130 fHtml += Form("%d%%", 100/fNFields); 131 fHtml += " align=\"center\""; 132 fHtml += ">"; 133 fHtml += Form("%1.4f", fValues[j][i]); 134 fHtml += "</td>"; 135 } 136 fHtml += "</tr> "; 137 } 138 } 139 140 //______________________________________________________________________________ 141 DelphesHtmlSummary::DelphesHtmlSummary(const char *title) : fNTables(0), fTitle(title) 142 { 143 // Constructor. 144 145 fObjTables = new TOrdCollection(); 139 } 140 fHtml += "</tr> "; 141 } 142 } 143 144 //______________________________________________________________________________ 145 DelphesHtmlSummary::DelphesHtmlSummary(const char *title) : 146 fNTables(0), fTitle(title) 147 { 148 // Constructor. 149 150 fObjTables = new TOrdCollection(); 146 151 } 147 152 … … 149 154 DelphesHtmlSummary::~DelphesHtmlSummary() 150 155 { 151 152 153 156 // Destructor. 157 158 Reset(); 154 159 } 155 160 156 161 //______________________________________________________________________________ 157 162 DelphesHtmlObjTable *DelphesHtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals, 158 159 { 160 161 162 163 164 165 166 if(opt.Contains("first"))167 168 169 170 163 Bool_t exp, Option_t *option) 164 { 165 // Add a new table in our list of tables. 166 167 TString opt = option; 168 opt.ToLower(); 169 DelphesHtmlObjTable *table = new DelphesHtmlObjTable(name, nfields, nvals, exp); 170 fNTables++; 171 if(opt.Contains("first")) 172 fObjTables->AddFirst(table); 173 else 174 fObjTables->Add(table); 175 return table; 171 176 } 172 177 … … 174 179 void DelphesHtmlSummary::Clear(Option_t *option) 175 180 { 176 177 178 if(option && option[0] == 'D')179 180 181 182 181 // Clear the table list. 182 183 if(option && option[0] == 'D') 184 fObjTables->Delete(option); 185 else 186 fObjTables->Clear(option); 187 fNTables = 0; 183 188 } 184 189 … … 186 191 void DelphesHtmlSummary::Reset(Option_t *) 187 192 { 188 // Reset (delete) the table list; 189 190 delete fObjTables; fObjTables = 0; 191 fNTables = 0; 193 // Reset (delete) the table list; 194 195 delete fObjTables; 196 fObjTables = 0; 197 fNTables = 0; 192 198 } 193 199 … … 195 201 void DelphesHtmlSummary::Build() 196 202 { 197 // Build the summary. 198 199 MakeHeader(); 200 for (int i=0;i<fNTables;i++) { 201 GetTable(i)->Build(); 202 fHtml += GetTable(i)->Html(); 203 } 204 MakeFooter(); 203 // Build the summary. 204 205 MakeHeader(); 206 for(int i = 0; i < fNTables; i++) 207 { 208 GetTable(i)->Build(); 209 fHtml += GetTable(i)->Html(); 210 } 211 MakeFooter(); 205 212 } 206 213 … … 208 215 void DelphesHtmlSummary::MakeHeader() 209 216 { 210 211 212 fHeader= "<html><head><title>";213 214 215 216 217 218 fHtml= fHeader;217 // Make HTML header. 218 219 fHeader = "<html><head><title>"; 220 fHeader += fTitle; 221 fHeader += "</title></head><body>"; 222 fHeader += "<center><h2><font color=#2222ee><i>"; 223 fHeader += fTitle; 224 fHeader += "</i></font></h2></center>"; 225 fHtml = fHeader; 219 226 } 220 227 … … 222 229 void DelphesHtmlSummary::MakeFooter() 223 230 { 224 // Make HTML footer. 225 226 fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>"; 227 fFooter += "Example of using Html widget to display tabular data"; 228 fFooter += "<br>"; 229 fFooter += "(c) 2007-2010 Bertrand Bellenot"; 230 fFooter += "</font></strong></center></body></html>"; 231 fHtml += fFooter; 232 } 233 231 // Make HTML footer. 232 233 fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>"; 234 fFooter += "Example of using Html widget to display tabular data"; 235 fFooter += "<br>"; 236 fFooter += "(c) 2007-2010 Bertrand Bellenot"; 237 fFooter += "</font></strong></center></body></html>"; 238 fHtml += fFooter; 239 } -
display/DelphesHtmlSummary.h
r45e58be r341014c 17 17 */ 18 18 19 // Delphes HTML table for the event display. 19 // Delphes HTML table for the event display. 20 20 // Based on the ROOT example "alice_esd_html_summary.C" 21 21 22 22 #ifndef DelphesHtmlSummary_h 23 #define DelphesHtmlSummary_h 23 #define DelphesHtmlSummary_h 24 24 25 25 #include "TArrayF.h" 26 26 #include "TOrdCollection.h" 27 27 28 class DelphesHtmlObjTable: public TObject 29 { 30 public: // make them public for shorter code 31 TString fName; 32 Int_t fNValues; // number of values 33 Int_t fNFields; // number of fields 34 TArrayF *fValues; 35 TString *fLabels; 36 Bool_t fExpand; 28 37 29 class DelphesHtmlObjTable : public TObject 30 { 31 public: // make them public for shorter code 38 TString fHtml; // HTML output code 32 39 33 TString fName; 34 Int_t fNValues; // number of values 35 Int_t fNFields; // number of fields 36 TArrayF *fValues; 37 TString *fLabels; 38 Bool_t fExpand; 39 40 TString fHtml; // HTML output code 41 42 void Build(); 43 void BuildTitle(); 44 void BuildLabels(); 45 void BuildTable(); 40 void Build(); 41 void BuildTitle(); 42 void BuildLabels(); 43 void BuildTable(); 46 44 47 45 public: 48 DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);49 46 DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp = kTRUE); 47 virtual ~DelphesHtmlObjTable(); 50 48 51 voidSetLabel(Int_t col, const char *label) { fLabels[col] = label; }52 voidSetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }53 TStringHtml() const { return fHtml; }49 void SetLabel(Int_t col, const char *label) { fLabels[col] = label; } 50 void SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); } 51 TString Html() const { return fHtml; } 54 52 55 53 ClassDef(DelphesHtmlObjTable, 0); 56 54 }; 57 55 … … 60 58 class DelphesHtmlSummary 61 59 { 62 public: 63 Int_tfNTables;64 TOrdCollection *fObjTables;// ->array of object tables65 TString fHtml;// output HTML string66 TString fTitle;// page title67 TString fHeader;// HTML header68 TString fFooter;// HTML footer60 public: // make them public for shorter code 61 Int_t fNTables; 62 TOrdCollection *fObjTables; // ->array of object tables 63 TString fHtml; // output HTML string 64 TString fTitle; // page title 65 TString fHeader; // HTML header 66 TString fFooter; // HTML footer 69 67 70 voidMakeHeader();71 voidMakeFooter();68 void MakeHeader(); 69 void MakeFooter(); 72 70 73 71 public: 74 75 72 DelphesHtmlSummary(const char *title); 73 virtual ~DelphesHtmlSummary(); 76 74 77 DelphesHtmlObjTable *AddTable(const char *name, Int_t nfields, Int_t nvals,78 Bool_t exp=kTRUE, Option_t *opt="");79 DelphesHtmlObjTable*GetTable(Int_t at) const { return (DelphesHtmlObjTable *)fObjTables->At(at); }80 voidBuild();81 void Clear(Option_t *option="");82 void Reset(Option_t *option="");83 TStringHtml() const { return fHtml; }75 DelphesHtmlObjTable *AddTable(const char *name, Int_t nfields, Int_t nvals, 76 Bool_t exp = kTRUE, Option_t *opt = ""); 77 DelphesHtmlObjTable *GetTable(Int_t at) const { return (DelphesHtmlObjTable *)fObjTables->At(at); } 78 void Build(); 79 void Clear(Option_t *option = ""); 80 void Reset(Option_t *option = ""); 81 TString Html() const { return fHtml; } 84 82 85 83 ClassDef(DelphesHtmlSummary, 0); 86 84 }; 87 85 -
display/DelphesPlotSummary.cc
r45e58be r341014c 21 21 #include <algorithm> 22 22 23 bool vecsorter (TLorentzVector i,TLorentzVector j) { return (i.Pt()>j.Pt()); } 24 25 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab):tab_(tab) {} 23 bool vecsorter(TLorentzVector i, TLorentzVector j) { return (i.Pt() > j.Pt()); } 24 25 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab *tab) : 26 tab_(tab) {} 26 27 27 28 DelphesPlotSummary::~DelphesPlotSummary() {} … … 29 30 void DelphesPlotSummary::Progress(Int_t p) 30 31 { 31 Emit("Progress(Int_t)",p); 32 } 33 34 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) { 32 Emit("Progress(Int_t)", p); 33 } 34 35 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase *> &elements) 36 { 35 37 elements_ = &elements; 36 38 // loop on the elements, and create tabs 37 for(std::vector<DelphesBranchBase*>::iterator data=elements.begin();data<elements.end();++data) { 39 for(std::vector<DelphesBranchBase *>::iterator data = elements.begin(); data < elements.end(); ++data) 40 { 38 41 // the canvas 39 TEveWindowSlot *slot = tab_->NewSlot();40 TRootEmbeddedCanvas *trec = new TRootEmbeddedCanvas();41 TCanvas *canvas = trec->GetCanvas();42 TEveWindowFrame * 42 TEveWindowSlot *slot = tab_->NewSlot(); 43 TRootEmbeddedCanvas *trec = new TRootEmbeddedCanvas(); 44 TCanvas *canvas = trec->GetCanvas(); 45 TEveWindowFrame *wf = slot->MakeFrame(trec); 43 46 wf->SetElementName((*data)->GetName()); 44 canvas->Divide(3, 3);47 canvas->Divide(3, 3); 45 48 canvases_[(*data)->GetName()] = canvas; 46 49 // the histograms 47 TH1F *h;48 std::vector<TH1F *> histograms;50 TH1F *h; 51 std::vector<TH1F *> histograms; 49 52 histograms.reserve(9); 50 h = new TH1F(Form("%sPt", (*data)->GetName()),Form("%s Pt",(*data)->GetName()),100,0,-1);51 histograms.push_back(h); 52 h = new TH1F(Form("%sEta", (*data)->GetName()),Form("%s Eta",(*data)->GetName()),100,0,-1);53 histograms.push_back(h); 54 h = new TH1F(Form("%sPhi", (*data)->GetName()),Form("%s Phi",(*data)->GetName()),100,0,-1);55 histograms.push_back(h); 56 h = new TH1F(Form("l%sPt", (*data)->GetName()),Form("leading %s Pt",(*data)->GetName()),100,0,-1);57 histograms.push_back(h); 58 h = new TH1F(Form("l%sEta", (*data)->GetName()),Form("leading %s Eta",(*data)->GetName()),100,0,-1);59 histograms.push_back(h); 60 h = new TH1F(Form("l%sPhi", (*data)->GetName()),Form("leading %s Phi",(*data)->GetName()),100,0,-1);61 histograms.push_back(h); 62 h = new TH1F(Form("sl%sPt", (*data)->GetName()),Form("subleading %s Pt",(*data)->GetName()),100,0,-1);63 histograms.push_back(h); 64 h = new TH1F(Form("sl%sEta", (*data)->GetName()),Form("subleading %s Eta",(*data)->GetName()),100,0,-1);65 histograms.push_back(h); 66 h = new TH1F(Form("sl%sPhi", (*data)->GetName()),Form("subleading %s Phi",(*data)->GetName()),100,0,-1);53 h = new TH1F(Form("%sPt", (*data)->GetName()), Form("%s Pt", (*data)->GetName()), 100, 0, -1); 54 histograms.push_back(h); 55 h = new TH1F(Form("%sEta", (*data)->GetName()), Form("%s Eta", (*data)->GetName()), 100, 0, -1); 56 histograms.push_back(h); 57 h = new TH1F(Form("%sPhi", (*data)->GetName()), Form("%s Phi", (*data)->GetName()), 100, 0, -1); 58 histograms.push_back(h); 59 h = new TH1F(Form("l%sPt", (*data)->GetName()), Form("leading %s Pt", (*data)->GetName()), 100, 0, -1); 60 histograms.push_back(h); 61 h = new TH1F(Form("l%sEta", (*data)->GetName()), Form("leading %s Eta", (*data)->GetName()), 100, 0, -1); 62 histograms.push_back(h); 63 h = new TH1F(Form("l%sPhi", (*data)->GetName()), Form("leading %s Phi", (*data)->GetName()), 100, 0, -1); 64 histograms.push_back(h); 65 h = new TH1F(Form("sl%sPt", (*data)->GetName()), Form("subleading %s Pt", (*data)->GetName()), 100, 0, -1); 66 histograms.push_back(h); 67 h = new TH1F(Form("sl%sEta", (*data)->GetName()), Form("subleading %s Eta", (*data)->GetName()), 100, 0, -1); 68 histograms.push_back(h); 69 h = new TH1F(Form("sl%sPhi", (*data)->GetName()), Form("subleading %s Phi", (*data)->GetName()), 100, 0, -1); 67 70 histograms.push_back(h); 68 71 histograms_[(*data)->GetName()] = histograms; 69 72 // the event histograms 70 TH1F* h1 = (TH1F*)histograms[0]->Clone(); h1->Reset(); h1->SetLineColor(kBlue); 71 TH1F* h2 = (TH1F*)histograms[1]->Clone(); h2->Reset(); h2->SetLineColor(kBlue); 72 TH1F* h3 = (TH1F*)histograms[2]->Clone(); h3->Reset(); h3->SetLineColor(kBlue); 73 std::vector<TH1F*> hv; 73 TH1F *h1 = (TH1F *)histograms[0]->Clone(); 74 h1->Reset(); 75 h1->SetLineColor(kBlue); 76 TH1F *h2 = (TH1F *)histograms[1]->Clone(); 77 h2->Reset(); 78 h2->SetLineColor(kBlue); 79 TH1F *h3 = (TH1F *)histograms[2]->Clone(); 80 h3->Reset(); 81 h3->SetLineColor(kBlue); 82 std::vector<TH1F *> hv; 74 83 hv.push_back(h1); 75 84 hv.push_back(h2); … … 78 87 // the event markers 79 88 TMarker *m; 80 std::vector<TMarker*> mv; 81 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 82 mv.push_back(m); 83 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 84 mv.push_back(m); 85 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 86 mv.push_back(m); 87 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 88 mv.push_back(m); 89 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 90 mv.push_back(m); 91 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 89 std::vector<TMarker *> mv; 90 m = new TMarker(0, 0, 29); 91 m->SetMarkerColor(kBlue); 92 m->SetMarkerSize(3); 93 mv.push_back(m); 94 m = new TMarker(0, 0, 29); 95 m->SetMarkerColor(kBlue); 96 m->SetMarkerSize(3); 97 mv.push_back(m); 98 m = new TMarker(0, 0, 29); 99 m->SetMarkerColor(kBlue); 100 m->SetMarkerSize(3); 101 mv.push_back(m); 102 m = new TMarker(0, 0, 29); 103 m->SetMarkerColor(kBlue); 104 m->SetMarkerSize(3); 105 mv.push_back(m); 106 m = new TMarker(0, 0, 29); 107 m->SetMarkerColor(kBlue); 108 m->SetMarkerSize(3); 109 mv.push_back(m); 110 m = new TMarker(0, 0, 29); 111 m->SetMarkerColor(kBlue); 112 m->SetMarkerSize(3); 92 113 mv.push_back(m); 93 114 eventMarkers_[(*data)->GetName()] = mv; … … 95 116 } 96 117 97 void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader, Int_t event_id) { 118 void DelphesPlotSummary::FillSample(ExRootTreeReader *treeReader, Int_t event_id) 119 { 98 120 Int_t entries = treeReader->GetEntries(); 99 for(Int_t i=0;i<entries;++i) { 121 for(Int_t i = 0; i < entries; ++i) 122 { 100 123 treeReader->ReadEntry(i); 101 for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) { 124 for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element) 125 { 102 126 std::vector<TLorentzVector> vectors = (*element)->GetVectors(); 103 std::sort(vectors.begin(), vectors.end(), vecsorter); 104 std::vector<TH1F*> histograms = histograms_[(*element)->GetName()]; 105 for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) { 127 std::sort(vectors.begin(), vectors.end(), vecsorter); 128 std::vector<TH1F *> histograms = histograms_[(*element)->GetName()]; 129 for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it) 130 { 106 131 histograms[0]->Fill(it->Pt()); 107 132 histograms[1]->Fill(it->Eta()); 108 133 histograms[2]->Fill(it->Phi()); 109 if(it==vectors.begin()) { 134 if(it == vectors.begin()) 135 { 110 136 histograms[3]->Fill(it->Pt()); 111 137 histograms[4]->Fill(it->Eta()); 112 138 histograms[5]->Fill(it->Phi()); 113 139 } 114 if(it==vectors.begin()+1) { 140 if(it == vectors.begin() + 1) 141 { 115 142 histograms[6]->Fill(it->Pt()); 116 143 histograms[7]->Fill(it->Eta()); … … 119 146 } 120 147 } 121 Progress(int(100 *i/entries));148 Progress(int(100 * i / entries)); 122 149 } 123 150 treeReader->ReadEntry(event_id); … … 125 152 } 126 153 127 void DelphesPlotSummary::Draw() { 128 for(std::map< TString, TCanvas* >::iterator it=canvases_.begin(); it!=canvases_.end(); ++it) { 129 TCanvas* c = it->second; 130 std::vector<TH1F*> histograms = histograms_[it->first]; 131 std::vector<TH1F*> eventProfiles = eventProfiles_[it->first]; 132 std::vector<TMarker*> eventMarkers = eventMarkers_[it->first]; 133 for(Int_t i=0;i<9;++i) { 134 c->cd(i+1); 135 if(histograms[i]->GetEntries()==0) continue; 154 void DelphesPlotSummary::Draw() 155 { 156 for(std::map<TString, TCanvas *>::iterator it = canvases_.begin(); it != canvases_.end(); ++it) 157 { 158 TCanvas *c = it->second; 159 std::vector<TH1F *> histograms = histograms_[it->first]; 160 std::vector<TH1F *> eventProfiles = eventProfiles_[it->first]; 161 std::vector<TMarker *> eventMarkers = eventMarkers_[it->first]; 162 for(Int_t i = 0; i < 9; ++i) 163 { 164 c->cd(i + 1); 165 if(histograms[i]->GetEntries() == 0) continue; 136 166 histograms[i]->Draw(); 137 if(i<3) { 167 if(i < 3) 168 { 138 169 eventProfiles[i]->Draw("same"); 139 } else { 140 eventMarkers[i-3]->Draw("same"); 170 } 171 else 172 { 173 eventMarkers[i - 3]->Draw("same"); 141 174 } 142 175 } 143 176 c->Update(); 144 } 145 } 146 147 void DelphesPlotSummary::FillEvent() { 177 } 178 } 179 180 void DelphesPlotSummary::FillEvent() 181 { 148 182 // clear event histograms and markers 149 for(std::map< TString, std::vector<TH1F*> >::iterator hv = eventProfiles_.begin(); hv!=eventProfiles_.end();++hv) { 150 for(std::vector<TH1F*>::iterator h = hv->second.begin(); h<hv->second.end();++h) { 183 for(std::map<TString, std::vector<TH1F *>>::iterator hv = eventProfiles_.begin(); hv != eventProfiles_.end(); ++hv) 184 { 185 for(std::vector<TH1F *>::iterator h = hv->second.begin(); h < hv->second.end(); ++h) 186 { 151 187 (*h)->Reset(); 152 188 } 153 189 } 154 for(std::map< TString, std::vector<TMarker*> >::iterator mv = eventMarkers_.begin(); mv!=eventMarkers_.end();++mv) { 155 for(std::vector<TMarker*>::iterator m = mv->second.begin(); m<mv->second.end();++m) { 190 for(std::map<TString, std::vector<TMarker *>>::iterator mv = eventMarkers_.begin(); mv != eventMarkers_.end(); ++mv) 191 { 192 for(std::vector<TMarker *>::iterator m = mv->second.begin(); m < mv->second.end(); ++m) 193 { 156 194 (*m)->SetMarkerSize(0); 157 195 } 158 196 } 159 197 // loop over the elements and fill markers with event data 160 for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) { 198 for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element) 199 { 161 200 std::vector<TLorentzVector> vectors = (*element)->GetVectors(); 162 std::sort(vectors.begin(), vectors.end(), vecsorter); 163 std::vector<TH1F*> hv = eventProfiles_[(*element)->GetName()]; 164 TH1F* h1 = hv[0]; h1->Reset(); 165 TH1F* h2 = hv[1]; h1->Reset(); 166 TH1F* h3 = hv[2]; h1->Reset(); 167 std::vector<TMarker*> mv = eventMarkers_[(*element)->GetName()]; 168 for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) { 201 std::sort(vectors.begin(), vectors.end(), vecsorter); 202 std::vector<TH1F *> hv = eventProfiles_[(*element)->GetName()]; 203 TH1F *h1 = hv[0]; 204 h1->Reset(); 205 TH1F *h2 = hv[1]; 206 h1->Reset(); 207 TH1F *h3 = hv[2]; 208 h1->Reset(); 209 std::vector<TMarker *> mv = eventMarkers_[(*element)->GetName()]; 210 for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it) 211 { 169 212 h1->Fill(it->Pt()); 170 213 h2->Fill(it->Eta()); 171 214 h3->Fill(it->Phi()); 172 if(it==vectors.begin()) { 173 mv[0]->SetX(it->Pt()); mv[0]->SetMarkerSize(3); 174 mv[1]->SetX(it->Eta()); mv[1]->SetMarkerSize(3); 175 mv[2]->SetX(it->Phi()); mv[2]->SetMarkerSize(3); 176 } 177 if(it==vectors.begin()+1) { 178 mv[3]->SetX(it->Pt()); mv[3]->SetMarkerSize(3); 179 mv[4]->SetX(it->Eta()); mv[4]->SetMarkerSize(3); 180 mv[5]->SetX(it->Phi()); mv[5]->SetMarkerSize(3); 181 } 182 } 183 } 184 } 215 if(it == vectors.begin()) 216 { 217 mv[0]->SetX(it->Pt()); 218 mv[0]->SetMarkerSize(3); 219 mv[1]->SetX(it->Eta()); 220 mv[1]->SetMarkerSize(3); 221 mv[2]->SetX(it->Phi()); 222 mv[2]->SetMarkerSize(3); 223 } 224 if(it == vectors.begin() + 1) 225 { 226 mv[3]->SetX(it->Pt()); 227 mv[3]->SetMarkerSize(3); 228 mv[4]->SetX(it->Eta()); 229 mv[4]->SetMarkerSize(3); 230 mv[5]->SetX(it->Phi()); 231 mv[5]->SetMarkerSize(3); 232 } 233 } 234 } 235 } -
display/DelphesPlotSummary.h
r45e58be r341014c 20 20 #define DelphesPlotSummary_h 21 21 22 #include <vector> 23 #include <map> 24 #include "TString.h" 25 #include "TH1F.h" 22 #include "DelphesBranchElement.h" 26 23 #include "TCanvas.h" 27 24 #include "TEveWindow.h" 28 #include "DelphesBranchElement.h" 25 #include "TH1F.h" 26 #include "TString.h" 29 27 #include "external/ExRootAnalysis/ExRootTreeReader.h" 30 28 #include <RQ_OBJECT.h> 31 29 #include <map> 30 #include <vector> 32 31 33 32 class DelphesPlotSummary 34 33 { 35 36 37 DelphesPlotSummary(TEveWindowTab*tab);38 39 void Init(std::vector<DelphesBranchBase*>&elements);40 void FillSample(ExRootTreeReader*treeReader, Int_t event_id);41 42 43 34 RQ_OBJECT("DelphesPlotSummary") 35 public: 36 DelphesPlotSummary(TEveWindowTab *tab); 37 virtual ~DelphesPlotSummary(); 38 void Init(std::vector<DelphesBranchBase *> &elements); 39 void FillSample(ExRootTreeReader *treeReader, Int_t event_id); 40 void FillEvent(); 41 void Draw(); 42 void Progress(Int_t); // *SIGNAL* 44 43 45 private: 46 TEveWindowTab* tab_; 47 std::map< TString, TCanvas* > canvases_; 48 std::map< TString, std::vector<TH1F*> > histograms_; 49 std::vector<DelphesBranchBase*>* elements_; 50 std::map< TString, std::vector<TMarker*> > eventMarkers_; 51 std::map< TString, std::vector<TH1F*> > eventProfiles_; 52 44 private: 45 TEveWindowTab *tab_; 46 std::map<TString, TCanvas *> canvases_; 47 std::map<TString, std::vector<TH1F *>> histograms_; 48 std::vector<DelphesBranchBase *> *elements_; 49 std::map<TString, std::vector<TMarker *>> eventMarkers_; 50 std::map<TString, std::vector<TH1F *>> eventProfiles_; 53 51 }; 54 52 55 53 #endif // DelphesPlotSummary_h 56
Note:
See TracChangeset
for help on using the changeset viewer.