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