Fork me on GitHub

source: svn/trunk/src/VeryForward.cc@ 242

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

memory leak free code

File size: 7.2 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#include "VeryForward.h"
12#include "H_RomanPot.h"
13#include <iostream>
14#include<cmath>
15
16using namespace std;
17
18
19//------------------------------------------------------------------------------
20
21VeryForward::VeryForward() {
22 DET = new RESOLution();
23 beamline1 = new H_BeamLine(1,500.);
24 beamline2 = new H_BeamLine(1,500.);
25 init();
26 //Initialisation of Hector
27 relative_energy = true; // should always be true
28 kickers_on = 1; // should always be 1
29
30}
31
32VeryForward::VeryForward(const string& DetDatacard) {
33 DET = new RESOLution();
34 DET->ReadDataCard(DetDatacard);
35 beamline1 = new H_BeamLine(1,500.);
36 beamline2 = new H_BeamLine(1,500.);
37 init();
38 //Initialisation of Hector
39 relative_energy = true; // should always be true
40 kickers_on = 1; // should always be 1
41
42}
43
44VeryForward::VeryForward(const RESOLution * DetDatacard) {
45 DET = new RESOLution(*DetDatacard);
46 beamline2 = new H_BeamLine(1,500.);
47 beamline1 = new H_BeamLine(1,500.);
48
49 init();
50 //Initialisation of Hector
51 relative_energy = true; // should always be true
52 kickers_on = 1; // should always be 1
53
54}
55
56VeryForward::VeryForward(const VeryForward& vf) {
57 DET = new RESOLution(*(vf.DET));
58 beamline1 = new H_BeamLine(*(vf.beamline1));
59 beamline2 = new H_BeamLine(*(vf.beamline2));
60}
61
62VeryForward& VeryForward::operator=(const VeryForward& vf){
63 if (this==&vf) return *this;
64 DET = new RESOLution(*(vf.DET));
65 beamline1 = new H_BeamLine(*(vf.beamline1));
66 beamline2 = new H_BeamLine(*(vf.beamline2));
67 return *this;
68}
69
70
71void VeryForward::init() {
72 //Initialisation of Hector
73 relative_energy = true; // should always be true
74 kickers_on = 1; // should always be 1
75
76 // user should provide : (1) optics file for each beamline, and IPname,
77 // and offset data (s,x) for optical elements
78 beamline1->fill("data/LHCB1IR5_v6.500.tfs",1,"IP5");
79 beamline1->offsetElements(120,-0.097);
80 H_RomanPot * rp220_1 = new H_RomanPot("rp220_1",220,2000); // RP 220m, 2mm, beam 1
81 H_RomanPot * rp420_1 = new H_RomanPot("rp420_1",420,4000); // RP 420m, 4mm, beam 1
82 beamline1->add(rp220_1);
83 beamline1->add(rp420_1);
84
85 beamline2->fill("data/LHCB1IR5_v6.500.tfs",-1,"IP5");
86 beamline2->offsetElements(120,+0.097);
87 H_RomanPot * rp220_2 = new H_RomanPot("rp220_2",220,2000);// RP 220m, 2mm, beam 2
88 H_RomanPot * rp420_2 = new H_RomanPot("rp420_2",420,4000);// RP 420m, 4mm, beam 2
89 beamline2->add(rp220_2);
90 beamline2->add(rp420_2);
91 // rp220_1, rp220_2, rp420_1 and rp420_2 will be deallocated in ~H_AbstractBeamLine
92 // do not put explicit delete
93}
94
95
96void VeryForward::ZDC(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchZDC,TRootGenParticle *particle)
97{
98 int pid=abs(particle->PID);
99 float eta=fabs(particle->Eta);
100
101
102 TRootZdcHits *elementZdc;
103 TLorentzVector genMomentum;
104 // Zero degree calorimeter, for forward neutrons and photons
105 if (particle->Status ==1 && (pid == pN || pid == pGAMMA ) && eta > DET->VFD_min_zdc ) {
106 genMomentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
107 // !!!!!!!!! vérifier que particle->Z est bien en micromÚtres!!!
108 // !!!!!!!!! vérifier que particle->T est bien en secondes!!!
109 // !!!!!!!!! pas de smearing ! on garde trop d'info !
110 elementZdc = (TRootZdcHits*) branchZDC->NewEntry();
111 elementZdc->Set(genMomentum);
112
113 // time of flight t is t = T + d/[ cos(theta) v ]
114 //double tx = acos(particle->Px/particle->Pz);
115 //double ty = acos(particle->Py/particle->Pz);
116 //double theta = (1E-6)*sqrt( pow(tx,2) + pow(ty,2) );
117 //double flight_distance = (DET->ZDC_S - particle->Z*(1E-6))/cos(theta) ; // assumes that Z is in micrometers
118 double flight_distance = (DET->VFD_s_zdc - particle->Z*(1E-6));
119 // assumes also that the emission angle is so small that 1/(cos theta) = 1
120 elementZdc->T = 0*particle->T + flight_distance/speed_of_light; // assumes highly relativistic particles
121 elementZdc->side = sign(eta);
122
123
124 }
125
126}
127void VeryForward::RomanPots(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchRP220,ExRootTreeBranch *branchFP420,TRootGenParticle *particle)
128{
129 int pid=abs(particle->PID);
130 float eta=fabs(particle->Eta);
131
132 TRootRomanPotHits* elementRP220;
133 TRootRomanPotHits* elementFP420;
134
135 TLorentzVector genMomentum;
136 genMomentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
137 // if forward proton
138 if( (pid == pP) && (particle->Status == 1) && (fabs(genMomentum.Eta()) > DET->CEN_max_calo_fwd) )
139 {
140 // !!!!!!!! put here particle->CHARGE and particle->MASS
141 H_BeamParticle p1; /// put here particle->CHARGE and particle->MASS
142 p1.smearAng();
143 p1.smearPos();
144 p1.setPosition(p1.getX()-500.,p1.getY(),p1.getTX()-1*kickers_on*CRANG,p1.getTY(),0);
145 p1.set4Momentum(particle->Px,particle->Py,particle->Pz,particle->E);
146
147 H_BeamLine *beamline;
148 if(genMomentum.Eta() >0) beamline = beamline1;
149 else beamline = beamline2;
150
151 p1.computePath(beamline,1);
152
153 if(p1.stopped(beamline)) {
154 if (p1.getStoppingElement()->getName()=="rp220_1" || p1.getStoppingElement()->getName()=="rp220_2") {
155 p1.propagate(DET->RP_220_s);
156 elementRP220 = (TRootRomanPotHits*) branchRP220->NewEntry();
157 elementRP220->X = (1E-6)*p1.getX(); // [m]
158 elementRP220->Y = (1E-6)*p1.getY(); // [m]
159 elementRP220->Tx = (1E-6)*p1.getTX(); // [rad]
160 elementRP220->Ty = (1E-6)*p1.getTY(); // [rad]
161 elementRP220->S = p1.getS(); // [m]
162 elementRP220->T = -1; // not yet implemented
163 elementRP220->E = p1.getE(); // not yet implemented
164 elementRP220->q2 = -1; // not yet implemented
165 elementRP220->side = sign(eta);
166
167 } else if (p1.getStoppingElement()->getName()=="rp420_1" || p1.getStoppingElement()->getName()=="rp420_2") {
168 p1.propagate(DET->RP_420_s);
169 elementFP420 = (TRootRomanPotHits*) branchFP420->NewEntry();
170 elementFP420->X = (1E-6)*p1.getX(); // [m]
171 elementFP420->Y = (1E-6)*p1.getY(); // [m]
172 elementFP420->Tx = (1E-6)*p1.getTX(); // [rad]
173 elementFP420->Ty = (1E-6)*p1.getTY(); // [rad]
174 elementFP420->S = p1.getS(); // [m]
175 elementFP420->T = -1; // not yet implemented
176 elementFP420->E = p1.getE(); // not yet implemented
177 elementFP420->q2 = -1; // not yet implemented
178 elementFP420->side = sign(eta);
179 }
180
181 }
182 // if(p1.stopped(beamline) && (p1.getStoppingElement()->getS() > 100))
183 // cout << "Eloss =" << 7000.-p1.getE() << " ; " << p1.getStoppingElement()->getName() << endl;
184 } // if forward proton
185}
186
187 // Forward particles in CASTOR ?
188 // /* if (particle->Status == 1 && (fabs(particle->Eta) > DET->MIN_CALO_VFWD)
189 // && (fabs(particle->Eta) < DET->MAX_CALO_VFWD)) {
190 //
191 //
192 // } // CASTOR
193 // */
194 //
Note: See TracBrowser for help on using the repository browser.