CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWSimTrackProxyBuilder.cc
Go to the documentation of this file.
1 /*
2  * FWSimTrackProxyBuilder.cc
3  * FWorks
4  *
5  * Created by Ianna Osborne on 9/9/10.
6  *
7  */
8 
16 
18 
19 #include "TEveTrack.h"
20 #include "TParticle.h"
21 #include "TDatabasePDG.h"
22 
24 {
25 public:
27  virtual ~FWSimTrackProxyBuilder( void ) {}
28 
30 
31 private:
32  // Disable default copy constructor
34  // Disable default assignment operator
36 
38  virtual void build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* ) override;
39 
40  void addParticlesToPdgDataBase( void );
41 };
42 
43 void
45 {
46  static Bool_t bAdded = kFALSE;
47  // Check if already called
48  if(bAdded)return;
49  bAdded = true;
50 
51  TDatabasePDG *pdgDB = TDatabasePDG::Instance();
52  const Int_t kspe=50000000;
53 
54  // PDG nuclear states are 10-digit numbers
55  // 10LZZZAAAI e.g. deuteron is
56  // 1000010020
57  const Int_t kion=1000000000;
58 
59  /*
60  const Double_t kAu2Gev=0.9314943228;
61  */
62 
63  const Double_t khSlash = 1.0545726663e-27;
64  const Double_t kErg2Gev = 1/1.6021773349e-3;
65  const Double_t khShGev = khSlash*kErg2Gev;
66  const Double_t kYear2Sec = 3600*24*365.25;
67 
68  //
69  // Bottom mesons
70  // mass and life-time from PDG
71  //
72  pdgDB->AddParticle("Upsilon(3S)","Upsilon(3S)",10.3552,kTRUE,
73  0,1,"Bottonium",200553);
74 
75  // QCD diffractive states
76  pdgDB->AddParticle("rho_diff0","rho_diff0",0,kTRUE,
77  0,0,"QCD diffr. state",9900110);
78  pdgDB->AddParticle("pi_diffr+","pi_diffr+",0,kTRUE,
79  0,1,"QCD diffr. state",9900210);
80  pdgDB->AddParticle("omega_di","omega_di",0,kTRUE,
81  0,0,"QCD diffr. state",9900220);
82  pdgDB->AddParticle("phi_diff","phi_diff",0,kTRUE,
83  0,0,"QCD diffr. state",9900330);
84  pdgDB->AddParticle("J/psi_di","J/psi_di",0,kTRUE,
85  0,0,"QCD diffr. state",9900440);
86  pdgDB->AddParticle("n_diffr0","n_diffr0",0,kTRUE,
87  0,0,"QCD diffr. state",9902110);
88  pdgDB->AddParticle("p_diffr+","p_diffr+",0,kTRUE,
89  0,1,"QCD diffr. state",9902210);
90 
91  // From Herwig
92  pdgDB->AddParticle("PSID ", " ", 3.7699, kFALSE, 0.0, 0, "meson", 30443);
93 
94  pdgDB->AddParticle("A_00 ", " ", 0.9960, kFALSE, 0.0, 0, "meson", 9000111);
95  pdgDB->AddParticle("A_0+ ", " ", 0.9960, kFALSE, 0.0,+3, "meson", 9000211);
96  pdgDB->AddParticle("A_0- ", " ", 0.9960, kFALSE, 0.0,-3, "meson", -9000211);
97 
98  pdgDB->AddParticle("F0P0 ", " ", 0.9960, kFALSE, 0.0, 0, "meson", 9010221);
99 
100  pdgDB->AddParticle("KDL_2+ ", " ", 1.773, kFALSE, 0.0,+3, "meson", 10325);
101  pdgDB->AddParticle("KDL_2- ", " ", 1.773, kFALSE, 0.0,-3, "meson", -10325);
102 
103  pdgDB->AddParticle("KDL_20 ", " ", 1.773, kFALSE, 0.0, 0, "meson", 10315);
104  pdgDB->AddParticle("KDL_2BR0", " ", 1.773, kFALSE, 0.0, 0, "meson", -10315);
105 
106  pdgDB->AddParticle("PI_2+ ", " ", 1.670, kFALSE, 0.0,+3, "meson", 10215);
107  pdgDB->AddParticle("PI_2- ", " ", 1.670, kFALSE, 0.0,-3, "meson", -10215);
108  pdgDB->AddParticle("PI_20 ", " ", 1.670, kFALSE, 0.0, 0, "meson", 10115);
109 
110 
111  pdgDB->AddParticle("KD*+ ", " ", 1.717, kFALSE, 0.0,+3, "meson", 30323);
112  pdgDB->AddParticle("KD*- ", " ", 1.717, kFALSE, 0.0,-3, "meson", -30323);
113 
114  pdgDB->AddParticle("KD*0 ", " ", 1.717, kFALSE, 0.0, 0, "meson", 30313);
115  pdgDB->AddParticle("KDBR*0 ", " ", 1.717, kFALSE, 0.0, 0, "meson", -30313);
116 
117  pdgDB->AddParticle("RHOD+ ", " ", 1.700, kFALSE, 0.0,+3, "meson", 30213);
118  pdgDB->AddParticle("RHOD- ", " ", 1.700, kFALSE, 0.0,-3, "meson", -30213);
119  pdgDB->AddParticle("RHOD0 ", " ", 1.700, kFALSE, 0.0, 0, "meson", 30113);
120 
121  pdgDB->AddParticle("ETA_2(L)", " ", 1.632, kFALSE, 0.0, 0, "meson", 10225);
122  pdgDB->AddParticle("ETA_2(H)", " ", 1.854, kFALSE, 0.0, 0, "meson", 10335);
123  pdgDB->AddParticle("OMEGA(H)", " ", 1.649, kFALSE, 0.0, 0, "meson", 30223);
124 
125 
126  pdgDB->AddParticle("KDH_2+ ", " ", 1.816, kFALSE, 0.0,+3, "meson", 20325);
127  pdgDB->AddParticle("KDH_2- ", " ", 1.816, kFALSE, 0.0,-3, "meson", -20325);
128 
129  pdgDB->AddParticle("KDH_20 ", " ", 1.816, kFALSE, 0.0, 0, "meson", 20315);
130  pdgDB->AddParticle("KDH_2BR0", " ", 1.816, kFALSE, 0.0, 0, "meson", -20315);
131 
132 
133  pdgDB->AddParticle("KD_3+ ", " ", 1.773, kFALSE, 0.0,+3, "meson", 327);
134  pdgDB->AddParticle("KD_3- ", " ", 1.773, kFALSE, 0.0,-3, "meson", -327);
135 
136  pdgDB->AddParticle("KD_30 ", " ", 1.773, kFALSE, 0.0, 0, "meson", 317);
137  pdgDB->AddParticle("KD_3BR0 ", " ", 1.773, kFALSE, 0.0, 0, "meson", -317);
138 
139  pdgDB->AddParticle("RHO_3+ ", " ", 1.691, kFALSE, 0.0,+3, "meson", 217);
140  pdgDB->AddParticle("RHO_3- ", " ", 1.691, kFALSE, 0.0,-3, "meson", -217);
141  pdgDB->AddParticle("RHO_30 ", " ", 1.691, kFALSE, 0.0, 0, "meson", 117);
142  pdgDB->AddParticle("OMEGA_3 ", " ", 1.667, kFALSE, 0.0, 0, "meson", 227);
143  pdgDB->AddParticle("PHI_3 ", " ", 1.854, kFALSE, 0.0, 0, "meson", 337);
144 
145  pdgDB->AddParticle("CHI2P_B0", " ", 10.232, kFALSE, 0.0, 0, "meson", 110551);
146  pdgDB->AddParticle("CHI2P_B1", " ", 10.255, kFALSE, 0.0, 0, "meson", 120553);
147  pdgDB->AddParticle("CHI2P_B2", " ", 10.269, kFALSE, 0.0, 0, "meson", 100555);
148  pdgDB->AddParticle("UPSLON4S", " ", 10.580, kFALSE, 0.0, 0, "meson", 300553);
149 
150 
151  // IONS
152  //
153  // Done by default now from Pythia6 table
154  // Needed for other generators
155  // So check if already defined
156 
157 
158  Int_t ionCode = kion+10020;
159  if(!pdgDB->GetParticle(ionCode)){
160  pdgDB->AddParticle("Deuteron","Deuteron", 1.875613, kTRUE,
161  0,3,"Ion",ionCode);
162  }
163  pdgDB->AddAntiParticle("AntiDeuteron", - ionCode);
164 
165  ionCode = kion+10030;
166  if(!pdgDB->GetParticle(ionCode)){
167  pdgDB->AddParticle("Triton","Triton", 2.80925, kFALSE,
168  khShGev/(12.33*kYear2Sec),3,"Ion",ionCode);
169  }
170  pdgDB->AddAntiParticle("AntiTriton", - ionCode);
171 
172  ionCode = kion+20030;
173  if(!pdgDB->GetParticle(ionCode)){
174  pdgDB->AddParticle("HE3","HE3", 2.80923,kFALSE,
175  0,6,"Ion",ionCode);
176  }
177  pdgDB->AddAntiParticle("AntiHE3", - ionCode);
178 
179  ionCode = kion+20040;
180  if(!pdgDB->GetParticle(ionCode)){
181  pdgDB->AddParticle("Alpha","Alpha", 3.727417, kTRUE,
182  khShGev/(12.33*kYear2Sec), 6, "Ion", ionCode);
183  }
184  pdgDB->AddAntiParticle("AntiAlpha", - ionCode);
185 
186  // Special particles
187  //
188  pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
189  0,0,"Special",kspe+50);
190  pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
191  0,0,"Special",kspe+51);
192  pdgDB->AddParticle("Lambda1520","Lambda1520",1.5195,kFALSE,
193  0.0156,0,"Resonance",3124);
194  pdgDB->AddAntiParticle("Lambda1520bar",-3124);
195 }
196 
197 //______________________________________________________________________________
198 
199 void
200 FWSimTrackProxyBuilder::build( const FWEventItem* iItem, TEveElementList* product, const FWViewContext* )
201 {
203  iItem->get( collection );
204 
205  if( 0 == collection )
206  {
207  return;
208  }
210 
211  TEveTrackPropagator* propagator = context().getTrackPropagator();
212 
213 
215  const edm::EventBase *event = item()->getEvent();
216  event->getByLabel( edm::InputTag( "g4SimHits" ), hitColl );
217 
218  int i = 0;
219  for( std::vector<SimTrack>::const_iterator it = collection->begin(), end = collection->end(); it != end; ++it )
220  {
221  const SimTrack& iData = (*it);
222  double vx = 0.0;
223  double vy = 0.0;
224  double vz = 0.0;
225  double vt = 0.0;
226  if(! iData.noVertex() && ( hitColl.isValid() && !hitColl->empty()))
227  {
228  int vInd = iData.vertIndex();
229  vx = hitColl->at(vInd).position().x();
230  vy = hitColl->at(vInd).position().y();
231  vz = hitColl->at(vInd).position().z();
232  vt = hitColl->at(vInd).position().t();
233  }
234 
235  TParticle* particle = new TParticle;
236  particle->SetPdgCode( iData.type());
237  particle->SetMomentum( iData.momentum().px(), iData.momentum().py(), iData.momentum().pz(), iData.momentum().e());
238  particle->SetProductionVertex( vx, vy, vz, vt );
239 
240  TEveTrack* track = new TEveTrack( particle, ++i, propagator );
241  if( iData.charge() == 0 )
242  {
243  track->SetLineStyle( 7 );
244  }
245  track->AddPathMark( TEvePathMark( TEvePathMark::kReference,
246  TEveVector( iData.trackerSurfacePosition().x(), iData.trackerSurfacePosition().y(), iData.trackerSurfacePosition().z()),
247  TEveVector( iData.trackerSurfaceMomentum().px(), iData.trackerSurfaceMomentum().py(), iData.trackerSurfaceMomentum().pz())));
248  track->MakeTrack();
249  setupAddElement( track, product );
250  }
251 }
252 
const math::XYZVectorD & trackerSurfacePosition() const
Definition: SimTrack.h:36
const fireworks::Context & context() const
int i
Definition: DBlmapReader.cc:9
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
void get(const T *&oData) const
Definition: FWEventItem.h:84
TEveTrackPropagator * getTrackPropagator() const
Definition: Context.h:73
float charge() const
charge
Definition: CoreSimTrack.cc:18
const FWEventItem * item() const
static const int kAll3DBits
Definition: FWViewType.h:59
bool noVertex() const
Definition: SimTrack.h:30
#define end
Definition: vmac.h:37
bool isValid() const
Definition: HandleBase.h:76
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
Definition: SimTrack.h:29
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:146
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
Definition: SimTrack.h:38
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:25
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:87
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
std::vector< SimTrack > SimTrackContainer
const FWSimTrackProxyBuilder & operator=(const FWSimTrackProxyBuilder &)