[bf6ed57] | 1 | #include <set>
|
---|
| 2 | #include <map>
|
---|
| 3 | #include <utility>
|
---|
| 4 | #include <vector>
|
---|
[df634866] | 5 | #include <algorithm>
|
---|
[d2ac201] | 6 | #include <sstream>
|
---|
[bf6ed57] | 7 | #include "TGeoManager.h"
|
---|
| 8 | #include "TGeoVolume.h"
|
---|
| 9 | #include "TGeoMedium.h"
|
---|
| 10 | #include "TGeoNode.h"
|
---|
| 11 | #include "TGeoCompositeShape.h"
|
---|
| 12 | #include "TGeoMatrix.h"
|
---|
| 13 | #include "TGeoTube.h"
|
---|
| 14 | #include "TGeoCone.h"
|
---|
| 15 | #include "TGeoArb8.h"
|
---|
[e0c1ff0] | 16 | //#include "external/ExRootAnalysis/ExRootConfReader.h"
|
---|
| 17 | //#include "external/ExRootAnalysis/ExRootTreeReader.h"
|
---|
| 18 | //#include "display/DelphesCaloData.h"
|
---|
| 19 | //#include "display/DelphesDisplay.h"
|
---|
| 20 | //#include "classes/DelphesClasses.h"
|
---|
[bf6ed57] | 21 | #include "TF2.h"
|
---|
| 22 | #include "TH1F.h"
|
---|
[e0c1ff0] | 23 | #include "TChain.h"
|
---|
| 24 | #include "TEveElement.h"
|
---|
| 25 | #include "TEveJetCone.h"
|
---|
| 26 | #include "TEveTrack.h"
|
---|
| 27 | #include "TEveTrackPropagator.h"
|
---|
| 28 | #include "TEveCalo.h"
|
---|
[bf6ed57] | 29 | #include "TMath.h"
|
---|
| 30 | #include "TSystem.h"
|
---|
[e0c1ff0] | 31 | #include "TEveManager.h"
|
---|
| 32 | #include "TEveGeoNode.h"
|
---|
| 33 | #include "TEveTrans.h"
|
---|
| 34 | #include "TEveViewer.h"
|
---|
| 35 | #include "TEveBrowser.h"
|
---|
| 36 | #include "TRootBrowser.h"
|
---|
| 37 | #include "TGLViewer.h"
|
---|
| 38 | #include "TGButton.h"
|
---|
| 39 | #include "TCollection.h"
|
---|
| 40 | #include "TClonesArray.h"
|
---|
| 41 | #include "TGLClip.h"
|
---|
[bf6ed57] | 42 |
|
---|
[7f66dc0] | 43 | /*
|
---|
| 44 | * assembly.C: sauvegarde as shape-extract -> implement in the geometry class (read/write)
|
---|
| 45 | * histobrowser.C: intégration d'histogrammes dans le display (on pourrait avoir Pt, eta, phi pour les principales collections)
|
---|
| 46 | * also from alice_esd: summary html table
|
---|
| 47 | *
|
---|
| 48 | */
|
---|
[bf6ed57] | 49 | using namespace std;
|
---|
| 50 |
|
---|
[7f66dc0] | 51 | // Forward declarations.
|
---|
| 52 | class Delphes3DGeometry;
|
---|
| 53 | class ExRootTreeReader;
|
---|
| 54 | class DelphesCaloData;
|
---|
| 55 | class DelphesDisplay;
|
---|
| 56 | void make_gui();
|
---|
| 57 | void load_event();
|
---|
| 58 | void delphes_read();
|
---|
| 59 |
|
---|
| 60 | // Configuration and global variables.
|
---|
| 61 | Int_t event_id = 0; // Current event id.
|
---|
| 62 | Double_t gRadius = 1.29;
|
---|
[a844c07] | 63 | Double_t gTotRadius = 2.0;
|
---|
[7f66dc0] | 64 | Double_t gHalfLength = 3.0;
|
---|
| 65 | Double_t gBz = 3.8;
|
---|
| 66 |
|
---|
| 67 | TAxis *gEtaAxis = 0;
|
---|
| 68 | TAxis *gPhiAxis = 0;
|
---|
| 69 |
|
---|
| 70 | TChain gChain("Delphes");
|
---|
| 71 |
|
---|
| 72 | ExRootTreeReader *gTreeReader = 0;
|
---|
| 73 |
|
---|
| 74 | TClonesArray *gBranchTower = 0;
|
---|
| 75 | TClonesArray *gBranchTrack = 0;
|
---|
[a844c07] | 76 | TClonesArray *gBranchEle = 0;
|
---|
| 77 | TClonesArray *gBranchMuon = 0;
|
---|
| 78 | TClonesArray *gBranchPhoton = 0;
|
---|
[7f66dc0] | 79 | TClonesArray *gBranchJet = 0;
|
---|
[a844c07] | 80 | TClonesArray *gBranchGenJet = 0;
|
---|
[b4cd1e7] | 81 | TClonesArray *gBranchMet = 0;
|
---|
[7f66dc0] | 82 |
|
---|
| 83 | DelphesCaloData *gCaloData = 0;
|
---|
| 84 | TEveElementList *gJetList = 0;
|
---|
[a844c07] | 85 | TEveElementList *gGenJetList = 0;
|
---|
[b4cd1e7] | 86 | TEveArrow *gMet = 0;
|
---|
[7f66dc0] | 87 | TEveTrackList *gTrackList = 0;
|
---|
[a844c07] | 88 | TEveTrackList *gElectronList = 0;
|
---|
| 89 | TEveTrackList *gMuonList = 0;
|
---|
| 90 | TEveTrackList *gPhotonList = 0;
|
---|
[7f66dc0] | 91 |
|
---|
| 92 | DelphesDisplay *gDelphesDisplay = 0;
|
---|
| 93 |
|
---|
| 94 | /******************************************************************************/
|
---|
| 95 | // Construction of the geometry
|
---|
| 96 | /******************************************************************************/
|
---|
| 97 |
|
---|
[bf6ed57] | 98 | // TODO: asymmetric detector
|
---|
[7f66dc0] | 99 |
|
---|
[bf6ed57] | 100 | class Delphes3DGeometry {
|
---|
| 101 | public:
|
---|
| 102 | Delphes3DGeometry(TGeoManager *geom = NULL);
|
---|
| 103 | ~Delphes3DGeometry() {}
|
---|
| 104 |
|
---|
[a0b6d15] | 105 | void readFile(const char* filename, const char* ParticlePropagator="ParticlePropagator",
|
---|
| 106 | const char* TrackingEfficiency="ChargedHadronTrackingEfficiency",
|
---|
| 107 | const char* MuonEfficiency="MuonEfficiency",
|
---|
| 108 | const char* Calorimeters="Calorimeter");
|
---|
[bf6ed57] | 109 |
|
---|
[7513718] | 110 | void loadFromFile(const char* filename, const char* name="DelphesGeometry");
|
---|
| 111 | void save(const char* filename, const char* name="DelphesGeometry");
|
---|
| 112 |
|
---|
[bf6ed57] | 113 | void setContingency(Double_t contingency) { contingency_ = contingency; }
|
---|
| 114 | void setCaloBarrelThickness(Double_t thickness) { calo_barrel_thickness_ = thickness; }
|
---|
| 115 | void setCaloEndcapThickness(Double_t thickness) { calo_endcap_thickness_ = thickness; }
|
---|
| 116 | void setMuonSystemThickness(Double_t thickness) { muonSystem_thickn_ = thickness; }
|
---|
| 117 |
|
---|
| 118 | TGeoVolume* getDetector(bool withTowers = true);
|
---|
| 119 |
|
---|
[7513718] | 120 | Double_t getTrackerRadius() const { return tk_radius_; }
|
---|
[a844c07] | 121 | Double_t getDetectorRadius() const { return muonSystem_radius_; }
|
---|
[7513718] | 122 | Double_t getTrackerHalfLength() const { return tk_length_; }
|
---|
| 123 | Double_t getBField() const { return tk_Bz_; }
|
---|
| 124 | std::pair<TAxis*, TAxis*> getCaloAxes() { return std::make_pair(etaAxis_,phiAxis_); }
|
---|
| 125 |
|
---|
[bf6ed57] | 126 | private:
|
---|
[df634866] | 127 | std::pair<Double_t, Double_t> addTracker(TGeoVolume *top);
|
---|
| 128 | std::pair<Double_t, Double_t> addCalorimeter(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning);
|
---|
| 129 | std::pair<Double_t, Double_t> addMuonDets(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength);
|
---|
| 130 | void addCaloTowers(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning);
|
---|
[bf6ed57] | 131 |
|
---|
| 132 | private:
|
---|
| 133 |
|
---|
| 134 | TGeoManager *geom_;
|
---|
| 135 |
|
---|
| 136 | TGeoMedium *vacuum_;
|
---|
| 137 | TGeoMedium *tkmed_;
|
---|
| 138 | TGeoMedium *calomed_;
|
---|
| 139 | TGeoMedium *mudetmed_;
|
---|
| 140 |
|
---|
[7513718] | 141 | TAxis* etaAxis_;
|
---|
| 142 | TAxis* phiAxis_;
|
---|
| 143 |
|
---|
[bf6ed57] | 144 | Double_t contingency_;
|
---|
| 145 | Double_t calo_barrel_thickness_;
|
---|
| 146 | Double_t calo_endcap_thickness_;
|
---|
| 147 | Double_t muonSystem_thickn_;
|
---|
[a844c07] | 148 | Double_t muonSystem_radius_;
|
---|
[bf6ed57] | 149 | Double_t tk_radius_;
|
---|
| 150 | Double_t tk_length_;
|
---|
[a0b6d15] | 151 | Double_t tk_etamax_;
|
---|
[7513718] | 152 | Double_t tk_Bz_;
|
---|
[df634866] | 153 |
|
---|
| 154 | std::vector<std::string> calorimeters_;
|
---|
| 155 | std::vector<std::string> muondets_;
|
---|
| 156 |
|
---|
| 157 | std::map<std::string, Double_t> muonSystem_etamax_;
|
---|
| 158 | std::map<std::string, set< pair<Double_t, Int_t> > > caloBinning_;
|
---|
[bf6ed57] | 159 |
|
---|
| 160 | };
|
---|
| 161 |
|
---|
| 162 | Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom) {
|
---|
| 163 |
|
---|
| 164 | //--- the geometry manager
|
---|
| 165 | geom_ = geom==NULL? gGeoManager : geom;
|
---|
[e0c1ff0] | 166 | //gGeoManager->DefaultColors();
|
---|
[bf6ed57] | 167 |
|
---|
| 168 | //--- define some materials
|
---|
| 169 | TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
|
---|
| 170 | TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // placeholder
|
---|
[c4d879d] | 171 | //TODO: create different materials for different subdetectors???
|
---|
[493aa9b] | 172 | matVacuum->SetTransparency(85); //TODO: tune
|
---|
| 173 | matAl->SetTransparency(85); //TODO: tune
|
---|
[bf6ed57] | 174 |
|
---|
| 175 | //--- define some media
|
---|
| 176 | TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
|
---|
| 177 | TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);
|
---|
| 178 | vacuum_ = Vacuum;
|
---|
| 179 | tkmed_ = Vacuum; // placeholder
|
---|
| 180 | calomed_ = Al; // placeholder
|
---|
| 181 | mudetmed_ = Al; // placeholder
|
---|
| 182 |
|
---|
| 183 | // custom parameters
|
---|
| 184 | contingency_ = 10.;
|
---|
| 185 | calo_barrel_thickness_ = 50.;
|
---|
| 186 | calo_endcap_thickness_ = 75.;
|
---|
[df634866] | 187 | muonSystem_thickn_ = 10.;
|
---|
[bf6ed57] | 188 |
|
---|
| 189 | // read these parameters from the Delphes Card (with default values)
|
---|
[7513718] | 190 | etaAxis_ = NULL;
|
---|
| 191 | phiAxis_ = NULL;
|
---|
[bf6ed57] | 192 | tk_radius_ = 120.;
|
---|
| 193 | tk_length_ = 150.;
|
---|
[a0b6d15] | 194 | tk_etamax_ = 3.0;
|
---|
[7513718] | 195 | tk_Bz_ = 1.;
|
---|
[a844c07] | 196 | muonSystem_radius_ = 200.;
|
---|
[bf6ed57] | 197 | }
|
---|
| 198 |
|
---|
[a0b6d15] | 199 | void Delphes3DGeometry::readFile(const char *configFile,
|
---|
| 200 | const char* ParticlePropagator, const char* TrackingEfficiency,
|
---|
| 201 | const char* MuonEfficiency, const char* Calorimeters) {
|
---|
[bf6ed57] | 202 |
|
---|
| 203 | ExRootConfReader *confReader = new ExRootConfReader;
|
---|
| 204 | confReader->ReadFile(configFile);
|
---|
| 205 |
|
---|
[493aa9b] | 206 | tk_radius_ = confReader->GetDouble(Form("%s::Radius",ParticlePropagator), 1.0)*100.; // tk_radius
|
---|
| 207 | tk_length_ = confReader->GetDouble(Form("%s::HalfLength",ParticlePropagator), 3.0)*100.; // tk_length
|
---|
[7513718] | 208 | tk_Bz_ = confReader->GetDouble("ParticlePropagator::Bz", 0.0); // tk_Bz
|
---|
[bf6ed57] | 209 |
|
---|
[a0b6d15] | 210 | {
|
---|
| 211 | TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",TrackingEfficiency),"abs(eta)<3.0");
|
---|
| 212 | tkEffFormula.ReplaceAll("pt","x");
|
---|
| 213 | tkEffFormula.ReplaceAll("eta","y");
|
---|
| 214 | tkEffFormula.ReplaceAll("phi","0.");
|
---|
| 215 | TF2* tkEffFunction = new TF2("tkEff",tkEffFormula,0,1000,-10,10);
|
---|
| 216 | TH1F etaHisto("eta","eta",100,5.,-5.);
|
---|
| 217 | Double_t pt,eta;
|
---|
| 218 | for(int i=0;i<1000;++i) {
|
---|
| 219 | tkEffFunction->GetRandom2(pt,eta);
|
---|
| 220 | etaHisto.Fill(eta);
|
---|
| 221 | }
|
---|
| 222 | Int_t bin = -1;
|
---|
| 223 | bin = etaHisto.FindFirstBinAbove(0.5);
|
---|
| 224 | Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
|
---|
| 225 | bin = etaHisto.FindLastBinAbove(0.5);
|
---|
| 226 | Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
|
---|
| 227 | tk_etamax_ = TMath::Max(fabs(etamin),fabs(etamax)); // tk_etamax
|
---|
| 228 | delete tkEffFunction;
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | {
|
---|
[df634866] | 232 | muondets_.push_back("muons");
|
---|
[a0b6d15] | 233 | TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",MuonEfficiency),"abs(eta)<2.0");
|
---|
[bf6ed57] | 234 | muonEffFormula.ReplaceAll("pt","x");
|
---|
| 235 | muonEffFormula.ReplaceAll("eta","y");
|
---|
| 236 | muonEffFormula.ReplaceAll("phi","0.");
|
---|
| 237 | TF2* muEffFunction = new TF2("muEff",muonEffFormula,0,1000,-10,10);
|
---|
[a0b6d15] | 238 | TH1F etaHisto("eta2","eta2",100,5.,-5.);
|
---|
[bf6ed57] | 239 | Double_t pt,eta;
|
---|
| 240 | for(int i=0;i<1000;++i) {
|
---|
| 241 | muEffFunction->GetRandom2(pt,eta);
|
---|
| 242 | etaHisto.Fill(eta);
|
---|
| 243 | }
|
---|
| 244 | Int_t bin = -1;
|
---|
| 245 | bin = etaHisto.FindFirstBinAbove(0.5);
|
---|
| 246 | Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
|
---|
| 247 | bin = etaHisto.FindLastBinAbove(0.5);
|
---|
| 248 | Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
|
---|
[df634866] | 249 | muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin),fabs(etamax)); // muonSystem_etamax
|
---|
[bf6ed57] | 250 | delete muEffFunction;
|
---|
[a0b6d15] | 251 | }
|
---|
[df634866] | 252 |
|
---|
| 253 | std::string s(Calorimeters);
|
---|
| 254 | std::replace( s.begin(), s.end(), ',', ' ' );
|
---|
| 255 | std::istringstream stream( s );
|
---|
| 256 | std::string word;
|
---|
| 257 | while (stream >> word) calorimeters_.push_back(word);
|
---|
| 258 |
|
---|
[bf6ed57] | 259 | caloBinning_.clear(); // calo binning
|
---|
[df634866] | 260 | for(std::vector<std::string>::const_iterator calo=calorimeters_.begin();calo!=calorimeters_.end(); ++calo) {
|
---|
| 261 | set< pair<Double_t, Int_t> > caloBinning;
|
---|
| 262 | ExRootConfParam paramEtaBins, paramPhiBins;
|
---|
| 263 | ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",calo->c_str()));
|
---|
| 264 | Int_t size = param.GetSize();
|
---|
| 265 | for(int i = 0; i < size/2; ++i) {
|
---|
| 266 | paramEtaBins = param[i*2];
|
---|
| 267 | paramPhiBins = param[i*2+1];
|
---|
| 268 | assert(paramEtaBins.GetSize()==1);
|
---|
| 269 | caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(),paramPhiBins.GetSize()-1));
|
---|
| 270 | }
|
---|
| 271 | caloBinning_[*calo] = caloBinning;
|
---|
[bf6ed57] | 272 | }
|
---|
| 273 |
|
---|
[7513718] | 274 | set< pair<Double_t, Int_t> > caloBinning = caloBinning_[*calorimeters_.begin()];
|
---|
| 275 | Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo
|
---|
[e0c1ff0] | 276 | unsigned int ii = 0;
|
---|
[7513718] | 277 | for(set< pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) {
|
---|
[e0c1ff0] | 278 | etaBins[ii++] = itEtaSet->first;
|
---|
[7513718] | 279 | }
|
---|
| 280 | etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins);
|
---|
| 281 | 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
|
---|
| 282 |
|
---|
[a844c07] | 283 | muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_+calo_barrel_thickness_)*calorimeters_.size() + muonSystem_thickn_;
|
---|
| 284 |
|
---|
[bf6ed57] | 285 | delete confReader;
|
---|
| 286 |
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 | TGeoVolume* Delphes3DGeometry::getDetector(bool withTowers) {
|
---|
[1d42548] | 290 | // compute the envelope
|
---|
| 291 | Double_t system_radius = tk_radius_+calo_barrel_thickness_+3*contingency_;
|
---|
[df634866] | 292 | Double_t system_length = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size()+contingency_;
|
---|
[1d42548] | 293 | // the detector volume
|
---|
| 294 | TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length);
|
---|
| 295 | // build the detector
|
---|
[df634866] | 296 | std::pair<Double_t, Double_t> limits = addTracker(top);
|
---|
| 297 | Double_t radius = limits.first;
|
---|
| 298 | Double_t length = limits.second;
|
---|
| 299 | for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo) {
|
---|
| 300 | limits = addCalorimeter(top,calo->c_str(),radius,length,caloBinning_[*calo]);
|
---|
| 301 | if (withTowers) {
|
---|
| 302 | addCaloTowers(top,calo->c_str(),radius,length,caloBinning_[*calo]);
|
---|
| 303 | }
|
---|
| 304 | radius = limits.first;
|
---|
| 305 | length = limits.second;
|
---|
| 306 | }
|
---|
| 307 | for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon) {
|
---|
| 308 | limits = addMuonDets(top, muon->c_str(), radius, length);
|
---|
| 309 | radius = limits.first;
|
---|
| 310 | length = limits.second;
|
---|
[bf6ed57] | 311 | }
|
---|
[1d42548] | 312 | // return the result
|
---|
[bf6ed57] | 313 | return top;
|
---|
| 314 | }
|
---|
| 315 |
|
---|
[df634866] | 316 | std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top) {
|
---|
[1d42548] | 317 | // tracker: a cylinder with two cones substracted
|
---|
[d2ac201] | 318 | new TGeoCone("forwardTkAcceptance",(tk_length_/2.+0.05),0.,tk_radius_,(tk_length_)*2.*exp(-tk_etamax_)/(1-exp(-2.*tk_etamax_)),tk_radius_);
|
---|
[1d42548] | 319 | TGeoTranslation *tr1 = new TGeoTranslation("tkacc1",0., 0., tk_length_/2.);
|
---|
| 320 | tr1->RegisterYourself();
|
---|
| 321 | TGeoRotation *negz = new TGeoRotation("tknegz",0,180,0);
|
---|
| 322 | negz->RegisterYourself();
|
---|
| 323 | TGeoCombiTrans *tr2 = new TGeoCombiTrans("tkacc2",0.,0.,-tk_length_/2.,negz);
|
---|
| 324 | tr2->RegisterYourself();
|
---|
| 325 | TGeoCompositeShape* tracker_cs = new TGeoCompositeShape("tracker_cs","forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2");
|
---|
| 326 | TGeoVolume *tracker = new TGeoVolume("tracker",tracker_cs,tkmed_);
|
---|
[bf6ed57] | 327 | tracker->SetLineColor(kYellow);
|
---|
| 328 | top->AddNode(tracker,1);
|
---|
[df634866] | 329 | return std::make_pair(tk_radius_,tk_length_);
|
---|
[bf6ed57] | 330 | }
|
---|
| 331 |
|
---|
[df634866] | 332 | std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char* name,
|
---|
| 333 | Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
|
---|
| 334 | // parameters derived from the inputs
|
---|
| 335 | Double_t calo_endcap_etamax = TMath::Max(fabs(caloBinning.begin()->first),fabs(caloBinning.rbegin()->first));
|
---|
| 336 | Double_t calo_barrel_innerRadius = innerBarrelRadius+contingency_;
|
---|
| 337 | Double_t calo_barrel_length = innerBarrelLength + calo_barrel_thickness_;
|
---|
| 338 | Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength));
|
---|
| 339 | Double_t calo_endcap_innerRadius1 = innerBarrelLength*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
|
---|
| 340 | Double_t calo_endcap_innerRadius2 = (innerBarrelLength+calo_endcap_thickness_)*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
|
---|
| 341 | Double_t calo_endcap_outerRadius1 = innerBarrelRadius;
|
---|
| 342 | Double_t calo_endcap_outerRadius2 = innerBarrelRadius+calo_barrel_thickness_;
|
---|
| 343 | Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
|
---|
| 344 | Double_t calo_endcap_diskThickness = TMath::Max(0.,calo_endcap_thickness_-calo_endcap_coneThickness);
|
---|
| 345 |
|
---|
[bf6ed57] | 346 | // calorimeters: tube truncated in eta + cones
|
---|
[df634866] | 347 | new TGeoTube(Form("%s_barrel_cylinder",name),calo_barrel_innerRadius,calo_barrel_innerRadius+calo_barrel_thickness_,calo_barrel_length);
|
---|
| 348 | new TGeoCone(Form("%s_endcap_cone",name),calo_endcap_coneThickness/2.,calo_endcap_innerRadius1,calo_endcap_outerRadius1,calo_endcap_innerRadius2,calo_endcap_outerRadius2);
|
---|
| 349 | new TGeoTube(Form("%s_endcap_disk",name),calo_endcap_innerRadius2,tk_radius_+calo_barrel_thickness_,calo_endcap_diskThickness/2.);
|
---|
| 350 | TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1",name),0., 0., (calo_endcap_coneThickness+calo_endcap_diskThickness)/2.);
|
---|
[bf6ed57] | 351 | tr1->RegisterYourself();
|
---|
[df634866] | 352 | TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs",name),Form("%s_endcap_cone+%s_endcap_disk:%s_tr1",name,name,name));
|
---|
| 353 | TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.);
|
---|
[bf6ed57] | 354 | trc1->RegisterYourself();
|
---|
[df634866] | 355 | TGeoRotation *negz = new TGeoRotation(Form("%s_negz",name),0,180,0);
|
---|
| 356 | TGeoCombiTrans *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.),negz);
|
---|
[bf6ed57] | 357 | trc2->RegisterYourself();
|
---|
[df634866] | 358 | TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.+contingency_);
|
---|
[bf6ed57] | 359 | trc1c->RegisterYourself();
|
---|
[df634866] | 360 | TGeoCombiTrans *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.)-contingency_,negz);
|
---|
[bf6ed57] | 361 | trc2c->RegisterYourself();
|
---|
[df634866] | 362 | TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap",name),calo_endcap_cs,calomed_);
|
---|
| 363 | TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs",name),
|
---|
| 364 | Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position",name,name,name,name,name));
|
---|
| 365 | TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel",name),calo_barrel_cs,calomed_);
|
---|
[bf6ed57] | 366 | calo_endcap->SetLineColor(kViolet);
|
---|
| 367 | calo_endcap->SetFillColor(kViolet);
|
---|
| 368 | calo_barrel->SetLineColor(kRed);
|
---|
| 369 | top->AddNode(calo_endcap,1,trc1c);
|
---|
| 370 | top->AddNode(calo_endcap,2,trc2c);
|
---|
| 371 | top->AddNode(calo_barrel,1);
|
---|
[df634866] | 372 | return std::make_pair(calo_barrel_innerRadius+calo_barrel_thickness_,innerBarrelLength+calo_endcap_thickness_+contingency_);
|
---|
[bf6ed57] | 373 | }
|
---|
| 374 |
|
---|
[df634866] | 375 | std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength) {
|
---|
[bf6ed57] | 376 | // muon system: tube + disks
|
---|
[df634866] | 377 | Double_t muonSystem_radius = innerBarrelRadius + contingency_;
|
---|
| 378 | Double_t muonSystem_length = innerBarrelLength + contingency_;
|
---|
| 379 | Double_t muonSystem_rmin = muonSystem_length*2.*exp(-muonSystem_etamax_[name])/(1-exp(-2.*muonSystem_etamax_[name]));
|
---|
| 380 | TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel",name),mudetmed_,muonSystem_radius,muonSystem_radius+muonSystem_thickn_,muonSystem_length);
|
---|
[bf6ed57] | 381 | muon_barrel->SetLineColor(kBlue);
|
---|
| 382 | top->AddNode(muon_barrel,1);
|
---|
[df634866] | 383 | TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap",name),mudetmed_,muonSystem_rmin,muonSystem_radius+muonSystem_thickn_,muonSystem_thickn_/2.);
|
---|
[bf6ed57] | 384 | muon_endcap->SetLineColor(kBlue);
|
---|
[df634866] | 385 | TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position",name),0.,0.,muonSystem_length);
|
---|
[bf6ed57] | 386 | trm1->RegisterYourself();
|
---|
[df634866] | 387 | TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position",name),0.,0.,-muonSystem_length);
|
---|
[bf6ed57] | 388 | trm1->RegisterYourself();
|
---|
| 389 | top->AddNode(muon_endcap,1,trm1);
|
---|
[164f032] | 390 | top->AddNode(muon_endcap,2,trm2);
|
---|
[df634866] | 391 | return std::make_pair(muonSystem_radius,muonSystem_length);
|
---|
[bf6ed57] | 392 | }
|
---|
| 393 |
|
---|
[df634866] | 394 | void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char* name,
|
---|
| 395 | Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
|
---|
[bf6ed57] | 396 |
|
---|
[df634866] | 397 | TGeoVolume* calo_endcap = top->GetNode(Form("%s_endcap_1",name))->GetVolume();
|
---|
| 398 | TGeoVolume* calo_barrel = top->GetNode(Form("%s_barrel_1",name))->GetVolume();
|
---|
| 399 | Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength));
|
---|
| 400 | Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
|
---|
[bf6ed57] | 401 |
|
---|
| 402 | // calo towers in the barrel
|
---|
| 403 | Double_t vertices[16] = {0.,0.,0.,0.,0.,0.,0.,0.}; // summit of the pyramid
|
---|
[df634866] | 404 | Double_t R = tk_radius_ + contingency_+(contingency_+calo_barrel_thickness_)*calorimeters_.size(); // radius of the muons system = height of the pyramid
|
---|
| 405 | Int_t nEtaBins = caloBinning.size();
|
---|
[bf6ed57] | 406 | // this rotation is to make the tower point "up"
|
---|
[df634866] | 407 | TGeoRotation* initTowerRot = new TGeoRotation(Form("%s_initTowerRot",name),0.,90.,0.);
|
---|
| 408 | TGeoCombiTrans* initTower = new TGeoCombiTrans(Form("%s_initTower",name),0.,-R/2.,0.,initTowerRot);
|
---|
[bf6ed57] | 409 | initTower->RegisterYourself();
|
---|
| 410 | // eta bins... we build one pyramid per eta slice and then translate it nphi times.
|
---|
| 411 | // phi bins represented by rotations around z
|
---|
| 412 | Double_t *y = new Double_t[nEtaBins];
|
---|
| 413 | Double_t *dx = new Double_t[nEtaBins];
|
---|
| 414 | Int_t *nphi = new Int_t[nEtaBins];
|
---|
| 415 | Int_t etaslice = 0;
|
---|
| 416 | std::map<std::pair<int,int>, TGeoRotation*> phirotations;
|
---|
[df634866] | 417 | for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
|
---|
| 418 | if(abs(bin->first)>calo_endcap_etamin) continue; // only in the barrel
|
---|
[bf6ed57] | 419 | nphi[etaslice] = bin->second;
|
---|
| 420 | y[etaslice] = 0.5*R*(1-exp(-2*bin->first))/exp(-bin->first);
|
---|
| 421 | Double_t phiRotationAngle = 360./nphi[etaslice];
|
---|
| 422 | dx[etaslice] = R*tan(TMath::Pi()*phiRotationAngle/360.);
|
---|
| 423 | for(int phislice=0;phislice<nphi[etaslice];++phislice) {
|
---|
[df634866] | 424 | phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
|
---|
[bf6ed57] | 425 | phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
|
---|
| 426 | }
|
---|
| 427 | ++etaslice;
|
---|
| 428 | }
|
---|
[d2ac201] | 429 | nEtaBins = etaslice;
|
---|
[bf6ed57] | 430 | for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
|
---|
| 431 | vertices[8] = -dx[i]; vertices[9] = y[i];
|
---|
| 432 | vertices[10] = -dx[i]; vertices[11] = y[i+1];
|
---|
| 433 | vertices[12] = dx[i]; vertices[13] = y[i+1];
|
---|
| 434 | vertices[14] = dx[i]; vertices[15] = y[i];
|
---|
[df634866] | 435 | new TGeoArb8(Form("%s_tower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
|
---|
[bf6ed57] | 436 | // intersection between the tower and the calo_barrel
|
---|
[df634866] | 437 | 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));
|
---|
| 438 | TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d",name,i),finaltower_cs,calomed_);
|
---|
[bf6ed57] | 439 | finaltower->SetLineColor(kRed);
|
---|
| 440 | for(int j=0;j<nphi[i];++j) { // loop on the phi slices
|
---|
| 441 | calo_barrel->AddNode(finaltower,j,phirotations[make_pair(i,j)]);
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
| 444 | delete[] y;
|
---|
| 445 | delete[] dx;
|
---|
| 446 | delete[] nphi;
|
---|
| 447 | //the towers in the forward region
|
---|
[df634866] | 448 | R = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size(); // Z of the muons system = height of the pyramid
|
---|
| 449 | nEtaBins = caloBinning.size();
|
---|
| 450 | // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place)
|
---|
| 451 | TGeoTranslation* towerdz = new TGeoTranslation(Form("%s_towerdz",name),0.,0.,R/2.-(innerBarrelLength+calo_endcap_coneThickness/2.));
|
---|
[bf6ed57] | 452 | towerdz->RegisterYourself();
|
---|
| 453 | // eta bins... we build one pyramid per eta slice and then translate it nphi times.
|
---|
| 454 | Double_t *r = new Double_t[nEtaBins];
|
---|
| 455 | nphi = new Int_t[nEtaBins];
|
---|
| 456 | etaslice = 0;
|
---|
| 457 | phirotations.clear();
|
---|
[df634866] | 458 | for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
|
---|
| 459 | if(bin->first<calo_endcap_etamin) continue; // only in the + endcap
|
---|
[bf6ed57] | 460 | r[etaslice] = R*2*exp(-bin->first)/(1-exp(-2*bin->first));
|
---|
| 461 | nphi[etaslice] = bin->second;
|
---|
| 462 | Double_t phiRotationAngle = 360./nphi[etaslice];
|
---|
| 463 | for(int phislice=0;phislice<nphi[etaslice];++phislice) {
|
---|
[df634866] | 464 | phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
|
---|
[bf6ed57] | 465 | phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
|
---|
| 466 | }
|
---|
| 467 | ++etaslice;
|
---|
| 468 | }
|
---|
| 469 | nEtaBins = etaslice;
|
---|
[d2ac201] | 470 | for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
|
---|
| 471 | vertices[8] = -r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[9] = r[i+1]*cos(TMath::Pi()/nphi[i]);
|
---|
| 472 | vertices[10] = -r[i]*sin(TMath::Pi()/nphi[i]); vertices[11] = r[i]*cos(TMath::Pi()/nphi[i]);
|
---|
| 473 | vertices[12] = r[i]*sin(TMath::Pi()/nphi[i]); vertices[13] = r[i]*cos(TMath::Pi()/nphi[i]);
|
---|
| 474 | vertices[14] = r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[15] = r[i+1]*cos(TMath::Pi()/nphi[i]);
|
---|
[df634866] | 475 | new TGeoArb8(Form("%sfwdtower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
|
---|
[bf6ed57] | 476 | // intersection between the tower and the calo_endcap
|
---|
[df634866] | 477 | TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs",name,i),Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs",name,i,name,name));
|
---|
| 478 | TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d",name,i),finalfwdtower_cs,calomed_);
|
---|
[bf6ed57] | 479 | finalfwdtower->SetLineColor(kViolet);
|
---|
| 480 | for(int j=0;j<nphi[i];++j) { // loop on the phi slices
|
---|
| 481 | calo_endcap->AddNode(finalfwdtower,j,phirotations[make_pair(i,j)]);
|
---|
| 482 | }
|
---|
| 483 | }
|
---|
| 484 | delete[] r;
|
---|
| 485 | delete[] nphi;
|
---|
| 486 | }
|
---|
| 487 |
|
---|
[7f66dc0] | 488 | /******************************************************************************/
|
---|
| 489 | // Initialization and steering functions
|
---|
| 490 | /******************************************************************************/
|
---|
| 491 |
|
---|
[c4d879d] | 492 | void delphes_event_display(const char *configFile, const char *inputFile, const Delphes3DGeometry& det3D)
|
---|
[7f66dc0] | 493 | {
|
---|
| 494 |
|
---|
[7513718] | 495 | // initialize the application
|
---|
| 496 | TEveManager::Create(kTRUE, "IV");
|
---|
[c4d879d] | 497 | TGeoManager* geom = gGeoManager;
|
---|
[7f66dc0] | 498 |
|
---|
[7513718] | 499 | // build the detector
|
---|
| 500 | gRadius = det3D.getTrackerRadius();
|
---|
[a844c07] | 501 | gTotRadius = det3D.getDetectorRadius();
|
---|
[7513718] | 502 | gHalfLength = det3D.getTrackerHalfLength();
|
---|
| 503 | gBz = det3D.getBField();
|
---|
| 504 | gEtaAxis = det3D.getCaloAxes().first;
|
---|
| 505 | gPhiAxis = det3D.getCaloAxes().second;
|
---|
[493aa9b] | 506 |
|
---|
| 507 | TGeoVolume* top = det3D.getDetector(false); //TODO: can this be set in the GUI?
|
---|
| 508 | geom->SetTopVolume(top);
|
---|
[7513718] | 509 | TEveElementList *geometry = new TEveElementList("Geometry");
|
---|
| 510 | TEveGeoTopNode* trk = new TEveGeoTopNode(gGeoManager, top->FindNode("tracker_1"));
|
---|
| 511 | trk->SetVisLevel(6);
|
---|
| 512 | geometry->AddElement(trk);
|
---|
| 513 | TEveGeoTopNode* calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_barrel_1"));
|
---|
| 514 | calo->SetVisLevel(3);
|
---|
| 515 | geometry->AddElement(calo);
|
---|
| 516 | calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_1"));
|
---|
| 517 | calo->SetVisLevel(3);
|
---|
| 518 | calo->UseNodeTrans();
|
---|
| 519 | geometry->AddElement(calo);
|
---|
| 520 | calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_2"));
|
---|
| 521 | calo->SetVisLevel(3);
|
---|
| 522 | calo->UseNodeTrans();
|
---|
| 523 | geometry->AddElement(calo);
|
---|
| 524 | TEveGeoTopNode* muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_barrel_1"));
|
---|
| 525 | muon->SetVisLevel(4);
|
---|
| 526 | geometry->AddElement(muon);
|
---|
| 527 | muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_1"));
|
---|
| 528 | muon->SetVisLevel(4);
|
---|
| 529 | muon->UseNodeTrans();
|
---|
| 530 | geometry->AddElement(muon);
|
---|
| 531 | muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_2"));
|
---|
| 532 | muon->SetVisLevel(4);
|
---|
| 533 | muon->UseNodeTrans();
|
---|
| 534 | geometry->AddElement(muon);
|
---|
[493aa9b] | 535 | //gGeoManager->DefaultColors();
|
---|
[7513718] | 536 |
|
---|
| 537 | // Create chain of root trees
|
---|
| 538 | gChain.Add(inputFile);
|
---|
| 539 |
|
---|
| 540 | // Create object of class ExRootTreeReader
|
---|
[7f66dc0] | 541 | printf("*** Opening Delphes data file ***\n");
|
---|
[7513718] | 542 | gTreeReader = new ExRootTreeReader(&gChain);
|
---|
[7f66dc0] | 543 |
|
---|
[7513718] | 544 | // Get pointers to branches
|
---|
| 545 | //TODO make it configurable, for more objects (or can we guess from the config?)
|
---|
[a844c07] | 546 | gBranchTower = gTreeReader->UseBranch("Tower");
|
---|
| 547 | gBranchTrack = gTreeReader->UseBranch("Track");
|
---|
| 548 | gBranchEle = gTreeReader->UseBranch("Electron");
|
---|
| 549 | gBranchMuon = gTreeReader->UseBranch("Muon");
|
---|
| 550 | gBranchPhoton = gTreeReader->UseBranch("Photon");
|
---|
| 551 | gBranchJet = gTreeReader->UseBranch("Jet");
|
---|
| 552 | gBranchGenJet = gTreeReader->UseBranch("GenJet");
|
---|
| 553 | gBranchMet = gTreeReader->UseBranch("MissingET");
|
---|
[7f66dc0] | 554 |
|
---|
[7513718] | 555 | // data
|
---|
| 556 | gCaloData = new DelphesCaloData(2);
|
---|
| 557 | gCaloData->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
|
---|
| 558 | gCaloData->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
|
---|
| 559 | gCaloData->SetEtaBins(gEtaAxis);
|
---|
| 560 | gCaloData->SetPhiBins(gPhiAxis);
|
---|
| 561 | gCaloData->IncDenyDestroy();
|
---|
| 562 |
|
---|
| 563 | gJetList = new TEveElementList("Jets");
|
---|
[a844c07] | 564 | gJetList->SetMainColor(kYellow);
|
---|
[7513718] | 565 | gEve->AddElement(gJetList);
|
---|
| 566 |
|
---|
[a844c07] | 567 | gGenJetList = new TEveElementList("GenJets");
|
---|
| 568 | gGenJetList->SetMainColor(kCyan);
|
---|
| 569 | gGenJetList->SetRnrSelf(false);
|
---|
| 570 | gGenJetList->SetRnrChildren(false);
|
---|
| 571 | gEve->AddElement(gGenJetList);
|
---|
| 572 |
|
---|
[b4cd1e7] | 573 | gMet = new TEveArrow(1., 0., 0., 0., 0., 0.);
|
---|
| 574 | gMet->SetMainColor(kViolet);
|
---|
| 575 | gMet->SetTubeR(0.02);
|
---|
| 576 | gMet->SetPickable(kTRUE);
|
---|
| 577 | gMet->SetName("Missing Et");
|
---|
| 578 | gEve->GetCurrentEvent()->AddElement(gMet);
|
---|
| 579 |
|
---|
[a844c07] | 580 | TEveTrackPropagator *trkProp;
|
---|
| 581 |
|
---|
| 582 | gElectronList = new TEveTrackList("Electrons");
|
---|
| 583 | gElectronList->SetMainColor(kRed);
|
---|
| 584 | gElectronList->SetMarkerColor(kViolet);
|
---|
| 585 | gElectronList->SetMarkerStyle(kCircle);
|
---|
| 586 | gElectronList->SetMarkerSize(0.5);
|
---|
| 587 | gEve->AddElement(gElectronList);
|
---|
| 588 | trkProp = gElectronList->GetPropagator();
|
---|
| 589 | trkProp->SetMagField(0.0, 0.0, -gBz);
|
---|
| 590 | trkProp->SetMaxR(gRadius);
|
---|
| 591 | trkProp->SetMaxZ(gHalfLength);
|
---|
| 592 |
|
---|
| 593 | gMuonList = new TEveTrackList("Muons");
|
---|
| 594 | gMuonList->SetMainColor(kGreen);
|
---|
| 595 | gMuonList->SetMarkerColor(kViolet);
|
---|
| 596 | gMuonList->SetMarkerStyle(kCircle);
|
---|
| 597 | gMuonList->SetMarkerSize(0.5);
|
---|
| 598 | gEve->AddElement(gMuonList);
|
---|
| 599 | trkProp = gMuonList->GetPropagator();
|
---|
| 600 | trkProp->SetMagField(0.0, 0.0, -gBz);
|
---|
| 601 | trkProp->SetMaxR(gTotRadius);
|
---|
| 602 | trkProp->SetMaxZ(gHalfLength);
|
---|
| 603 |
|
---|
[7513718] | 604 | gTrackList = new TEveTrackList("Tracks");
|
---|
| 605 | gTrackList->SetMainColor(kBlue);
|
---|
| 606 | gTrackList->SetMarkerColor(kRed);
|
---|
| 607 | gTrackList->SetMarkerStyle(kCircle);
|
---|
| 608 | gTrackList->SetMarkerSize(0.5);
|
---|
| 609 | gEve->AddElement(gTrackList);
|
---|
[a844c07] | 610 | trkProp = gTrackList->GetPropagator();
|
---|
[7513718] | 611 | trkProp->SetMagField(0.0, 0.0, -gBz);
|
---|
[493aa9b] | 612 | trkProp->SetMaxR(gRadius);
|
---|
| 613 | trkProp->SetMaxZ(gHalfLength);
|
---|
[7513718] | 614 |
|
---|
[a844c07] | 615 | gPhotonList= new TEveTrackList("Photons");
|
---|
| 616 | gPhotonList->SetMainColor(kYellow);
|
---|
| 617 | gPhotonList->SetLineStyle(7);
|
---|
| 618 | gPhotonList->SetMarkerColor(kViolet);
|
---|
| 619 | gPhotonList->SetMarkerStyle(kCircle);
|
---|
| 620 | gPhotonList->SetMarkerSize(0.5);
|
---|
| 621 | gEve->AddElement(gPhotonList);
|
---|
| 622 | trkProp = gPhotonList->GetPropagator();
|
---|
| 623 | trkProp->SetMagField(0.0, 0.0, 0.0);
|
---|
| 624 | trkProp->SetMaxR(gRadius);
|
---|
| 625 | trkProp->SetMaxZ(gHalfLength);
|
---|
| 626 |
|
---|
[7513718] | 627 | // viewers and scenes
|
---|
| 628 |
|
---|
[e0c1ff0] | 629 | TEveCalo3D *calo3d = new TEveCalo3D(gCaloData);
|
---|
[493aa9b] | 630 | calo3d->SetBarrelRadius(gRadius);
|
---|
| 631 | calo3d->SetEndCapPos(gHalfLength);
|
---|
[7513718] | 632 |
|
---|
[e0c1ff0] | 633 | //gStyle->SetPalette(1, 0);
|
---|
[7513718] | 634 | TEveCaloLego *lego = new TEveCaloLego(gCaloData);
|
---|
| 635 | lego->InitMainTrans();
|
---|
| 636 | lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
|
---|
| 637 | lego->SetAutoRebin(kFALSE);
|
---|
| 638 | lego->Set2DMode(TEveCaloLego::kValSizeOutline);
|
---|
| 639 |
|
---|
| 640 | gDelphesDisplay = new DelphesDisplay;
|
---|
| 641 | gEve->AddGlobalElement(geometry);
|
---|
[e0c1ff0] | 642 | gEve->AddGlobalElement(calo3d);
|
---|
[7513718] | 643 | gDelphesDisplay->ImportGeomRPhi(geometry);
|
---|
[e0c1ff0] | 644 | gDelphesDisplay->ImportCaloRPhi(calo3d);
|
---|
[7513718] | 645 | gDelphesDisplay->ImportGeomRhoZ(geometry);
|
---|
[e0c1ff0] | 646 | gDelphesDisplay->ImportCaloRhoZ(calo3d);
|
---|
[7513718] | 647 | gDelphesDisplay->ImportCaloLego(lego);
|
---|
| 648 | gEve->Redraw3D(kTRUE);
|
---|
[7f66dc0] | 649 |
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 | //______________________________________________________________________________
|
---|
| 653 | void load_event()
|
---|
| 654 | {
|
---|
| 655 | // Load event specified in global event_id.
|
---|
| 656 | // The contents of previous event are removed.
|
---|
| 657 |
|
---|
| 658 | printf("Loading event %d.\n", event_id);
|
---|
| 659 |
|
---|
| 660 | gEve->GetViewers()->DeleteAnnotations();
|
---|
| 661 |
|
---|
| 662 | if(gCaloData) gCaloData->ClearTowers();
|
---|
| 663 | if(gJetList) gJetList->DestroyElements();
|
---|
[a844c07] | 664 | if(gGenJetList) gGenJetList->DestroyElements();
|
---|
[7f66dc0] | 665 | if(gTrackList) gTrackList->DestroyElements();
|
---|
[a844c07] | 666 | if(gElectronList) gElectronList->DestroyElements();
|
---|
| 667 | if(gMuonList) gMuonList->DestroyElements();
|
---|
| 668 | if(gPhotonList) gPhotonList->DestroyElements();
|
---|
[7f66dc0] | 669 |
|
---|
| 670 | delphes_read();
|
---|
| 671 |
|
---|
[e0c1ff0] | 672 | TEveElement* top = (TEveElement*)gEve->GetCurrentEvent();
|
---|
[7f66dc0] | 673 | gDelphesDisplay->DestroyEventRPhi();
|
---|
| 674 | gDelphesDisplay->ImportEventRPhi(top);
|
---|
| 675 | gDelphesDisplay->DestroyEventRhoZ();
|
---|
| 676 | gDelphesDisplay->ImportEventRhoZ(top);
|
---|
| 677 |
|
---|
| 678 | //update_html_summary();
|
---|
| 679 |
|
---|
| 680 | gEve->Redraw3D(kFALSE, kTRUE);
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | void delphes_read()
|
---|
| 684 | {
|
---|
| 685 |
|
---|
| 686 | TIter itTower(gBranchTower);
|
---|
| 687 | TIter itTrack(gBranchTrack);
|
---|
[a844c07] | 688 | TIter itElectron(gBranchEle);
|
---|
| 689 | TIter itPhoton(gBranchPhoton);
|
---|
| 690 | TIter itMuon(gBranchMuon);
|
---|
[7f66dc0] | 691 | TIter itJet(gBranchJet);
|
---|
[a844c07] | 692 | TIter itGenJet(gBranchGenJet);
|
---|
[b4cd1e7] | 693 | TIter itMet(gBranchMet);
|
---|
[7f66dc0] | 694 |
|
---|
| 695 | Tower *tower;
|
---|
| 696 | Track *track;
|
---|
[a844c07] | 697 | Electron *electron;
|
---|
| 698 | Muon *muon;
|
---|
| 699 | Photon *photon;
|
---|
[7f66dc0] | 700 | Jet *jet;
|
---|
[b4cd1e7] | 701 | MissingET *MET;
|
---|
[7f66dc0] | 702 |
|
---|
| 703 | TEveJetCone *eveJetCone;
|
---|
| 704 | TEveTrack *eveTrack;
|
---|
| 705 |
|
---|
| 706 | Int_t counter;
|
---|
[b4cd1e7] | 707 | Float_t maxPt = 0.;
|
---|
[7f66dc0] | 708 |
|
---|
| 709 | TEveTrackPropagator *trkProp = gTrackList->GetPropagator();
|
---|
[a844c07] | 710 | TEveTrackPropagator *photProp = gPhotonList->GetPropagator();
|
---|
[e0c1ff0] | 711 | if(event_id >= gTreeReader->GetEntries()) return;
|
---|
[7f66dc0] | 712 |
|
---|
| 713 | // Load selected branches with data from specified event
|
---|
| 714 | gTreeReader->ReadEntry(event_id);
|
---|
[a844c07] | 715 |
|
---|
[7f66dc0] | 716 | // Loop over all towers
|
---|
| 717 | itTower.Reset();
|
---|
| 718 | while((tower = (Tower *) itTower.Next()))
|
---|
| 719 | {
|
---|
| 720 | gCaloData->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
|
---|
| 721 | gCaloData->FillSlice(0, tower->Eem);
|
---|
| 722 | gCaloData->FillSlice(1, tower->Ehad);
|
---|
| 723 | }
|
---|
| 724 | gCaloData->DataChanged();
|
---|
[a844c07] | 725 |
|
---|
[7f66dc0] | 726 | // Loop over all tracks
|
---|
| 727 | itTrack.Reset();
|
---|
| 728 | counter = 0;
|
---|
[a844c07] | 729 | while((track = (Track *) itTrack.Next())) {
|
---|
[7f66dc0] | 730 | TParticle pb(track->PID, 1, 0, 0, 0, 0,
|
---|
| 731 | track->P4().Px(), track->P4().Py(),
|
---|
| 732 | track->P4().Pz(), track->P4().E(),
|
---|
| 733 | track->X, track->Y, track->Z, 0.0);
|
---|
| 734 |
|
---|
| 735 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 736 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 737 | eveTrack->SetStdTitle();
|
---|
| 738 | eveTrack->SetAttLineAttMarker(gTrackList);
|
---|
| 739 | gTrackList->AddElement(eveTrack);
|
---|
[a844c07] | 740 | eveTrack->SetLineColor(kBlue);
|
---|
[7f66dc0] | 741 | eveTrack->MakeTrack();
|
---|
[b4cd1e7] | 742 | maxPt = maxPt > track->PT ? maxPt : track->PT;
|
---|
[7f66dc0] | 743 | }
|
---|
[a844c07] | 744 |
|
---|
| 745 | // Loop over all electrons
|
---|
| 746 | itElectron.Reset();
|
---|
| 747 | counter = 0;
|
---|
| 748 | while((electron = (Electron *) itElectron.Next())) {
|
---|
| 749 | TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
|
---|
| 750 | electron->P4().Px(), electron->P4().Py(),
|
---|
| 751 | electron->P4().Pz(), electron->P4().E(),
|
---|
| 752 | 0., 0., 0., 0.);
|
---|
| 753 |
|
---|
| 754 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 755 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 756 | eveTrack->SetStdTitle();
|
---|
| 757 | eveTrack->SetAttLineAttMarker(gElectronList);
|
---|
| 758 | gElectronList->AddElement(eveTrack);
|
---|
| 759 | eveTrack->SetLineColor(kRed);
|
---|
| 760 | eveTrack->MakeTrack();
|
---|
| 761 | maxPt = maxPt > electron->PT ? maxPt : electron->PT;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | // Loop over all photons
|
---|
| 765 | itPhoton.Reset();
|
---|
| 766 | counter = 0;
|
---|
| 767 | while((photon = (Photon *) itPhoton.Next())) {
|
---|
| 768 | TParticle pb(22, 1, 0, 0, 0, 0,
|
---|
| 769 | photon->P4().Px(), photon->P4().Py(),
|
---|
| 770 | photon->P4().Pz(), photon->P4().E(),
|
---|
| 771 | 0., 0., 0., 0.);
|
---|
| 772 |
|
---|
| 773 | eveTrack = new TEveTrack(&pb, counter, photProp);
|
---|
| 774 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 775 | eveTrack->SetStdTitle();
|
---|
| 776 | eveTrack->SetAttLineAttMarker(gPhotonList);
|
---|
| 777 | gPhotonList->AddElement(eveTrack);
|
---|
| 778 | eveTrack->SetLineColor(kYellow);
|
---|
| 779 | eveTrack->MakeTrack();
|
---|
| 780 | maxPt = maxPt > photon->PT ? maxPt : photon->PT;
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 | // Loop over all muons
|
---|
| 784 | itMuon.Reset();
|
---|
| 785 | counter = 0;
|
---|
| 786 | while((muon = (Muon *) itMuon.Next())) {
|
---|
| 787 | TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
|
---|
| 788 | muon->P4().Px(), muon->P4().Py(),
|
---|
| 789 | muon->P4().Pz(), muon->P4().E(),
|
---|
| 790 | 0., 0., 0., 0.);
|
---|
| 791 |
|
---|
| 792 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 793 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 794 | eveTrack->SetStdTitle();
|
---|
| 795 | eveTrack->SetAttLineAttMarker(gMuonList);
|
---|
| 796 | gMuonList->AddElement(eveTrack);
|
---|
| 797 | eveTrack->SetLineColor(kGreen);
|
---|
| 798 | eveTrack->MakeTrack();
|
---|
| 799 | maxPt = maxPt > muon->PT ? maxPt : muon->PT;
|
---|
| 800 | }
|
---|
| 801 |
|
---|
[7f66dc0] | 802 | // Loop over all jets
|
---|
| 803 | itJet.Reset();
|
---|
| 804 | counter = 0;
|
---|
| 805 | while((jet = (Jet *) itJet.Next()))
|
---|
| 806 | {
|
---|
| 807 | eveJetCone = new TEveJetCone();
|
---|
[a844c07] | 808 | eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
|
---|
[7f66dc0] | 809 | eveJetCone->SetName(Form("jet [%d]", counter++));
|
---|
| 810 | eveJetCone->SetMainTransparency(60);
|
---|
| 811 | eveJetCone->SetLineColor(kYellow);
|
---|
[a844c07] | 812 | eveJetCone->SetFillColor(kYellow);
|
---|
[493aa9b] | 813 | eveJetCone->SetCylinder(gRadius - 10, gHalfLength - 10);
|
---|
[7f66dc0] | 814 | eveJetCone->SetPickable(kTRUE);
|
---|
| 815 | eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
|
---|
| 816 | gJetList->AddElement(eveJetCone);
|
---|
[b4cd1e7] | 817 | maxPt = maxPt > jet->PT ? maxPt : jet->PT;
|
---|
| 818 | }
|
---|
| 819 |
|
---|
[a844c07] | 820 | // Loop over all genjets
|
---|
| 821 | itJet.Reset();
|
---|
| 822 | counter = 0;
|
---|
| 823 | while((jet = (Jet *) itGenJet.Next()))
|
---|
| 824 | {
|
---|
| 825 | eveJetCone = new TEveJetCone();
|
---|
| 826 | eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
|
---|
| 827 | eveJetCone->SetName(Form("jet [%d]", counter++));
|
---|
| 828 | eveJetCone->SetMainTransparency(60);
|
---|
| 829 | eveJetCone->SetLineColor(kCyan);
|
---|
| 830 | eveJetCone->SetFillColor(kCyan);
|
---|
| 831 | eveJetCone->SetCylinder(gRadius - 10, gHalfLength - 10);
|
---|
| 832 | eveJetCone->SetPickable(kTRUE);
|
---|
| 833 | eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
|
---|
| 834 | gGenJetList->AddElement(eveJetCone);
|
---|
| 835 | }
|
---|
| 836 |
|
---|
[b4cd1e7] | 837 | // Missing Et
|
---|
| 838 | // recipe: gRadius * MET/maxpt(tracks, jets)
|
---|
| 839 | itMet.Reset();
|
---|
| 840 | while((MET = (MissingET*) itMet.Next())) {
|
---|
| 841 | delete gMet;
|
---|
| 842 | gMet = new TEveArrow((gRadius * MET->MET/maxPt)*cos(MET->Phi), (gRadius * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.);
|
---|
| 843 | gMet->SetMainColor(kViolet);
|
---|
[a844c07] | 844 | gMet->SetTubeR(0.04);
|
---|
| 845 | gMet->SetConeR(0.08);
|
---|
| 846 | gMet->SetConeL(0.10);
|
---|
[b4cd1e7] | 847 | gMet->SetPickable(kTRUE);
|
---|
| 848 | gMet->SetName("Missing Et");
|
---|
| 849 | gMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));
|
---|
| 850 | gMet->ProjectAllChildren();
|
---|
| 851 | gEve->GetCurrentEvent()->AddElement(gMet);
|
---|
[7f66dc0] | 852 | }
|
---|
| 853 | }
|
---|
| 854 |
|
---|
| 855 |
|
---|
| 856 | /******************************************************************************/
|
---|
| 857 | // GUI
|
---|
| 858 | /******************************************************************************/
|
---|
| 859 |
|
---|
| 860 | //______________________________________________________________________________
|
---|
| 861 | //
|
---|
| 862 | // EvNavHandler class is needed to connect GUI signals.
|
---|
| 863 |
|
---|
| 864 | class EvNavHandler
|
---|
| 865 | {
|
---|
| 866 | public:
|
---|
| 867 | void Fwd()
|
---|
| 868 | {
|
---|
[e0c1ff0] | 869 | if (event_id < gTreeReader->GetEntries() - 1) {
|
---|
[7f66dc0] | 870 | ++event_id;
|
---|
| 871 | load_event();
|
---|
| 872 | } else {
|
---|
| 873 | printf("Already at last event.\n");
|
---|
| 874 | }
|
---|
| 875 | }
|
---|
| 876 | void Bck()
|
---|
| 877 | {
|
---|
| 878 | if (event_id > 0) {
|
---|
| 879 | --event_id;
|
---|
| 880 | load_event();
|
---|
| 881 | } else {
|
---|
| 882 | printf("Already at first event.\n");
|
---|
| 883 | }
|
---|
| 884 | }
|
---|
| 885 | };
|
---|
| 886 |
|
---|
| 887 | //______________________________________________________________________________
|
---|
| 888 | void make_gui()
|
---|
| 889 | {
|
---|
| 890 | // Create minimal GUI for event navigation.
|
---|
| 891 | // TODO: better GUI could be made based on the ch15 of the manual (Writing a GUI)
|
---|
| 892 |
|
---|
| 893 | // add a tab on the left
|
---|
| 894 | TEveBrowser* browser = gEve->GetBrowser();
|
---|
| 895 | browser->StartEmbedding(TRootBrowser::kLeft);
|
---|
| 896 |
|
---|
| 897 | // set the main title
|
---|
| 898 | TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
|
---|
| 899 | frmMain->SetWindowName("Delphes Event Display");
|
---|
| 900 | frmMain->SetCleanup(kDeepCleanup);
|
---|
| 901 |
|
---|
| 902 | // build the navigation menu
|
---|
| 903 | TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain);
|
---|
| 904 | {
|
---|
| 905 | TString icondir;
|
---|
| 906 | if(gSystem->Getenv("ROOTSYS"))
|
---|
| 907 | icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS"));
|
---|
| 908 | if(!gSystem->OpenDirectory(icondir))
|
---|
| 909 | icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") );
|
---|
| 910 | TGPictureButton* b = 0;
|
---|
| 911 | EvNavHandler *fh = new EvNavHandler;
|
---|
| 912 |
|
---|
| 913 | b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
|
---|
| 914 | hf->AddFrame(b);
|
---|
| 915 | b->Connect("Clicked()", "EvNavHandler", fh, "Bck()");
|
---|
| 916 |
|
---|
| 917 | b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
|
---|
| 918 | hf->AddFrame(b);
|
---|
| 919 | b->Connect("Clicked()", "EvNavHandler", fh, "Fwd()");
|
---|
| 920 | }
|
---|
| 921 | frmMain->AddFrame(hf);
|
---|
| 922 | frmMain->MapSubwindows();
|
---|
| 923 | frmMain->Resize();
|
---|
| 924 | frmMain->MapWindow();
|
---|
| 925 | browser->StopEmbedding();
|
---|
| 926 | browser->SetTabTitle("Event Control", 0);
|
---|
| 927 | }
|
---|
| 928 |
|
---|
| 929 | /******************************************************************************/
|
---|
| 930 | // MAIN
|
---|
| 931 | /******************************************************************************/
|
---|
| 932 |
|
---|
[a0b6d15] | 933 | void geometry(const char* filename = "delphes_card_CMS.tcl", const char* ParticlePropagator="ParticlePropagator",
|
---|
| 934 | const char* TrackingEfficiency="ChargedHadronTrackingEfficiency",
|
---|
| 935 | const char* MuonEfficiency="MuonEfficiency",
|
---|
| 936 | const char* Calorimeters="Calorimeter")
|
---|
[bf6ed57] | 937 | {
|
---|
[e0c1ff0] | 938 |
|
---|
[c4d879d] | 939 | // load the libraries
|
---|
[bf6ed57] | 940 | gSystem->Load("libGeom");
|
---|
| 941 | gSystem->Load("../libDelphes");
|
---|
[c4d879d] | 942 | gSystem->Load("../libDelphesDisplay");
|
---|
[493aa9b] | 943 |
|
---|
[c4d879d] | 944 | // create the detector representation
|
---|
| 945 | Delphes3DGeometry det3D(new TGeoManager("delphes", "Delphes geometry"));
|
---|
| 946 | det3D.readFile(filename, ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters);
|
---|
| 947 |
|
---|
| 948 | // create the application items
|
---|
| 949 | delphes_event_display("delphes_card_CMS.tcl", "../delphes_output.root", det3D);
|
---|
[493aa9b] | 950 | make_gui();
|
---|
| 951 | load_event();
|
---|
| 952 | gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown.
|
---|
| 953 |
|
---|
| 954 | // EClipType not exported to CINT (see TGLUtil.h):
|
---|
| 955 | // 0 - no clip, 1 - clip plane, 2 - clip box
|
---|
| 956 | TGLViewer *v = gEve->GetDefaultGLViewer();
|
---|
| 957 | Double_t plane[4] = { 0., 1., 0., 0. };
|
---|
| 958 | //v->GetClipSet()->SetClipState(1,plane);
|
---|
| 959 | //v->GetClipSet()->SetClipType(1);
|
---|
| 960 | //v->ColorSet().Background().SetColor(kMagenta+4);
|
---|
| 961 | //v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0);
|
---|
| 962 | v->RefreshPadEditor(v);
|
---|
| 963 | v->CurrentCamera().RotateRad(-1.2, 0.5);
|
---|
| 964 | v->DoDraw();
|
---|
| 965 |
|
---|
[bf6ed57] | 966 | }
|
---|
| 967 |
|
---|