Fork me on GitHub

source: svn/trunk/src/FrogUtil.cc@ 210

Last change on this file since 210 was 186, checked in by Xavier Rouby, 16 years ago

less 'cout'

File size: 34.6 KB
Line 
1/*
2 * ---- Delphes ----
3 * A Fast Simulator for general purpose LHC detector
4 * S. Ovyn ~~~~ severine.ovyn@uclouvain.be
5 *
6 * Center for Particle Physics and Phenomenology (CP3)
7 * Universite Catholique de Louvain (UCL)
8 * Louvain-la-Neuve, Belgium
9 * */
10
11// \brief Trigger class, and some generic definitions
12
13#include "interface/FrogUtil.h"
14#include "TRandom.h"
15
16#include "Utilities/FROG/Includes/FROG/FROG_DetId.h"
17#include "Utilities/FROG/Includes/FROG/FROG_Geometry.h"
18#include "Utilities/FROG/Includes/FROG/FROG_Geometry.cpp"
19#include "Utilities/FROG/Includes/FROG/FROG_Events.h"
20#include "Utilities/FROG/Includes/FROG/FROG_Events.cpp"
21#include "Utilities/FROG/Includes/FROG/FROG_Element_Tools.h"
22#include "Utilities/FROG/Includes/FROG/FROG_Element_Tools.cpp"
23#include "Utilities/FROG/Includes/FROG/FROG_Net_Tools.h"
24#include "Utilities/FROG/Includes/FROG/FROG_Net_Tools.cpp"
25#include "Utilities/FROG/Includes/FROG/FROG_Path.h"
26#include "Utilities/FROG/Includes/FROG/FROG_Path.cpp"
27#include "Utilities/FROG/Includes/FROG/FROG_Coord.h"
28#include "Utilities/FROG/Includes/FROG/FROG_Coord.cpp"
29#include "Utilities/FROG/Includes/FROG/FROG_ReadCards.h"
30#include "Utilities/FROG/Includes/FROG/FROG_ReadCards.cpp"
31#include "Utilities/FROG/Includes/FROG/FROG_ZLib.h"
32#include "Utilities/FROG/Includes/FROG/FROG_ZLib.cpp"
33
34#include <iostream>
35#include <sstream>
36#include <fstream>
37#include <iomanip>
38#include <cstring>
39
40using namespace std;
41using namespace FROG_COORD;
42
43const float twopi = 6.2831;
44
45FrogDisplay::FrogDisplay() {}
46
47//PROTON 1
48void FrogDisplay::Build_1Event(FROG_Element_Event* event1)
49{
50 double posp_x = 0.0299923*1000;
51 double posp_y = 0.00602767*1000;
52 double posp_z = 0;
53 FROG_Element_Event_Hit* hitp = new FROG_Element_Event_Hit(500000001 + ((int)posp_z)/50, posp_x, posp_y, posp_z, -1);
54 double dirp_x = 0*1000;
55 double dirp_y = 0*1000;
56 double dirp_z = -1*1000;
57 float Pp = sqrt(dirp_x*dirp_x + dirp_y*dirp_y + dirp_z*dirp_z);
58 float Ptp = sqrt(dirp_x*dirp_x + dirp_y*dirp_y);
59 FROG_Element_Base_With_DetId_And_Name* trackCollectionP = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+1000, "Tracks: protons");
60 FROG_Element_Event_Track* trackp= new FROG_Element_Event_Track(0,Pp,Ptp,0);
61 trackp->addDaughter(hitp);
62 double pos2p_x = 0.0299923*1000+0*1000*0.4;
63 double pos2p_y = 0.00602767*1000+0*1000*0.4;
64 double pos2p_z = -1*1000*0.4;
65 FROG_Element_Event_Hit* hit2p = new FROG_Element_Event_Hit(500000001 + ((int)pos2p_z)/50, pos2p_x, pos2p_y, pos2p_z, -1);
66 trackp->addDaughter(hit2p);
67 trackCollectionP->addDaughter(trackp);
68
69 // photon 1
70 FROG_Element_Base_With_DetId_And_Name* trackCollection = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK,"Tracks: Photons");
71 FROG_Element_Event_Track* track1 = new FROG_Element_Event_Track(0,1,1,0);
72 double pos0_x = 0.0299923*1000;
73 double pos0_y = 0.00602767*1000;
74 double pos0_z = -0.309438*1000;
75 FROG_Element_Event_Hit* hit0 = new FROG_Element_Event_Hit(400000001 + ((int)pos0_z)/50, pos0_x, pos0_y, pos0_z, -1);
76 track1->addDaughter(hit0);
77 double pos1_x = 0.03*1000;
78 double pos1_y = 0.00602856*1000;
79 double pos1_z = -0.309567*1000;
80 FROG_Element_Event_Hit* hit1 = new FROG_Element_Event_Hit(400000001 + ((int)pos1_z)/50, pos1_x, pos1_y, pos1_z, -1);
81 track1->addDaughter(hit1);
82
83
84 trackCollection->addDaughter(track1);
85 // photon 2
86 FROG_Element_Event_Track* track2 = new FROG_Element_Event_Track(0,1,1,0);
87 double pos2_x = 0.0299923*1000;
88 double pos2_y = 0.00602767*1000;
89 double pos2_z = -0.312795*1000;
90 FROG_Element_Event_Hit* hit2 = new FROG_Element_Event_Hit(400000001 + ((int)pos2_z)/50, pos2_x, pos2_y, pos2_z, -1);
91 track2->addDaughter(hit2);
92 double pos3_x = 0.0291312*1000;
93 double pos3_y = 0.00599684*1000;
94 double pos3_z = -0.326865*1000;
95 FROG_Element_Event_Hit* hit3 = new FROG_Element_Event_Hit(400000001 + ((int)pos3_z)/50, pos3_x, pos3_y, pos3_z, -1);
96 track2->addDaughter(hit3);
97 double pos4_x = 0.0272812*1000;
98 double pos4_y = 0*1000;
99 double pos4_z = -0.325133*1000;
100 FROG_Element_Event_Hit* hit4 = new FROG_Element_Event_Hit(400000001 + ((int)pos4_z)/50, pos4_x, pos4_y, pos4_z, -1);
101 track2->addDaughter(hit4);
102 double pos5_x = 0.0147219*1000;
103 double pos5_y = -0.04071*1000;
104 double pos5_z = -0.313375*1000;
105 FROG_Element_Event_Hit* hit5 = new FROG_Element_Event_Hit(400000001 + ((int)pos5_z)/50, pos5_x, pos5_y, pos5_z, -1);
106 track2->addDaughter(hit5);
107 trackCollection->addDaughter(track2);
108
109 // photon 3
110 FROG_Element_Event_Track* track3 = new FROG_Element_Event_Track(0,1,1,0);
111 double pos6_x = 0.0299923*1000;
112 double pos6_y = 0.00602767*1000;
113 double pos6_z = -0.241733*1000;
114 FROG_Element_Event_Hit* hit6 = new FROG_Element_Event_Hit(400000001 + ((int)pos6_z)/50, pos6_x, pos6_y, pos6_z, -1);
115 track3->addDaughter(hit6);
116 double pos7_x = 0.0247239*1000;
117 double pos7_y = 0.00635725*1000;
118 double pos7_z = -0.327258*1000;
119 FROG_Element_Event_Hit* hit7 = new FROG_Element_Event_Hit(400000001 + ((int)pos7_z)/50, pos7_x, pos7_y, pos7_z, -1);
120 track3->addDaughter(hit7);
121 double pos8_x = 0.023245*1000;
122 double pos8_y = 0*1000;
123 double pos8_z = -0.325292*1000;
124 FROG_Element_Event_Hit* hit8 = new FROG_Element_Event_Hit(400000001 + ((int)pos8_z)/50, pos8_x, pos8_y, pos8_z, -1);
125 track3->addDaughter(hit8);
126 double pos9_x = 0.0137742*1000;
127 double pos9_y = -0.04071*1000;
128 double pos9_z = -0.312698*1000;
129 FROG_Element_Event_Hit* hit9 = new FROG_Element_Event_Hit(400000001 + ((int)pos9_z)/50, pos9_x, pos9_y, pos9_z, -1);
130 track3->addDaughter(hit9);
131 trackCollection->addDaughter(track3);
132
133 // photon 4
134 FROG_Element_Event_Track* track4 = new FROG_Element_Event_Track(0,1,1,0);
135 double pos10_x = 0.0299923*1000;
136 double pos10_y = 0.00602767*1000;
137 double pos10_z = -0.103114*1000;
138 FROG_Element_Event_Hit* hit10 = new FROG_Element_Event_Hit(400000001 + ((int)pos10_z)/50, pos10_x, pos10_y, pos10_z, -1);
139 track4->addDaughter(hit10);
140 double pos11_x = 0.0169713*1000;
141 double pos11_y = 0.0106604*1000;
142 double pos11_z = -0.324528*1000;
143 FROG_Element_Event_Hit* hit11 = new FROG_Element_Event_Hit(400000001 + ((int)pos11_z)/50, pos11_x, pos11_y, pos11_z, -1);
144 track4->addDaughter(hit11);
145 double pos12_x = 0.0159847*1000;
146 double pos12_y = 0*1000;
147 double pos12_z = -0.322034*1000;
148 FROG_Element_Event_Hit* hit12 = new FROG_Element_Event_Hit(400000001 + ((int)pos12_z)/50, pos12_x, pos12_y, pos12_z, -1);
149 track4->addDaughter(hit12);
150 double pos13_x = 0.00925296*1000;
151 double pos13_y = -0.0727334*1000;
152 double pos13_z = -0.305018*1000;
153 FROG_Element_Event_Hit* hit13 = new FROG_Element_Event_Hit(400000001 + ((int)pos13_z)/50, pos13_x, pos13_y, pos13_z, -1);
154 track4->addDaughter(hit13);
155 trackCollection->addDaughter(track4);
156
157 // photon 5
158 FROG_Element_Event_Track* track5 = new FROG_Element_Event_Track(0,1,1,0);
159 double pos14_x = 0.0299923*1000;
160 double pos14_y = 0.00602767*1000;
161 double pos14_z = -0.0550703*1000;
162 FROG_Element_Event_Hit* hit14 = new FROG_Element_Event_Hit(400000001 + ((int)pos14_z)/50, pos14_x, pos14_y, pos14_z, -1);
163 track5->addDaughter(hit14);
164 double pos15_x = 0.03*1000;
165 double pos15_y = 0.00597767*1000;
166 double pos15_z = -0.0558923*1000;
167 FROG_Element_Event_Hit* hit15 = new FROG_Element_Event_Hit(400000001 + ((int)pos15_z)/50, pos15_x, pos15_y, pos15_z, -1);
168 track5->addDaughter(hit15);
169 trackCollection->addDaughter(track5);
170
171 // photon 6
172 FROG_Element_Event_Track* track6 = new FROG_Element_Event_Track(0,1,1,0);
173 double pos16_x = 0.0299923*1000;
174 double pos16_y = 0.00602767*1000;
175 double pos16_z = -0.0724158*1000;
176 FROG_Element_Event_Hit* hit16 = new FROG_Element_Event_Hit(400000001 + ((int)pos16_z)/50, pos16_x, pos16_y, pos16_z, -1);
177 track6->addDaughter(hit16);
178 double pos17_x = 0.03*1000;
179 double pos17_y = 0.00602949*1000;
180 double pos17_z = -0.0725471*1000;
181 FROG_Element_Event_Hit* hit17 = new FROG_Element_Event_Hit(400000001 + ((int)pos17_z)/50, pos17_x, pos17_y, pos17_z, -1);
182 track6->addDaughter(hit17);
183 trackCollection->addDaughter(track6);
184
185 // photon 7
186 FROG_Element_Event_Track* track7 = new FROG_Element_Event_Track(0,1,1,0);
187 double pos18_x = 0.0299923*1000;
188 double pos18_y = 0.00602767*1000;
189 double pos18_z = -0.108963*1000;
190 FROG_Element_Event_Hit* hit18 = new FROG_Element_Event_Hit(400000001 + ((int)pos18_z)/50, pos18_x, pos18_y, pos18_z, -1);
191 track7->addDaughter(hit18);
192 double pos19_x = 0.03*1000;
193 double pos19_y = 0.0060305*1000;
194 double pos19_z = -0.109102*1000;
195 FROG_Element_Event_Hit* hit19 = new FROG_Element_Event_Hit(400000001 + ((int)pos19_z)/50, pos19_x, pos19_y, pos19_z, -1);
196 track7->addDaughter(hit19);
197 trackCollection->addDaughter(track7);
198
199 // photon 8
200 FROG_Element_Event_Track* track8 = new FROG_Element_Event_Track(0,1,1,0);
201 double pos20_x = 0.0299923*1000;
202 double pos20_y = 0.00602767*1000;
203 double pos20_z = -0.189456*1000;
204 FROG_Element_Event_Hit* hit20 = new FROG_Element_Event_Hit(400000001 + ((int)pos20_z)/50, pos20_x, pos20_y, pos20_z, -1);
205 track8->addDaughter(hit20);
206 double pos21_x = 0.0248364*1000;
207 double pos21_y = 0.0129674*1000;
208 double pos21_z = -0.321989*1000;
209 FROG_Element_Event_Hit* hit21 = new FROG_Element_Event_Hit(400000001 + ((int)pos21_z)/50, pos21_x, pos21_y, pos21_z, -1);
210 track8->addDaughter(hit21);
211 double pos22_x = 0.0222521*1000;
212 double pos22_y = 0*1000;
213 double pos22_z = -0.319622*1000;
214 FROG_Element_Event_Hit* hit22 = new FROG_Element_Event_Hit(400000001 + ((int)pos22_z)/50, pos22_x, pos22_y, pos22_z, -1);
215 track8->addDaughter(hit22);
216 double pos23_x = 0.0141387*1000;
217 double pos23_y = -0.04071*1000;
218 double pos23_z = -0.312192*1000;
219 FROG_Element_Event_Hit* hit23 = new FROG_Element_Event_Hit(400000001 + ((int)pos23_z)/50, pos23_x, pos23_y, pos23_z, -1);
220 track8->addDaughter(hit23);
221 trackCollection->addDaughter(track8);
222
223 // photon 9
224 FROG_Element_Event_Track* track9 = new FROG_Element_Event_Track(0,1,1,0);
225 double pos24_x = 0.0299923*1000;
226 double pos24_y = 0.00602767*1000;
227 double pos24_z = -0.162889*1000;
228 FROG_Element_Event_Hit* hit24 = new FROG_Element_Event_Hit(400000001 + ((int)pos24_z)/50, pos24_x, pos24_y, pos24_z, -1);
229 track9->addDaughter(hit24);
230 double pos25_x = 0.0275782*1000;
231 double pos25_y = 0*1000;
232 double pos25_z = -0.266817*1000;
233 FROG_Element_Event_Hit* hit25 = new FROG_Element_Event_Hit(400000001 + ((int)pos25_z)/50, pos25_x, pos25_y, pos25_z, -1);
234 track9->addDaughter(hit25);
235 trackCollection->addDaughter(track9);
236
237 // photon 10
238 FROG_Element_Event_Track* track10 = new FROG_Element_Event_Track(0,1,1,0);
239 double pos26_x = 0.0299923*1000;
240 double pos26_y = 0.00602767*1000;
241 double pos26_z = -0.0968708*1000;
242 FROG_Element_Event_Hit* hit26 = new FROG_Element_Event_Hit(400000001 + ((int)pos26_z)/50, pos26_x, pos26_y, pos26_z, -1);
243 track10->addDaughter(hit26);
244 double pos27_x = 0.03*1000;
245 double pos27_y = 0.00603619*1000;
246 double pos27_z = -0.0970637*1000;
247 FROG_Element_Event_Hit* hit27 = new FROG_Element_Event_Hit(400000001 + ((int)pos27_z)/50, pos27_x, pos27_y, pos27_z, -1);
248 track10->addDaughter(hit27);
249 trackCollection->addDaughter(track10);
250
251 // photon 11
252 FROG_Element_Event_Track* track11 = new FROG_Element_Event_Track(0,1,1,0);
253 double pos28_x = 0.0299923*1000;
254 double pos28_y = 0.00602767*1000;
255 double pos28_z = -0.211734*1000;
256 FROG_Element_Event_Hit* hit28 = new FROG_Element_Event_Hit(400000001 + ((int)pos28_z)/50, pos28_x, pos28_y, pos28_z, -1);
257 track11->addDaughter(hit28);
258 double pos29_x = 0.0231748*1000;
259 double pos29_y = 0.00496626*1000;
260 double pos29_z = -0.328422*1000;
261 FROG_Element_Event_Hit* hit29 = new FROG_Element_Event_Hit(400000001 + ((int)pos29_z)/50, pos29_x, pos29_y, pos29_z, -1);
262 track11->addDaughter(hit29);
263 double pos30_x = 0.0221601*1000;
264 double pos30_y = 0*1000;
265 double pos30_z = -0.326734*1000;
266 FROG_Element_Event_Hit* hit30 = new FROG_Element_Event_Hit(400000001 + ((int)pos30_z)/50, pos30_x, pos30_y, pos30_z, -1);
267 track11->addDaughter(hit30);
268 double pos31_x = 0.0138423*1000;
269 double pos31_y = -0.04071*1000;
270 double pos31_z = -0.312897*1000;
271 FROG_Element_Event_Hit* hit31 = new FROG_Element_Event_Hit(400000001 + ((int)pos31_z)/50, pos31_x, pos31_y, pos31_z, -1);
272 track11->addDaughter(hit31);
273 trackCollection->addDaughter(track11);
274
275 // photon 12
276 FROG_Element_Event_Track* track12 = new FROG_Element_Event_Track(0,1,1,0);
277 double pos32_x = 0.0299923*1000;
278 double pos32_y = 0.00602767*1000;
279 double pos32_z = -0.233216*1000;
280 FROG_Element_Event_Hit* hit32 = new FROG_Element_Event_Hit(400000001 + ((int)pos32_z)/50, pos32_x, pos32_y, pos32_z, -1);
281 track12->addDaughter(hit32);
282 double pos33_x = 0.03*1000;
283 double pos33_y = 0.00603839*1000;
284 double pos33_z = -0.233429*1000;
285 FROG_Element_Event_Hit* hit33 = new FROG_Element_Event_Hit(400000001 + ((int)pos33_z)/50, pos33_x, pos33_y, pos33_z, -1);
286 track12->addDaughter(hit33);
287 trackCollection->addDaughter(track12);
288
289 // photon 13
290 FROG_Element_Event_Track* track13 = new FROG_Element_Event_Track(0,1,1,0);
291 double pos34_x = 0.0299923*1000;
292 double pos34_y = 0.00602767*1000;
293 double pos34_z = -0.0352209*1000;
294 FROG_Element_Event_Hit* hit34 = new FROG_Element_Event_Hit(400000001 + ((int)pos34_z)/50, pos34_x, pos34_y, pos34_z, -1);
295 track13->addDaughter(hit34);
296 double pos35_x = 0.03*1000;
297 double pos35_y = 0.00603501*1000;
298 double pos35_z = -0.0353909*1000;
299 FROG_Element_Event_Hit* hit35 = new FROG_Element_Event_Hit(400000001 + ((int)pos35_z)/50, pos35_x, pos35_y, pos35_z, -1);
300 track13->addDaughter(hit35);
301 trackCollection->addDaughter(track13);
302
303 // photon 14
304 FROG_Element_Event_Track* track14 = new FROG_Element_Event_Track(0,1,1,0);
305 double pos36_x = 0.0299923*1000;
306 double pos36_y = 0.00602767*1000;
307 double pos36_z = -0.0678788*1000;
308 FROG_Element_Event_Hit* hit36 = new FROG_Element_Event_Hit(400000001 + ((int)pos36_z)/50, pos36_x, pos36_y, pos36_z, -1);
309 track14->addDaughter(hit36);
310 double pos37_x = 0.03*1000;
311 double pos37_y = 0.00602573*1000;
312 double pos37_z = -0.0680089*1000;
313 FROG_Element_Event_Hit* hit37 = new FROG_Element_Event_Hit(400000001 + ((int)pos37_z)/50, pos37_x, pos37_y, pos37_z, -1);
314 track14->addDaughter(hit37);
315 trackCollection->addDaughter(track14);
316
317 // photon 15
318 FROG_Element_Event_Track* track15 = new FROG_Element_Event_Track(0,1,1,0);
319 double pos38_x = 0.0299923*1000;
320 double pos38_y = 0.00602767*1000;
321 double pos38_z = -0.0418564*1000;
322 FROG_Element_Event_Hit* hit38 = new FROG_Element_Event_Hit(400000001 + ((int)pos38_z)/50, pos38_x, pos38_y, pos38_z, -1);
323 track15->addDaughter(hit38);
324 double pos39_x = 0.0281432*1000;
325 double pos39_y = 0*1000;
326 double pos39_z = -0.148365*1000;
327 FROG_Element_Event_Hit* hit39 = new FROG_Element_Event_Hit(400000001 + ((int)pos39_z)/50, pos39_x, pos39_y, pos39_z, -1);
328 track15->addDaughter(hit39);
329 trackCollection->addDaughter(track15);
330 event1->addDaughter(trackCollectionP);
331 event1->addDaughter(trackCollection);
332
333}
334
335void FrogDisplay::BuidEvents(string outputfilename,int nEntryFrog)
336{
337 const Font_t kExRootFont = 42;
338 const Float_t kExRootFontSize = 0.07;
339 gROOT->SetStyle("Plain");
340 gROOT->cd();
341 gStyle->SetCanvasColor(10);
342 gStyle->SetPadColor(10);
343 gStyle->SetFillColor(-1);
344 gStyle->SetPaperSize(20, 24);
345 gStyle->SetStatFont(kExRootFont);
346 gStyle->SetTextFont(kExRootFont);
347 gStyle->SetTextSize(kExRootFontSize);
348 gStyle->SetLegendBorderSize(0);
349 gStyle->SetOptStat(0);
350
351 TChain* chain = new TChain("Analysis");
352 TChain* chainGen = new TChain("GEN");
353 chain ->Add(outputfilename.c_str());
354 chainGen->Add(outputfilename.c_str());
355
356 ExRootTreeReader *treeReader = new ExRootTreeReader(chain);
357 ExRootTreeReader *treeReaderGen = new ExRootTreeReader(chainGen);
358
359 const TClonesArray* branchElectron = treeReader ->UseBranch("Electron");
360 const TClonesArray* branchMuon = treeReader ->UseBranch("Muon");
361 const TClonesArray* branchTau = treeReader ->UseBranch("TauJet");
362 const TClonesArray* branchPhoton = treeReader ->UseBranch("Photon");
363 const TClonesArray* branchJet = treeReader ->UseBranch("Jet");
364 const TClonesArray* branchMET = treeReader ->UseBranch("ETmis");
365
366 TRootElectron* elec;
367 TRootMuon* muon;
368 TRootTauJet* tau;
369 TRootPhoton* photon;
370 TRootJet* jet;
371 TRootETmis* met;
372
373 Long64_t allEntries;
374 allEntries=treeReader->GetEntries();
375
376 FROG_Events* frog_events = new FROG_Events();
377 if(nEntryFrog > allEntries)
378 {
379 cout<<"nEntry to display by frog greater than number of available events... Exit"<<endl;
380 return;
381 }
382 for(Int_t entry = 0; entry < nEntryFrog; ++entry){
383// cout<<"Event n° "<<entry<<endl;
384 treeReader ->ReadEntry(entry);
385 treeReaderGen->ReadEntry(entry);
386
387 //Create a new event
388
389 FROG_Element_Event* frog_event = new FROG_Element_Event(1,entry);
390 frog_events->AddEvent(frog_event);
391
392 //Create a new branch in the event with name SIM and ID = EVTID_SIM
393 FROG_Element_Base_With_DetId_And_Name* frog_branchSIM = new FROG_Element_Base_With_DetId_And_Name(EVTID_SIM,"SIM");
394 frog_event->addDaughter(frog_branchSIM);
395
396 //SIM ELEC
397 //Create a new sub-branch in the SIM branch with name Electrons: this sub branch will contais all the electrons
398 FROG_Element_Base_With_DetId_And_Name* frog_branchElectrons = new FROG_Element_Base_With_DetId_And_Name(EVTID_SIM+1000,"Electrons");
399 frog_branchSIM->addDaughter(frog_branchElectrons);
400
401 for(int p=0;p<branchElectron->GetEntriesFast();p++){
402 elec = (TRootElectron*) branchElectron->At(p);
403// cout<<"Elec nO "<<p<<" PT: "<<elec->PT<<" Eta "<<elec->Eta<<" Phi"<<elec->Phi<<endl;
404 FROG_Element_Event_Candidate* frog_elec = new FROG_Element_Event_Candidate(11,elec->E,elec->Eta,elec->Phi);
405
406 frog_branchElectrons->addDaughter(frog_elec);
407 }
408
409 //SIM MUONS
410 //Create a new sub-branch in the SIM branch with name Muons: this sub branch will contais all the muons
411 FROG_Element_Base_With_DetId_And_Name* frog_branchMuons = new FROG_Element_Base_With_DetId_And_Name(EVTID_SIM+2000,"Muons");
412 frog_branchSIM->addDaughter(frog_branchMuons);
413 for(int p=0;p<branchMuon->GetEntriesFast();p++){
414 muon = (TRootMuon*) branchMuon->At(p);
415// cout<<"Muon nO"<<p<<" PT: "<<muon->PT<<"Eta "<<muon->Eta<<" Phi"<<muon->Phi<<endl;
416 FROG_Element_Event_Candidate* frog_muon = new FROG_Element_Event_Candidate(13,muon->E,muon->Eta,muon->Phi);
417 frog_branchMuons->addDaughter(frog_muon);
418 }
419
420 //SIM TAUS
421 //Create a new sub-branch in the SIM branch with name Taus: this sub branch will contais all the Taus
422 FROG_Element_Base_With_DetId_And_Name* frog_branchTaus = new FROG_Element_Base_With_DetId_And_Name(EVTID_SIM+3000,"Taus");
423 frog_branchSIM->addDaughter(frog_branchTaus);
424 for(int p=0;p<branchTau->GetEntriesFast();p++){
425 tau = (TRootTauJet*) branchTau->At(p);
426// cout<<"Tau nO"<<p<<" PT: "<<tau->PT<<"Eta "<<tau->Eta<<" Phi"<<tau->Phi<<endl;
427 FROG_Element_Event_Candidate* frog_tau = new FROG_Element_Event_Candidate(15,tau->E,tau->Eta,tau->Phi);
428 frog_branchTaus->addDaughter(frog_tau);
429 }
430
431 //SIM PHOTONS
432 //Create a new sub-branch in the SIM branch with name Photons: this sub branch will contais all the Photons
433 FROG_Element_Base_With_DetId_And_Name* frog_branchPhotons = new FROG_Element_Base_With_DetId_And_Name(EVTID_SIM+4000,"Photons");
434 frog_branchSIM->addDaughter(frog_branchPhotons);
435 for(int p=0;p<branchPhoton->GetEntriesFast();p++){
436 photon = (TRootPhoton*) branchPhoton->At(p);
437// cout<<"Photon nO"<<p<<" PT: "<<photon->PT<<"Eta "<<photon->Eta<<" Phi"<<photon->Phi<<endl;
438 FROG_Element_Event_Candidate* frog_photon = new FROG_Element_Event_Candidate(22,photon->E,photon->Eta,photon->Phi);
439 frog_branchPhotons->addDaughter(frog_photon);
440 }
441
442 //SIM JETS
443 //Create a new sub-branch in the SIM branch with name Jets: this sub branch will contais all the Jets
444 FROG_Element_Base_With_DetId_And_Name* frog_branchJets = new FROG_Element_Base_With_DetId_And_Name(EVTID_SIM+5000,"Jets");
445 frog_branchSIM->addDaughter(frog_branchJets);
446 for(int p=0;p<branchJet->GetEntriesFast();p++){
447 jet = (TRootJet*) branchJet->At(p);
448// cout<<"Jet nO"<<p<<" PT: "<<jet->PT<<"Eta "<<jet->Eta<<" Phi"<<jet->Phi<<endl;
449 FROG_Element_Event_Jet* frog_jet = new FROG_Element_Event_Jet(jet->E,jet->Eta,jet->Phi);
450 frog_branchJets->addDaughter(frog_jet);
451 }
452
453 //SIM MET
454 //Create a new sub-branch in the SIM branch with name MET: this sub branch will contais all the METs
455 FROG_Element_Base_With_DetId_And_Name* frog_branchMET = new FROG_Element_Base_With_DetId_And_Name(EVTID_SIM+6000,"MET");
456 frog_branchSIM->addDaughter(frog_branchMET);
457 for(int p=0;p<branchMET->GetEntriesFast();p++){
458 met = (TRootETmis*) branchMET->At(p);
459// cout<<"MET nO"<<p<<" ET: "<<met->ET<<"Eta "<<0<<" Phi"<<met->Phi<<endl;
460 FROG_Element_Event_MET* frog_met = new FROG_Element_Event_MET(0,met->ET,0,met->Phi, met->ET);
461 frog_branchMET->addDaughter(frog_met);
462 }
463
464 //Save the event in the .vis file
465 frog_events->SaveInLive("DelphesToFrog.vis",false,false,(unsigned int)-1);
466 }
467
468 delete treeReader;
469 delete treeReaderGen;
470 delete frog_events;
471}
472
473void FrogDisplay::BuildGeom(string DetDatacard)
474{
475 //Smearing information
476 RESOLution *DET = new RESOLution();
477 DET->ReadDataCard(DetDatacard);
478
479 // This element is the root of the "file" tree. (don't change this line)
480 FROG_Element_Base* prim = new FROG_Element_Base(C_PRIMARY);
481
482 FROG_Element_Base* mygeom = new FROG_Element_Base(C_GEOMETRY);
483 prim->addDaughter(mygeom);
484
485 FROG_Element_Base_With_DetId_And_Name* detector = new FROG_Element_Base_With_DetId_And_Name(900000000,"Delphes");
486 mygeom->addDaughter(detector);
487
488 double Rayon_Tracker=40;
489 double Rayon_Calo = Rayon_Tracker*1.5;
490 double Rayon_Muon = Rayon_Tracker*2;
491 double Lenght_Tracker=100;
492 double Lenght_Calo=Lenght_Tracker+Lenght_Tracker/2.5;
493 double Lenght_Muon=Lenght_Calo+Lenght_Calo/2.5;
494 double Lenght_CaloFwd=Lenght_Muon+Lenght_Muon/2.5;
495
496 int NumPhi=100;
497 float frac=1;
498
499 //************************************************Tracker*************************************************
500 //********************************************************************************************************
501
502 FROG_Element_Base_With_DetId_And_Name* Tracker = new FROG_Element_Base_With_DetId_And_Name(910000000,"Tracker");
503 detector->addDaughter(Tracker);
504 unsigned int DetIdCountTracker = 1;
505
506 double ray=Rayon_Tracker;
507 double rayCone = tan(EtaToTheta(DET->CEN_max_tracker))*Lenght_Tracker/2;
508 if(ray < rayCone)ray=rayCone;
509
510 double dphi = 6.283185307179586476925286766559 /NumPhi;
511 for(double phi=0; phi<=twopi/frac;phi+=dphi){
512
513 FROG_Element_Primitive_CustomSurface* trackerCone1 = new FROG_Element_Primitive_CustomSurface(9100000+DetIdCountTracker*10,
514 rayCone*sin(phi) ,rayCone*cos(phi) ,-Lenght_Tracker/2,
515 rayCone*sin(phi+dphi) ,rayCone*cos(phi+dphi) ,-Lenght_Tracker/2,
516 0 , 0 , 0,
517 0 , 0 , 0);
518 Tracker->addDaughter(trackerCone1); DetIdCountTracker++;
519
520 FROG_Element_Primitive_CustomSurface* trackerCone2 = new FROG_Element_Primitive_CustomSurface(9100000+DetIdCountTracker*10,
521 0 , 0 ,0,
522 0 , 0 ,0,
523 rayCone*sin(phi) , rayCone*cos(phi) , Lenght_Tracker/2,
524 rayCone*sin(phi+dphi) , rayCone*sin(phi+dphi) , Lenght_Tracker/2);
525 Tracker->addDaughter(trackerCone2); DetIdCountTracker++;
526
527
528 FROG_Element_Primitive_CustomSurface* trackerB = new FROG_Element_Primitive_CustomSurface(9100000+DetIdCountTracker*10,
529 ray*sin(phi) ,ray*cos(phi) ,-Lenght_Tracker*0.5,
530 ray*sin(phi+dphi) ,ray*cos(phi+dphi) ,-Lenght_Tracker*0.5,
531 ray*sin(phi+dphi) ,ray*cos(phi+dphi) , Lenght_Tracker*0.5,
532 ray*sin(phi) ,ray*cos(phi) , Lenght_Tracker*0.5);
533 Tracker->addDaughter(trackerB); DetIdCountTracker++;
534
535 FROG_Element_Primitive_CustomSurface* trackerEndCap1 = new FROG_Element_Primitive_CustomSurface(9100000+DetIdCountTracker*10,
536 rayCone*sin(phi) , rayCone*cos(phi) , -(Lenght_Tracker)/2,
537 rayCone*sin(phi+dphi) , rayCone*cos(phi+dphi) , -(Lenght_Tracker)/2,
538 ray*sin(phi+dphi) , ray*cos(phi+dphi) , -(Lenght_Tracker)/2,
539 ray*sin(phi) , ray*cos(phi) , -(Lenght_Tracker)/2);
540 Tracker->addDaughter(trackerEndCap1); DetIdCountTracker++;
541
542 FROG_Element_Primitive_CustomSurface* trackerEndCap2 = new FROG_Element_Primitive_CustomSurface(9100000+DetIdCountTracker*10,
543 rayCone*sin(phi) , rayCone*cos(phi) , (Lenght_Tracker)/2,
544 rayCone*sin(phi+dphi) , rayCone*cos(phi+dphi) , (Lenght_Tracker)/2,
545 ray*sin(phi+dphi) , ray*cos(phi+dphi) , (Lenght_Tracker)/2,
546 ray*sin(phi) , ray*cos(phi) , (Lenght_Tracker)/2);
547 Tracker->addDaughter(trackerEndCap2); DetIdCountTracker++;
548
549 }
550
551 Rayon_Calo = ray*1.5;
552
553 //******************************************Central calorimeters******************************************
554 //********************************************************************************************************
555
556 FROG_Element_Base_With_DetId_And_Name* CALO = new FROG_Element_Base_With_DetId_And_Name(920000000,"Calo");
557 detector->addDaughter(CALO);
558 unsigned int DetIdCountCalo = 1;
559
560 float rayConeD = tan(EtaToTheta(DET->CEN_max_calo_cen))*Lenght_Tracker/2;
561 float rayConeF = tan(EtaToTheta(DET->CEN_max_calo_cen))*Lenght_Calo/2;
562 ray=Rayon_Calo;
563 if(ray<rayConeF)ray=rayConeF;
564
565 for(double phi=0; phi<=twopi/frac;phi+=dphi){
566
567 //BARREL
568 FROG_Element_Primitive_CustomSurface* caloB = new FROG_Element_Primitive_CustomSurface(9100000+DetIdCountCalo*10,
569 ray*sin(phi) ,ray*cos(phi) ,-Lenght_Calo*0.5,
570 ray*sin(phi+dphi) ,ray*cos(phi+dphi) ,-Lenght_Calo*0.5,
571 ray*sin(phi+dphi) ,ray*cos(phi+dphi) , Lenght_Calo*0.5,
572 ray*sin(phi) ,ray*cos(phi) , Lenght_Calo*0.5);
573 CALO->addDaughter(caloB); DetIdCountCalo++;
574
575 //Partial cone + side
576 FROG_Element_Primitive_CustomSurface* caloEndCap1a = new FROG_Element_Primitive_CustomSurface(9200000+DetIdCountCalo*10,
577 rayConeD*sin(phi) , rayConeD*cos(phi) , (Lenght_Tracker)/2,
578 rayConeD*sin(phi+dphi) , rayConeD*cos(phi+dphi) , (Lenght_Tracker)/2,
579 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , (Lenght_Calo)/2,
580 rayConeF*sin(phi) , rayConeF*cos(phi) , (Lenght_Calo)/2);
581 CALO->addDaughter(caloEndCap1a); DetIdCountCalo++;
582
583 //Close Endcap + side
584 FROG_Element_Primitive_CustomSurface* caloEndCap1b = new FROG_Element_Primitive_CustomSurface(9200000+DetIdCountTracker*10,
585 rayConeF*sin(phi) , rayConeF*cos(phi) , (Lenght_Calo)/2,
586 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , (Lenght_Calo)/2,
587 ray*sin(phi+dphi) , ray*cos(phi+dphi) , (Lenght_Calo)/2,
588 ray*sin(phi) , ray*cos(phi) , (Lenght_Calo)/2);
589 CALO->addDaughter(caloEndCap1b); DetIdCountCalo++;
590
591 //Partial cone - side
592 FROG_Element_Primitive_CustomSurface* caloEndCap2a = new FROG_Element_Primitive_CustomSurface(9200000+DetIdCountCalo*10,
593 rayConeD*sin(phi) , rayConeD*cos(phi) , -(Lenght_Tracker)/2,
594 rayConeD*sin(phi+dphi) , rayConeD*cos(phi+dphi) , -(Lenght_Tracker)/2,
595 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , -(Lenght_Calo)/2,
596 rayConeF*sin(phi) , rayConeF*cos(phi) , -(Lenght_Calo)/2);
597 CALO->addDaughter(caloEndCap2a); DetIdCountCalo++;
598
599 //Close Endcap - side
600 FROG_Element_Primitive_CustomSurface* caloEndCap2b = new FROG_Element_Primitive_CustomSurface(9200000+DetIdCountTracker*10,
601 rayConeF*sin(phi) , rayConeF*cos(phi) , -(Lenght_Calo)/2,
602 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , -(Lenght_Calo)/2,
603 ray*sin(phi+dphi) , ray*cos(phi+dphi) , -(Lenght_Calo)/2,
604 ray*sin(phi) , ray*cos(phi) , -(Lenght_Calo)/2);
605 CALO->addDaughter(caloEndCap2b); DetIdCountCalo++;
606
607 }
608
609 Rayon_Muon = ray*1.2;
610
611 //***********************************************Muon chambers********************************************
612 //********************************************************************************************************
613
614 FROG_Element_Base_With_DetId_And_Name* MUON = new FROG_Element_Base_With_DetId_And_Name(930000000,"Muon");
615 detector->addDaughter(MUON);
616 unsigned int DetIdCountMuon = 1;
617
618 rayConeD = tan(EtaToTheta(DET->CEN_max_mu))*Lenght_Calo/2;
619 rayConeF = tan(EtaToTheta(DET->CEN_max_mu))*Lenght_Muon/2;
620 ray=Rayon_Muon;
621 if(ray<rayConeF)ray=rayConeF;
622
623 for(double phi=0; phi<=twopi/frac;phi+=dphi){
624
625 //BARREL
626 FROG_Element_Primitive_CustomSurface* muonB = new FROG_Element_Primitive_CustomSurface(9300000+DetIdCountMuon*10,
627 ray*sin(phi) ,ray*cos(phi) ,-Lenght_Muon*0.5,
628 ray*sin(phi+dphi) ,ray*cos(phi+dphi) ,-Lenght_Muon*0.5,
629 ray*sin(phi+dphi) ,ray*cos(phi+dphi) , Lenght_Muon*0.5,
630 ray*sin(phi) ,ray*cos(phi) , Lenght_Muon*0.5);
631 MUON->addDaughter(muonB); DetIdCountMuon++;
632
633 //Partial cone + side
634 FROG_Element_Primitive_CustomSurface* muonEndCap1a = new FROG_Element_Primitive_CustomSurface(9300000+DetIdCountMuon*10,
635 rayConeD*sin(phi) , rayConeD*cos(phi) , (Lenght_Calo)/2,
636 rayConeD*sin(phi+dphi) , rayConeD*cos(phi+dphi) , (Lenght_Calo)/2,
637 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , (Lenght_Muon)/2,
638 rayConeF*sin(phi) , rayConeF*cos(phi) , (Lenght_Muon)/2);
639 MUON->addDaughter(muonEndCap1a); DetIdCountMuon++;
640
641 //Close Endcap + side
642 FROG_Element_Primitive_CustomSurface* muonEndCap1b = new FROG_Element_Primitive_CustomSurface(9300000+DetIdCountMuon*10,
643 rayConeF*sin(phi) , rayConeF*cos(phi) , (Lenght_Muon)/2,
644 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , (Lenght_Muon)/2,
645 ray*sin(phi+dphi) , ray*cos(phi+dphi) , (Lenght_Muon)/2,
646 ray*sin(phi) , ray*cos(phi) , (Lenght_Muon)/2);
647 MUON->addDaughter(muonEndCap1b); DetIdCountMuon++;
648
649 //Partial cone - side
650 FROG_Element_Primitive_CustomSurface* muonEndCap2a = new FROG_Element_Primitive_CustomSurface(9300000+DetIdCountMuon*10,
651 rayConeD*sin(phi) , rayConeD*cos(phi) , -(Lenght_Calo)/2,
652 rayConeD*sin(phi+dphi) , rayConeD*cos(phi+dphi) , -(Lenght_Calo)/2,
653 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , -(Lenght_Muon)/2,
654 rayConeF*sin(phi) , rayConeF*cos(phi) , -(Lenght_Muon)/2);
655 MUON->addDaughter(muonEndCap2a); DetIdCountMuon++;
656
657 //Close Endcap - side
658 FROG_Element_Primitive_CustomSurface* muonEndCap2b = new FROG_Element_Primitive_CustomSurface(9300000+DetIdCountMuon*10,
659 rayConeF*sin(phi) , rayConeF*cos(phi) , -(Lenght_Muon)/2,
660 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , -(Lenght_Muon)/2,
661 ray*sin(phi+dphi) , ray*cos(phi+dphi) , -(Lenght_Muon)/2,
662 ray*sin(phi) , ray*cos(phi) , -(Lenght_Muon)/2);
663 MUON->addDaughter(muonEndCap2b); DetIdCountMuon++;
664 }
665
666
667 //******************************************Forward calorimeters******************************************
668 //********************************************************************************************************
669
670 FROG_Element_Base_With_DetId_And_Name* CALOFWD = new FROG_Element_Base_With_DetId_And_Name(940000000,"CaloFwd");
671 detector->addDaughter(CALOFWD);
672 unsigned int DetIdCountCaloFwd = 1;
673
674 rayConeD = tan(EtaToTheta(DET->CEN_max_calo_fwd))*Lenght_Muon;
675 rayConeF = tan(EtaToTheta(DET->CEN_max_calo_fwd))*Lenght_CaloFwd;
676 ray=tan(EtaToTheta(DET->CEN_max_calo_cen))*Lenght_CaloFwd;
677
678 for(double phi=0; phi<=twopi/frac;phi+=dphi){
679
680 //Partial cone + side
681 FROG_Element_Primitive_CustomSurface* caloFWDEndCap1a = new FROG_Element_Primitive_CustomSurface(9400000+DetIdCountCaloFwd*10,
682 rayConeD*sin(phi) , rayConeD*cos(phi) , (Lenght_Muon)/2,
683 rayConeD*sin(phi+dphi) , rayConeD*cos(phi+dphi) , (Lenght_Muon)/2,
684 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , (Lenght_CaloFwd)/2,
685 rayConeF*sin(phi) , rayConeF*cos(phi) , (Lenght_CaloFwd)/2);
686 CALOFWD->addDaughter(caloFWDEndCap1a); DetIdCountCaloFwd++;
687
688 //Close Endcap + side
689 FROG_Element_Primitive_CustomSurface* caloFWDEndCap1b = new FROG_Element_Primitive_CustomSurface(9400000+DetIdCountCaloFwd*10,
690 rayConeF*sin(phi) , rayConeF*cos(phi) , (Lenght_CaloFwd)/2,
691 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , (Lenght_CaloFwd)/2,
692 ray*sin(phi+dphi) , ray*cos(phi+dphi) , (Lenght_CaloFwd)/2,
693 ray*sin(phi) , ray*cos(phi) , (Lenght_CaloFwd)/2);
694 CALOFWD->addDaughter(caloFWDEndCap1b); DetIdCountCaloFwd++;
695
696 //BARREL
697 FROG_Element_Primitive_CustomSurface* caloFWDB1 = new FROG_Element_Primitive_CustomSurface(9400000+DetIdCountMuon*10,
698 ray*sin(phi) ,ray*cos(phi) , Lenght_Muon*0.5,
699 ray*sin(phi+dphi) ,ray*cos(phi+dphi) , Lenght_Muon*0.5,
700 ray*sin(phi+dphi) ,ray*cos(phi+dphi) , Lenght_CaloFwd*0.5,
701 ray*sin(phi) ,ray*cos(phi) , Lenght_CaloFwd*0.5);
702 CALOFWD->addDaughter(caloFWDB1); DetIdCountCaloFwd++;
703
704 //Partial cone - side
705 FROG_Element_Primitive_CustomSurface* caloFWDEndCap2a = new FROG_Element_Primitive_CustomSurface(9400000+DetIdCountCaloFwd*10,
706 rayConeD*sin(phi) , rayConeD*cos(phi) , -(Lenght_Muon)/2,
707 rayConeD*sin(phi+dphi) , rayConeD*cos(phi+dphi) , -(Lenght_Muon)/2,
708 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , -(Lenght_CaloFwd)/2,
709 rayConeF*sin(phi) , rayConeF*cos(phi) , -(Lenght_CaloFwd)/2);
710 CALOFWD->addDaughter(caloFWDEndCap2a); DetIdCountCaloFwd++;
711
712 //Close Endcap - side
713 FROG_Element_Primitive_CustomSurface* caloFWDEndCap2b = new FROG_Element_Primitive_CustomSurface(9400000+DetIdCountCaloFwd*10,
714 rayConeF*sin(phi) , rayConeF*cos(phi) , -(Lenght_CaloFwd)/2,
715 rayConeF*sin(phi+dphi) , rayConeF*cos(phi+dphi) , -(Lenght_CaloFwd)/2,
716 ray*sin(phi+dphi) , ray*cos(phi+dphi) , -(Lenght_CaloFwd)/2,
717 ray*sin(phi) , ray*cos(phi) , -(Lenght_CaloFwd)/2);
718 CALOFWD->addDaughter(caloFWDEndCap2b); DetIdCountCaloFwd++;
719
720 //BARREL
721 FROG_Element_Primitive_CustomSurface* caloFWDB2 = new FROG_Element_Primitive_CustomSurface(9400000+DetIdCountMuon*10,
722 ray*sin(phi) ,ray*cos(phi) , -Lenght_Muon*0.5,
723 ray*sin(phi+dphi) ,ray*cos(phi+dphi) , -Lenght_Muon*0.5,
724 ray*sin(phi+dphi) ,ray*cos(phi+dphi) , -Lenght_CaloFwd*0.5,
725 ray*sin(phi) ,ray*cos(phi) , -Lenght_CaloFwd*0.5);
726 CALOFWD->addDaughter(caloFWDB2); DetIdCountCaloFwd++;
727 }
728
729
730
731
732 FROG_Geometry* CustomGeom = new FROG_Geometry(prim);
733 CustomGeom->Save("DelphesToFrog.geom");
734
735 //FROG_ELEMENT::PrintTree(prim);
736 return;
737
738}
739
Note: See TracBrowser for help on using the repository browser.