1 | #include <set>
|
---|
2 | #include <map>
|
---|
3 | #include <utility>
|
---|
4 | #include <vector>
|
---|
5 | #include <algorithm>
|
---|
6 | #include <sstream>
|
---|
7 | #include <exception>
|
---|
8 | #include "TGeoManager.h"
|
---|
9 | #include "TGeoVolume.h"
|
---|
10 | #include "TGeoMedium.h"
|
---|
11 | #include "TGeoNode.h"
|
---|
12 | #include "TGeoCompositeShape.h"
|
---|
13 | #include "TGeoMatrix.h"
|
---|
14 | #include "TGeoTube.h"
|
---|
15 | #include "TGeoCone.h"
|
---|
16 | #include "TGeoArb8.h"
|
---|
17 | #include "external/ExRootAnalysis/ExRootConfReader.h"
|
---|
18 | #include "external/ExRootAnalysis/ExRootTreeReader.h"
|
---|
19 | #include "display/DelphesCaloData.h"
|
---|
20 | #include "display/DelphesDisplay.h"
|
---|
21 | #include "display/DelphesBranchElement.h"
|
---|
22 | #include "display/Delphes3DGeometry.h"
|
---|
23 | #include "classes/DelphesClasses.h"
|
---|
24 | #include "TF2.h"
|
---|
25 | #include "TH1F.h"
|
---|
26 | #include "TChain.h"
|
---|
27 | #include "TEveElement.h"
|
---|
28 | #include "TEveJetCone.h"
|
---|
29 | #include "TEveTrack.h"
|
---|
30 | #include "TEveTrackPropagator.h"
|
---|
31 | #include "TEveCalo.h"
|
---|
32 | #include "TMath.h"
|
---|
33 | #include "TSystem.h"
|
---|
34 | #include "TEveManager.h"
|
---|
35 | #include "TEveGeoNode.h"
|
---|
36 | #include "TEveTrans.h"
|
---|
37 | #include "TEveViewer.h"
|
---|
38 | #include "TEveBrowser.h"
|
---|
39 | #include "TRootBrowser.h"
|
---|
40 | #include "TGLViewer.h"
|
---|
41 | #include "TGButton.h"
|
---|
42 | #include "TCollection.h"
|
---|
43 | #include "TClonesArray.h"
|
---|
44 | #include "TGLClip.h"
|
---|
45 | #include "TEveArrow.h"
|
---|
46 |
|
---|
47 | /*
|
---|
48 | * assembly.C: sauvegarde as shape-extract -> implement in the geometry class (read/write)
|
---|
49 | * histobrowser.C: intégration d'histogrammes dans le display (on pourrait avoir Pt, eta, phi pour les principales collections)
|
---|
50 | * also from alice_esd: summary html table
|
---|
51 | *
|
---|
52 | */
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | // Forward declarations.
|
---|
56 | class Delphes3DGeometry;
|
---|
57 | class ExRootTreeReader;
|
---|
58 | class DelphesCaloData;
|
---|
59 | class DelphesDisplay;
|
---|
60 | class DelphesBranchBase;
|
---|
61 | template<typename EveContainer> class DelphesBranchElement;
|
---|
62 | void make_gui();
|
---|
63 | void load_event();
|
---|
64 | void delphes_read();
|
---|
65 | void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element);
|
---|
66 | void delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element);
|
---|
67 | void delphes_read_jets(TClonesArray* data, DelphesBranchBase* element);
|
---|
68 | void delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element);
|
---|
69 | void readConfig(const char *configFile, const Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays);
|
---|
70 |
|
---|
71 | // Configuration and global variables.
|
---|
72 | Int_t event_id = 0; // Current event id.
|
---|
73 | Double_t gRadius = 1.29;
|
---|
74 | Double_t gTotRadius = 2.0;
|
---|
75 | Double_t gHalfLength = 3.0;
|
---|
76 | Double_t gBz = 3.8;
|
---|
77 |
|
---|
78 | TChain gChain("Delphes");
|
---|
79 |
|
---|
80 | ExRootTreeReader *gTreeReader = 0;
|
---|
81 |
|
---|
82 | std::vector<DelphesBranchBase*> gElements;
|
---|
83 | std::vector<TClonesArray*> gArrays;
|
---|
84 |
|
---|
85 | DelphesDisplay *gDelphesDisplay = 0;
|
---|
86 |
|
---|
87 | /******************************************************************************/
|
---|
88 | // Initialization and steering functions
|
---|
89 | /******************************************************************************/
|
---|
90 |
|
---|
91 | // function that parses the config to extract the branches of interest and prepare containers
|
---|
92 | void readConfig(const char *configFile, Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays) {
|
---|
93 | ExRootConfReader *confReader = new ExRootConfReader;
|
---|
94 | confReader->ReadFile(configFile);
|
---|
95 | Double_t tk_radius = det3D.getTrackerRadius();
|
---|
96 | Double_t tk_length = det3D.getTrackerHalfLength();
|
---|
97 | Double_t tk_Bz = det3D.getBField();
|
---|
98 | Double_t mu_radius = det3D.getDetectorRadius();
|
---|
99 | Double_t mu_length = det3D.getDetectorHalfLength();
|
---|
100 | TAxis* etaAxis = det3D.getCaloAxes().first;
|
---|
101 | TAxis* phiAxis = det3D.getCaloAxes().second;
|
---|
102 | ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch");
|
---|
103 | Int_t nBranches = branches.GetSize()/3;
|
---|
104 | DelphesBranchElement<TEveTrackList>* tlist;
|
---|
105 | DelphesBranchElement<DelphesCaloData>* clist;
|
---|
106 | DelphesBranchElement<TEveElementList>* elist;
|
---|
107 | for(Int_t b = 0; b<nBranches; ++b) {
|
---|
108 | TString input = branches[b*3].GetString();
|
---|
109 | TString name = branches[b*3+1].GetString();
|
---|
110 | TString className = branches[b*3+2].GetString();
|
---|
111 | if(className=="Track") {
|
---|
112 | if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
|
---|
113 | tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue);
|
---|
114 | elements.push_back(tlist);
|
---|
115 | TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
|
---|
116 | trkProp->SetMagField(0., 0., -tk_Bz);
|
---|
117 | trkProp->SetMaxR(tk_radius);
|
---|
118 | trkProp->SetMaxZ(tk_length);
|
---|
119 | } else if(className=="Tower") {
|
---|
120 | if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
|
---|
121 | clist = new DelphesBranchElement<DelphesCaloData>(name,"tower",kBlack);
|
---|
122 | clist->GetContainer()->SetEtaBins(etaAxis);
|
---|
123 | clist->GetContainer()->SetPhiBins(phiAxis);
|
---|
124 | elements.push_back(clist);
|
---|
125 | } else if(className=="Jet") {
|
---|
126 | if(input.Contains("GenJetFinder")) {
|
---|
127 | elist = new DelphesBranchElement<TEveElementList>(name,"jet",kCyan);
|
---|
128 | elist->GetContainer()->SetRnrSelf(false);
|
---|
129 | elist->GetContainer()->SetRnrChildren(false);
|
---|
130 | elements.push_back(elist);
|
---|
131 | } else {
|
---|
132 | elements.push_back(new DelphesBranchElement<TEveElementList>(name,"jet",kYellow));
|
---|
133 | }
|
---|
134 | } else if(className=="Electron") {
|
---|
135 | tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kRed);
|
---|
136 | elements.push_back(tlist);
|
---|
137 | TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
|
---|
138 | trkProp->SetMagField(0., 0., -tk_Bz);
|
---|
139 | trkProp->SetMaxR(tk_radius);
|
---|
140 | trkProp->SetMaxZ(tk_length);
|
---|
141 | } else if(className=="Photon") {
|
---|
142 | tlist = new DelphesBranchElement<TEveTrackList>(name,"photon",kYellow);
|
---|
143 | elements.push_back(tlist);
|
---|
144 | TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
|
---|
145 | trkProp->SetMagField(0., 0., 0.);
|
---|
146 | trkProp->SetMaxR(tk_radius);
|
---|
147 | trkProp->SetMaxZ(tk_length);
|
---|
148 | } else if(className=="Muon") {
|
---|
149 | tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kGreen);
|
---|
150 | elements.push_back(tlist);
|
---|
151 | TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
|
---|
152 | trkProp->SetMagField(0., 0., -tk_Bz);
|
---|
153 | trkProp->SetMaxR(mu_radius);
|
---|
154 | trkProp->SetMaxZ(mu_length);
|
---|
155 | } else if(className=="MissingET") {
|
---|
156 | elements.push_back(new DelphesBranchElement<TEveElementList>(name,"vector",kViolet));
|
---|
157 | } else if(className=="GenParticle") {
|
---|
158 | tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kCyan);
|
---|
159 | elements.push_back(tlist);
|
---|
160 | tlist->GetContainer()->SetRnrSelf(false);
|
---|
161 | tlist->GetContainer()->SetRnrChildren(false);
|
---|
162 | TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator();
|
---|
163 | trkProp->SetMagField(0., 0., -tk_Bz);
|
---|
164 | trkProp->SetMaxR(tk_radius);
|
---|
165 | trkProp->SetMaxZ(tk_length);
|
---|
166 | }
|
---|
167 | //TODO one possible simplification could be to add the array to the element class.
|
---|
168 | arrays.push_back(gTreeReader->UseBranch(name));
|
---|
169 | }
|
---|
170 | }
|
---|
171 |
|
---|
172 | void delphes_event_display(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D)
|
---|
173 | {
|
---|
174 |
|
---|
175 | // initialize the application
|
---|
176 | TEveManager::Create(kTRUE, "IV");
|
---|
177 | TGeoManager* geom = gGeoManager;
|
---|
178 |
|
---|
179 | // build the detector
|
---|
180 | gRadius = det3D.getTrackerRadius();
|
---|
181 | gTotRadius = det3D.getDetectorRadius();
|
---|
182 | gHalfLength = det3D.getTrackerHalfLength();
|
---|
183 | gBz = det3D.getBField();
|
---|
184 |
|
---|
185 | //TODO specific to some classical detector... could use better the det3D
|
---|
186 | TGeoVolume* top = det3D.getDetector(false);
|
---|
187 | geom->SetTopVolume(top);
|
---|
188 | TEveElementList *geometry = new TEveElementList("Geometry");
|
---|
189 | TEveGeoTopNode* trk = new TEveGeoTopNode(gGeoManager, top->FindNode("tracker_1"));
|
---|
190 | trk->SetVisLevel(6);
|
---|
191 | geometry->AddElement(trk);
|
---|
192 | TEveGeoTopNode* calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_barrel_1"));
|
---|
193 | calo->SetVisLevel(3);
|
---|
194 | geometry->AddElement(calo);
|
---|
195 | calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_1"));
|
---|
196 | calo->SetVisLevel(3);
|
---|
197 | calo->UseNodeTrans();
|
---|
198 | geometry->AddElement(calo);
|
---|
199 | calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_2"));
|
---|
200 | calo->SetVisLevel(3);
|
---|
201 | calo->UseNodeTrans();
|
---|
202 | geometry->AddElement(calo);
|
---|
203 | TEveGeoTopNode* muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_barrel_1"));
|
---|
204 | muon->SetVisLevel(4);
|
---|
205 | geometry->AddElement(muon);
|
---|
206 | muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_1"));
|
---|
207 | muon->SetVisLevel(4);
|
---|
208 | muon->UseNodeTrans();
|
---|
209 | geometry->AddElement(muon);
|
---|
210 | muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_2"));
|
---|
211 | muon->SetVisLevel(4);
|
---|
212 | muon->UseNodeTrans();
|
---|
213 | geometry->AddElement(muon);
|
---|
214 | //gGeoManager->DefaultColors();
|
---|
215 |
|
---|
216 | // Create chain of root trees
|
---|
217 | gChain.Add(inputFile);
|
---|
218 |
|
---|
219 | // Create object of class ExRootTreeReader
|
---|
220 | printf("*** Opening Delphes data file ***\n");
|
---|
221 | gTreeReader = new ExRootTreeReader(&gChain);
|
---|
222 |
|
---|
223 | // prepare data collections
|
---|
224 | readConfig(configFile, det3D, gElements, gArrays);
|
---|
225 |
|
---|
226 | // viewers and scenes
|
---|
227 | gDelphesDisplay = new DelphesDisplay;
|
---|
228 | gEve->AddGlobalElement(geometry);
|
---|
229 | gDelphesDisplay->ImportGeomRPhi(geometry);
|
---|
230 | gDelphesDisplay->ImportGeomRhoZ(geometry);
|
---|
231 | // find the first calo data and use that to initialize the calo display
|
---|
232 | for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++data) {
|
---|
233 | if(TString((*data)->GetType())=="tower") {
|
---|
234 | //TODO: why do I have to split this in two lines??? seems a cint bug?
|
---|
235 | DelphesBranchElement<DelphesCaloData>* data_tmp = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>(*data);
|
---|
236 | DelphesCaloData* container = data_tmp->GetContainer();
|
---|
237 | // DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
|
---|
238 | assert(container);
|
---|
239 | TEveCalo3D *calo3d = new TEveCalo3D(container);
|
---|
240 | calo3d->SetBarrelRadius(gRadius);
|
---|
241 | calo3d->SetEndCapPos(gHalfLength);
|
---|
242 | gEve->AddGlobalElement(calo3d);
|
---|
243 | gDelphesDisplay->ImportCaloRPhi(calo3d);
|
---|
244 | gDelphesDisplay->ImportCaloRhoZ(calo3d);
|
---|
245 | TEveCaloLego *lego = new TEveCaloLego(container);
|
---|
246 | lego->InitMainTrans();
|
---|
247 | lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
|
---|
248 | lego->SetAutoRebin(kFALSE);
|
---|
249 | lego->Set2DMode(TEveCaloLego::kValSizeOutline);
|
---|
250 | gDelphesDisplay->ImportCaloLego(lego);
|
---|
251 | break;
|
---|
252 | }
|
---|
253 | }
|
---|
254 | gEve->Redraw3D(kTRUE);
|
---|
255 | }
|
---|
256 |
|
---|
257 | //______________________________________________________________________________
|
---|
258 | void load_event()
|
---|
259 | {
|
---|
260 | // Load event specified in global event_id.
|
---|
261 | // The contents of previous event are removed.
|
---|
262 |
|
---|
263 | //TODO move this to the status bar ???
|
---|
264 | printf("Loading event %d.\n", event_id);
|
---|
265 |
|
---|
266 | // clear the previous event
|
---|
267 | gEve->GetViewers()->DeleteAnnotations();
|
---|
268 | for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++data) {
|
---|
269 | (*data)->Reset();
|
---|
270 | }
|
---|
271 |
|
---|
272 | // read the new event
|
---|
273 | delphes_read();
|
---|
274 |
|
---|
275 | // update display
|
---|
276 | TEveElement* top = (TEveElement*)gEve->GetCurrentEvent();
|
---|
277 | gDelphesDisplay->DestroyEventRPhi();
|
---|
278 | gDelphesDisplay->ImportEventRPhi(top);
|
---|
279 | gDelphesDisplay->DestroyEventRhoZ();
|
---|
280 | gDelphesDisplay->ImportEventRhoZ(top);
|
---|
281 | //update_html_summary();
|
---|
282 | gEve->Redraw3D(kFALSE, kTRUE);
|
---|
283 | }
|
---|
284 |
|
---|
285 | void delphes_read()
|
---|
286 | {
|
---|
287 |
|
---|
288 | // safety
|
---|
289 | if(event_id >= gTreeReader->GetEntries() || event_id<0 ) return;
|
---|
290 |
|
---|
291 | // Load selected branches with data from specified event
|
---|
292 | gTreeReader->ReadEntry(event_id);
|
---|
293 |
|
---|
294 | // loop over selected branches, and apply the proper recipe to fill the collections.
|
---|
295 | // this is basically to loop on gArrays to fill gElements.
|
---|
296 |
|
---|
297 | //TODO: one option would be to have templated methods in the element classes. We could simply call "element.fill()"
|
---|
298 | std::vector<TClonesArray*>::iterator data = gArrays.begin();
|
---|
299 | std::vector<DelphesBranchBase*>::iterator element = gElements.begin();
|
---|
300 | std::vector<TClonesArray*>::iterator data_tracks = gArrays.begin();
|
---|
301 | std::vector<DelphesBranchBase*>::iterator element_tracks = gElements.begin();
|
---|
302 | Int_t nTracks = 0;
|
---|
303 | for(; data<gArrays.end() && element<gElements.end(); ++data, ++element) {
|
---|
304 | TString type = (*element)->GetType();
|
---|
305 | // keep the most generic track collection for the end
|
---|
306 | if(type=="track" && TString((*element)->GetClassName())=="Track" && nTracks==0) {
|
---|
307 | data_tracks = data;
|
---|
308 | element_tracks = element;
|
---|
309 | nTracks = (*data_tracks)->GetEntries();
|
---|
310 | continue;
|
---|
311 | }
|
---|
312 | // branch on the element type
|
---|
313 | if(type=="tower") delphes_read_towers(*data,*element);
|
---|
314 | else if(type=="track" || type=="photon") delphes_read_tracks(*data,*element);
|
---|
315 | else if(type=="jet") delphes_read_jets(*data,*element);
|
---|
316 | else if(type=="vector") delphes_read_vectors(*data,*element);
|
---|
317 | }
|
---|
318 | // finish whith what we consider to be the main track collection
|
---|
319 | if(nTracks>0) delphes_read_tracks(*data,*element);
|
---|
320 | }
|
---|
321 |
|
---|
322 | void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element) {
|
---|
323 | DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>(element)->GetContainer();
|
---|
324 | assert(container);
|
---|
325 | // Loop over all towers
|
---|
326 | TIter itTower(data);
|
---|
327 | Tower *tower;
|
---|
328 | while((tower = (Tower *) itTower.Next()))
|
---|
329 | {
|
---|
330 | container->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
|
---|
331 | container->FillSlice(0, tower->Eem);
|
---|
332 | container->FillSlice(1, tower->Ehad);
|
---|
333 | }
|
---|
334 | container->DataChanged();
|
---|
335 | }
|
---|
336 |
|
---|
337 | void delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element) {
|
---|
338 | TEveTrackList* container = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(element)->GetContainer();
|
---|
339 | assert(container);
|
---|
340 | TString className = element->GetClassName();
|
---|
341 | TIter itTrack(data);
|
---|
342 | Int_t counter = 0;
|
---|
343 | TEveTrack *eveTrack;
|
---|
344 | TEveTrackPropagator *trkProp = container->GetPropagator();
|
---|
345 | if(className=="Track") {
|
---|
346 | // Loop over all tracks
|
---|
347 | Track *track;
|
---|
348 | while((track = (Track *) itTrack.Next())) {
|
---|
349 | TParticle pb(track->PID, 1, 0, 0, 0, 0,
|
---|
350 | track->P4().Px(), track->P4().Py(),
|
---|
351 | track->P4().Pz(), track->P4().E(),
|
---|
352 | track->X, track->Y, track->Z, 0.0);
|
---|
353 |
|
---|
354 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
355 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
356 | eveTrack->SetStdTitle();
|
---|
357 | eveTrack->SetAttLineAttMarker(container);
|
---|
358 | container->AddElement(eveTrack);
|
---|
359 | eveTrack->SetLineColor(element->GetColor());
|
---|
360 | eveTrack->MakeTrack();
|
---|
361 | }
|
---|
362 | } else if(className=="Electron") {
|
---|
363 | // Loop over all electrons
|
---|
364 | Electron *electron;
|
---|
365 | while((electron = (Electron *) itTrack.Next())) {
|
---|
366 | TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
|
---|
367 | electron->P4().Px(), electron->P4().Py(),
|
---|
368 | electron->P4().Pz(), electron->P4().E(),
|
---|
369 | 0., 0., 0., 0.);
|
---|
370 |
|
---|
371 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
372 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
373 | eveTrack->SetStdTitle();
|
---|
374 | eveTrack->SetAttLineAttMarker(container);
|
---|
375 | container->AddElement(eveTrack);
|
---|
376 | eveTrack->SetLineColor(element->GetColor());
|
---|
377 | eveTrack->MakeTrack();
|
---|
378 | }
|
---|
379 | } else if(className=="Muon") {
|
---|
380 | // Loop over all muons
|
---|
381 | Muon *muon;
|
---|
382 | while((muon = (Muon *) itTrack.Next())) {
|
---|
383 | TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
|
---|
384 | muon->P4().Px(), muon->P4().Py(),
|
---|
385 | muon->P4().Pz(), muon->P4().E(),
|
---|
386 | 0., 0., 0., 0.);
|
---|
387 |
|
---|
388 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
389 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
390 | eveTrack->SetStdTitle();
|
---|
391 | eveTrack->SetAttLineAttMarker(container);
|
---|
392 | container->AddElement(eveTrack);
|
---|
393 | eveTrack->SetLineColor(element->GetColor());
|
---|
394 | eveTrack->MakeTrack();
|
---|
395 | }
|
---|
396 | } else if(className=="Photon") {
|
---|
397 | // Loop over all photons
|
---|
398 | Photon *photon;
|
---|
399 | while((photon = (Photon *) itTrack.Next())) {
|
---|
400 | TParticle pb(22, 1, 0, 0, 0, 0,
|
---|
401 | photon->P4().Px(), photon->P4().Py(),
|
---|
402 | photon->P4().Pz(), photon->P4().E(),
|
---|
403 | 0., 0., 0., 0.);
|
---|
404 |
|
---|
405 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
406 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
407 | eveTrack->SetStdTitle();
|
---|
408 | eveTrack->SetAttLineAttMarker(container);
|
---|
409 | container->AddElement(eveTrack);
|
---|
410 | eveTrack->SetLineColor(element->GetColor());
|
---|
411 | eveTrack->MakeTrack();
|
---|
412 | }
|
---|
413 | }
|
---|
414 | }
|
---|
415 |
|
---|
416 | void delphes_read_jets(TClonesArray* data, DelphesBranchBase* element) {
|
---|
417 | TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();
|
---|
418 | assert(container);
|
---|
419 | TIter itJet(data);
|
---|
420 | Jet *jet;
|
---|
421 | TEveJetCone *eveJetCone;
|
---|
422 | // Loop over all jets
|
---|
423 | Int_t counter = 0;
|
---|
424 | while((jet = (Jet *) itJet.Next()))
|
---|
425 | {
|
---|
426 | eveJetCone = new TEveJetCone();
|
---|
427 | eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
|
---|
428 | eveJetCone->SetName(Form("jet [%d]", counter++));
|
---|
429 | eveJetCone->SetMainTransparency(60);
|
---|
430 | eveJetCone->SetLineColor(element->GetColor());
|
---|
431 | eveJetCone->SetFillColor(element->GetColor());
|
---|
432 | eveJetCone->SetCylinder(gRadius - 10, gHalfLength - 10);
|
---|
433 | eveJetCone->SetPickable(kTRUE);
|
---|
434 | eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
|
---|
435 | container->AddElement(eveJetCone);
|
---|
436 | }
|
---|
437 | }
|
---|
438 |
|
---|
439 | void delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element) {
|
---|
440 | TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();
|
---|
441 | assert(container);
|
---|
442 | TIter itMet(data);
|
---|
443 | MissingET *MET;
|
---|
444 | TEveArrow *eveMet;
|
---|
445 | // Missing Et
|
---|
446 | Double_t maxPt = 50.;
|
---|
447 | // TODO to be changed as we don't have access to maxPt anymore. MET scale could be a general parameter set in GUI
|
---|
448 | while((MET = (MissingET*) itMet.Next())) {
|
---|
449 | eveMet = new TEveArrow((gRadius * MET->MET/maxPt)*cos(MET->Phi), (gRadius * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.);
|
---|
450 | eveMet->SetMainColor(element->GetColor());
|
---|
451 | eveMet->SetTubeR(0.04);
|
---|
452 | eveMet->SetConeR(0.08);
|
---|
453 | eveMet->SetConeL(0.10);
|
---|
454 | eveMet->SetPickable(kTRUE);
|
---|
455 | eveMet->SetName("Missing Et");
|
---|
456 | eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));
|
---|
457 | container->AddElement(eveMet);
|
---|
458 | }
|
---|
459 | }
|
---|
460 |
|
---|
461 | /******************************************************************************/
|
---|
462 | // GUI
|
---|
463 | /******************************************************************************/
|
---|
464 |
|
---|
465 | //______________________________________________________________________________
|
---|
466 | //
|
---|
467 | // EvNavHandler class is needed to connect GUI signals.
|
---|
468 |
|
---|
469 | class EvNavHandler
|
---|
470 | {
|
---|
471 | public:
|
---|
472 | void Fwd()
|
---|
473 | {
|
---|
474 | if (event_id < gTreeReader->GetEntries() - 1) {
|
---|
475 | ++event_id;
|
---|
476 | load_event();
|
---|
477 | } else {
|
---|
478 | printf("Already at last event.\n");
|
---|
479 | }
|
---|
480 | }
|
---|
481 | void Bck()
|
---|
482 | {
|
---|
483 | if (event_id > 0) {
|
---|
484 | --event_id;
|
---|
485 | load_event();
|
---|
486 | } else {
|
---|
487 | printf("Already at first event.\n");
|
---|
488 | }
|
---|
489 | }
|
---|
490 | };
|
---|
491 |
|
---|
492 | //______________________________________________________________________________
|
---|
493 | void make_gui()
|
---|
494 | {
|
---|
495 | // Create minimal GUI for event navigation.
|
---|
496 | // TODO: better GUI could be made based on the ch15 of the manual (Writing a GUI)
|
---|
497 |
|
---|
498 | // add a tab on the left
|
---|
499 | TEveBrowser* browser = gEve->GetBrowser();
|
---|
500 | browser->StartEmbedding(TRootBrowser::kLeft);
|
---|
501 |
|
---|
502 | // set the main title
|
---|
503 | TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
|
---|
504 | frmMain->SetWindowName("Delphes Event Display");
|
---|
505 | frmMain->SetCleanup(kDeepCleanup);
|
---|
506 |
|
---|
507 | // build the navigation menu
|
---|
508 | TGHorizontalFrame* hf = new TGHorizontalFrame(frmMain);
|
---|
509 | {
|
---|
510 | TString icondir;
|
---|
511 | if(gSystem->Getenv("ROOTSYS"))
|
---|
512 | icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS"));
|
---|
513 | if(!gSystem->OpenDirectory(icondir))
|
---|
514 | icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") );
|
---|
515 | TGPictureButton* b = 0;
|
---|
516 | EvNavHandler *fh = new EvNavHandler;
|
---|
517 |
|
---|
518 | b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
|
---|
519 | hf->AddFrame(b);
|
---|
520 | b->Connect("Clicked()", "EvNavHandler", fh, "Bck()");
|
---|
521 |
|
---|
522 | b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
|
---|
523 | hf->AddFrame(b);
|
---|
524 | b->Connect("Clicked()", "EvNavHandler", fh, "Fwd()");
|
---|
525 | }
|
---|
526 | frmMain->AddFrame(hf);
|
---|
527 | frmMain->MapSubwindows();
|
---|
528 | frmMain->Resize();
|
---|
529 | frmMain->MapWindow();
|
---|
530 | browser->StopEmbedding();
|
---|
531 | browser->SetTabTitle("Event Control", 0);
|
---|
532 | }
|
---|
533 |
|
---|
534 | /******************************************************************************/
|
---|
535 | // MAIN
|
---|
536 | /******************************************************************************/
|
---|
537 |
|
---|
538 | void geometry(const char* filename = "delphes_card_CMS.tcl", const char* ParticlePropagator="ParticlePropagator",
|
---|
539 | const char* TrackingEfficiency="ChargedHadronTrackingEfficiency",
|
---|
540 | const char* MuonEfficiency="MuonEfficiency",
|
---|
541 | const char* Calorimeters="Calorimeter")
|
---|
542 | {
|
---|
543 |
|
---|
544 | // load the libraries
|
---|
545 | gSystem->Load("libGeom");
|
---|
546 | //gSystem->Load("../libDelphes");
|
---|
547 | gSystem->Load("../libDelphesDisplay");
|
---|
548 |
|
---|
549 | // create the detector representation
|
---|
550 | Delphes3DGeometry det3D(new TGeoManager("delphes", "Delphes geometry"));
|
---|
551 | det3D.readFile(filename, ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters);
|
---|
552 |
|
---|
553 | // create the application items
|
---|
554 | delphes_event_display("delphes_card_CMS.tcl", "../delphes_output.root", det3D); //TODO root file as input cfg
|
---|
555 | make_gui();
|
---|
556 | load_event();
|
---|
557 | gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown.
|
---|
558 |
|
---|
559 | // EClipType not exported to CINT (see TGLUtil.h):
|
---|
560 | // 0 - no clip, 1 - clip plane, 2 - clip box
|
---|
561 | TGLViewer *v = gEve->GetDefaultGLViewer();
|
---|
562 | //Double_t plane[4] = { 0., 1., 0., 0. };
|
---|
563 | //v->GetClipSet()->SetClipState(1,plane);
|
---|
564 | //v->GetClipSet()->SetClipType(1);
|
---|
565 | //v->ColorSet().Background().SetColor(kMagenta+4);
|
---|
566 | //v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0);
|
---|
567 | v->RefreshPadEditor(v);
|
---|
568 | v->CurrentCamera().RotateRad(-1.2, 0.5);
|
---|
569 | v->DoDraw();
|
---|
570 |
|
---|
571 | }
|
---|
572 |
|
---|