FairRoot/PandaRoot
RhoBooster.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: RhoBooster.cxx,v 1.4 2002-02-01 23:00:05 marcel Exp $
4 //
5 // Description:
6 // Class RhoBooster
7 //
8 // Environment:
9 // Software developed for the BaBar Detector at the SLAC B-Factory.
10 //
11 // Author List:
12 // Gautier Hamel de Monchenault - CEN Saclay & Lawrence Berkeley Lab
13 //
14 // History (add to end):
15 // Gautier Sept, 1997 - creation
16 //
17 // Copyright Information:
18 // Copyright (C) 1997 Lawrence Berkeley Laboratory
19 // Copyright (C) 1997 CEA - Centre d'Etude de Saclay
20 //
21 // ROOT Version by Marcel Kunze, RUB
22 // Ralf Kliemt, HIM/GSI Feb.2013 (Cleanup & Restructuring)
23 //------------------------------------------------------------------------
24 
25 #include "RhoTools/RhoBooster.h"
26 
28 
29 TBuffer& operator>> ( TBuffer& buf, RhoBooster *&obj )
30 {
31  obj = ( RhoBooster* ) buf.ReadObject ( RhoBooster::Class() );
32  return buf;
33 }
34 
35 #include <iostream>
36 using namespace std;
37 
38 //
39 // Constructors
40 //
41 
42 RhoBooster::RhoBooster ( const RhoCandidate* referenceCand, Bool_t saveCovMatrix )
43  : fBoostVector ( 0.,0.,0. ),
44 // fRotateAndBoostTo(0),
45 // fRotateAndBoostFrom(0),
46  fSaveCovMatrix ( saveCovMatrix )
47 {
48  if ( referenceCand ) SetBoostVector(referenceCand);
49 }
50 
51 RhoBooster::RhoBooster ( const RhoCandidate& referenceCand, Bool_t saveCovMatrix )
52  : fBoostVector ( 0.,0.,0. ),
53 // fRotateAndBoostTo(0),
54 // fRotateAndBoostFrom(0),
55  fSaveCovMatrix ( saveCovMatrix )
56 {
57  SetBoostVector(referenceCand);
58 }
59 
60 RhoBooster::RhoBooster ( const TLorentzVector& lorentzVector, Bool_t saveCovMatrix )
61  : fBoostVector ( 0.,0.,0. ),
62 // fRotateAndBoostTo(0),
63 // fRotateAndBoostFrom(0),
64  fSaveCovMatrix ( saveCovMatrix )
65 {
66  SetBoostVector(lorentzVector);
67 }
68 
69 RhoBooster::RhoBooster ( const TVector3& boostVector, Bool_t saveCovMatrix )
70  : fBoostVector ( 0.,0.,0. ),
71 // fRotateAndBoostTo(0),
72 // fRotateAndBoostFrom(0),
73  fSaveCovMatrix ( saveCovMatrix )
74 {
75  SetBoostVector(boostVector);
76 }
77 
78 
79 //--------------
80 // Destructor --
81 //--------------
82 
84 {
85  //clean();
86 }
87 
88 // void
89 // RhoBooster::clean()
90 // {
91 // if(fRotateAndBoostTo) delete fRotateAndBoostTo;
92 // fRotateAndBoostTo=0;
93 // if(fRotateAndBoostFrom) delete fRotateAndBoostFrom;
94 // fRotateAndBoostFrom=0;
95 // }
96 
98 RhoBooster::BoostTo ( const RhoCandidate& cand ) const
99 {
100  return Boost ( cand, To );
101 }
102 
104 RhoBooster::BoostFrom ( const RhoCandidate& cand ) const
105 {
106  return Boost ( cand, From );
107 }
108 
109 void
111  RhoCandList& boostedList,
112  Bool_t cleanList ) const
113 {
114  if ( cleanList ) {
115  boostedList.Cleanup();
116  }
117  RhoCandListIterator iter ( initialList );
118  RhoCandidate* cand=0;
119  while ( (cand=iter.Next()) ) {
120  boostedList.Add ( &(Boost ( *cand, To )) );
121  }
122 }
123 
124 void
126  RhoCandList& boostedList,
127  Bool_t cleanList ) const
128 {
129  if ( cleanList ) {
130  boostedList.Cleanup();
131  }
132  RhoCandListIterator iter ( initialList );
133  RhoCandidate* cand=0;
134  while ( (cand=iter.Next()) ) {
135  boostedList.Add ( &(Boost ( *cand, From )) );
136  }
137 }
138 
139 
140 // -----------------------------------------
141 // -- Private Function Member Definitions --
142 // -----------------------------------------
143 
146  BoostSign sign ) const
147 {
149  if ( sign == To ) {
150  bc->Boost ( -fBoostVector );
151  } else {
152  bc->Boost ( fBoostVector );
153  }
154  return *bc;
155 
156  // // recursive implementation
157  // // the function returns a poInt_ter to the current mother
158  // // in order to establish mother-daughter links
159  // //
160  // // 1) get the boost vector beta=p/E of the moving frame.
161  // TVector3 beta( theLorentzVector().fBoostVector() );
162  // // boostTo : -beta
163  // // boostFrom : beta
164  // if( sign==To ) beta *= -1;
165  // // 2) now apply the boost to the four-vector
166  // TLorentzVector the4Vector( cand.p4() ); // four-vector of the candidate
167  // the4Vector.boost( beta ); // boost it along the boost vector
168 
169  // Create a instance of a RhoCandidate with the boosted 4-vector
170  // the problem is that we loose all connection with the original...
171  // the solution would be to copy the RhoCandidate and then
172  // to boost it !!! We are missing a boost method in RhoCandidate,
173  // or in TCandBase.
174 
175 // if ( fSaveCovMatrix == kTRUE ) {
176 // const TLorentzVector& boosted4Mtm = BoostedP4 ( cand, sign );
177 // // Boost 4-momentum error (covariance) matrix
178 // const RhoLorentzVectorErr& boostedCovError = BoostedError ( cand, sign );
179 //
180 // // Don't boost decay vertex - this will have a different meaning in the boosted
181 // // frame - a new re-fit of the boosted candidates would need to be done to get the
182 // // correct vertex in the boosted frame. Also, can't change the values
183 // // of the vertex in the abstract class, TAbsVertex, unless we know what vertexer was
184 // // used. This would complicate the TBooster Interface.
185 //
186 // // Set the trajectory for the boosted RhoCandidate
187 // // (really, set it's new covariance matrix).
188 // Double_t charge = cand.Charge(); // charge is Double_t!
189 // RhoCandidate* boostedCand = RhoFactory::Instance()->NewCandidate ( RhoCandidate ( boosted4Mtm, charge ) );
190 // boostedCand->SetTrajectory ( boosted4Mtm, boostedCovError.CovMatrix(), ( int ) charge, cand.PdtEntry(), 0 );
191 // // now loop on daughters
192 // RhoCandListIterator iterDau = cand.DaughterIterator();
193 // RhoCandidate* daug=0;
194 // while ( daug=iterDau.Next() ) {
195 // const TLorentzVector& boostedDaug4Mtm = BoostedP4 ( *daug, sign );
196 // // Boost 4-momentum error (covariance) matrix
197 // const RhoLorentzVectorErr& boostedDaugCovError = BoostedError ( *daug, sign );
198 // // Set the trajectory for the boosted RhoCandidate
199 // // (really, set it's new covariance matrix).
200 // Double_t daugCharge = daug->Charge(); // charge is Double_t!
201 // RhoCandidate* boostedDaugCand = RhoFactory::Instance()->NewCandidate ( RhoCandidate ( boostedDaug4Mtm, daugCharge ) );
202 // boostedDaugCand->SetTrajectory ( boostedDaug4Mtm, boostedDaugCovError.CovMatrix(), ( int ) daugCharge,
203 // daug->PdtEntry(), 0 );
204 // boostedCand->AddDaughterLink ( boostedDaugCand );
205 // }
206 // // Set mass here when the daughters are defined.
207 // boostedCand->SetMass ( cand.Mass() );
208 // // have to cast off the const because of the RhoCandidate Int_terface !!!!!
209 // if ( cand.PdtEntry() ) { boostedCand->SetType ( cand.PdtEntry() ); }
210 // return *boostedCand;
211 // }
212 //
213 // RhoCandidate* boostedCand = RhoFactory::Instance()->NewCandidate ( RhoCandidate ( BoostedP4 ( cand, sign ), cand.Charge() ) );
214 // //
215 // // now loop on daughters
216 // RhoCandListIterator iterDau = cand.DaughterIterator();
217 // RhoCandidate* dau=0;
218 // while ( dau=iterDau.Next() ) {
219 // RhoCandidate boostedDau = Boost ( *dau, sign );
220 // boostedCand->AddDaughterLink ( &boostedDau );
221 // }
222 //
223 // // Set mass here when the daughters are defined.
224 // boostedCand->SetMass ( cand.Mass() );
225 // if ( cand.PdtEntry() ) { boostedCand->SetType ( cand.PdtEntry() ); }
226 //
227 // // set marker (for overlap checks)
228 // boostedCand->SetMarker ( cand.GetMarker ( 0 ),0 );
229 // boostedCand->SetMarker ( cand.GetMarker ( 1 ),1 );
230 // boostedCand->SetMarker ( cand.GetMarker ( 2 ),2 );
231 // boostedCand->SetMarker ( cand.GetMarker ( 3 ),3 );
232 //
233 // // set link to AOD Information
234 // if ( &cand.GetRecoCandidate() ) {
235 // boostedCand->SetRecoCandidate ( cand.GetRecoCandidate() );
236 // }
237 // return *boostedCand;
238 
239 }
240 
241 // TLorentzVector
242 // RhoBooster::BoostedP4 ( const RhoCandidate& cand, BoostSign sign ) const
243 // {
244 // // new implemetation using Chris Hearty's rotateAndBoost
245 // return RotateAndBoost ( sign ) * cand.P4();
246 // }
247 
248 // RhoLorentzVectorErr
249 // RhoBooster::BoostedError ( const RhoCandidate& cand, BoostSign sign ) const
250 // {
251 //
252 // // Get combined rotation and Lorentz Boost
253 // const TLorentzRotation& rotation = RotateAndBoost ( sign );
254 // // Form BbrLorentzVectorErr object for 4-momentum
255 // // BbrLorentzVectorErr(4-momentum, covariance Matrix)
256 //
257 // RhoLorentzVectorErr theError ( cand.P4(), cand.P4Err() );
258 //
259 // // Now transform this error using the rotation and boost.
260 // // The covariance matrix is changed using a similarity transformation
261 //
262 // return theError.Transform ( rotation );
263 // }
264 
265 
266 // const TLorentzRotation&
267 // RhoBooster::RotateAndBoost ( BoostSign sign ) const
268 // {
269 // TLorentzRotation* rAndB=0;
270 // switch ( sign ) {
271 // case To :
272 // rAndB = fRotateAndBoostTo;
273 // break;
274 // case From:
275 // rAndB = fRotateAndBoostFrom;
276 // break;
277 // default:
278 // cerr << "Unknown case " << endl;
279 // }
280 //
281 // if ( rAndB==0 ) {
282 // // rotation matrix and boost
283 // Double_t boost = fBoostVector.Mag();
284 // TVector3 boostAlongZ ( 0., 0., boost );
285 // TLorentzRotation boostPart ( boostAlongZ );
286 //
287 // Double_t alpha ( fBoostVector.Phi() );
288 // Double_t beta ( fBoostVector.Theta() );
289 // Double_t gamma ( -fBoostVector.Phi() );
290 //
291 // TRotation euler;
292 // euler.RotateZ ( gamma );
293 // euler.RotateY ( beta );
294 // euler.RotateZ ( alpha );
295 //
296 // TLorentzRotation rotationPart ( euler );
297 // TLorentzRotation product ( rotationPart*boostPart );
298 //
299 // rAndB = new TLorentzRotation ( product );
300 //
301 // if ( sign==To ) {
302 // rAndB->Invert();
303 // }
304 // // assign rAndB to the data member
305 // switch ( sign ) {
306 // case To :
307 // fRotateAndBoostTo = rAndB;
308 // break;
309 // case From:
310 // fRotateAndBoostFrom = rAndB;
311 // break;
312 // default:
313 // cerr << "Unknown case " << endl;
314 // }
315 // }
316 //
317 // return *rAndB;
318 //}
319 
void Add(const RhoCandidate *c)
Definition: RhoCandList.h:49
void Cleanup()
Definition: RhoCandList.cxx:62
RhoCandidate & Boost(const RhoCandidate &cand, BoostSign sign) const
Definition: RhoBooster.cxx:145
void Boost(Double_t bx, Double_t by, Double_t bz)
RhoCandidate & BoostFrom(const RhoCandidate &cand) const
Definition: RhoBooster.cxx:104
TVector3 fBoostVector
Definition: RhoBooster.h:122
virtual ~RhoBooster()
Definition: RhoBooster.cxx:83
static RhoFactory * Instance()
Definition: RhoFactory.cxx:34
static RhoCandidate * NewCandidate()
Definition: RhoFactory.cxx:52
ClassImp(PndAnaContFact)
int sign(T val)
Definition: PndCADef.h:48
RhoBooster(const TLorentzVector &cmFrame, Bool_t saveCovMatrix=kFALSE)
Definition: RhoBooster.cxx:60
RhoCandidate & BoostTo(const RhoCandidate &cand) const
Definition: RhoBooster.cxx:98
void SetBoostVector(const TVector3 &cmFrame)
Definition: RhoBooster.h:80