Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:04

0001 /*
0002  *  FWSimTrackProxyBuilder.cc
0003  *  FWorks
0004  *
0005  *  Created by Ianna Osborne on 9/9/10.
0006  *
0007  */
0008 
0009 #include "Fireworks/Core/interface/FWProxyBuilderBase.h"
0010 #include "Fireworks/Core/interface/Context.h"
0011 #include "Fireworks/Core/interface/FWEventItem.h"
0012 #include "SimDataFormats/Track/interface/SimTrack.h"
0013 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0014 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0015 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0016 
0017 #include "FWCore/Common/interface/EventBase.h"
0018 
0019 #include "TEveTrack.h"
0020 #include "TParticle.h"
0021 #include "TDatabasePDG.h"
0022 
0023 class FWSimTrackProxyBuilder : public FWProxyBuilderBase {
0024 public:
0025   FWSimTrackProxyBuilder(void) {}
0026   ~FWSimTrackProxyBuilder(void) override {}
0027 
0028   REGISTER_PROXYBUILDER_METHODS();
0029 
0030   // Disable default copy constructor
0031   FWSimTrackProxyBuilder(const FWSimTrackProxyBuilder&) = delete;
0032   // Disable default assignment operator
0033   const FWSimTrackProxyBuilder& operator=(const FWSimTrackProxyBuilder&) = delete;
0034 
0035 private:
0036   using FWProxyBuilderBase::build;
0037   void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) override;
0038 
0039   void addParticlesToPdgDataBase(void);
0040 };
0041 
0042 void FWSimTrackProxyBuilder::addParticlesToPdgDataBase(void) {
0043   static Bool_t bAdded = kFALSE;
0044   // Check if already called
0045   if (bAdded)
0046     return;
0047   bAdded = true;
0048 
0049   TDatabasePDG* pdgDB = TDatabasePDG::Instance();
0050   const Int_t kspe = 50000000;
0051 
0052   // PDG nuclear states are 10-digit numbers
0053   // 10LZZZAAAI e.g. deuteron is
0054   // 1000010020
0055   const Int_t kion = 1000000000;
0056 
0057   /*
0058     const Double_t kAu2Gev=0.9314943228;
0059     */
0060 
0061   const Double_t khSlash = 1.0545726663e-27;
0062   const Double_t kErg2Gev = 1 / 1.6021773349e-3;
0063   const Double_t khShGev = khSlash * kErg2Gev;
0064   const Double_t kYear2Sec = 3600 * 24 * 365.25;
0065 
0066   //
0067   // Bottom mesons
0068   // mass and life-time from PDG
0069   //
0070   pdgDB->AddParticle("Upsilon(3S)", "Upsilon(3S)", 10.3552, kTRUE, 0, 1, "Bottonium", 200553);
0071 
0072   // QCD diffractive states
0073   pdgDB->AddParticle("rho_diff0", "rho_diff0", 0, kTRUE, 0, 0, "QCD diffr. state", 9900110);
0074   pdgDB->AddParticle("pi_diffr+", "pi_diffr+", 0, kTRUE, 0, 1, "QCD diffr. state", 9900210);
0075   pdgDB->AddParticle("omega_di", "omega_di", 0, kTRUE, 0, 0, "QCD diffr. state", 9900220);
0076   pdgDB->AddParticle("phi_diff", "phi_diff", 0, kTRUE, 0, 0, "QCD diffr. state", 9900330);
0077   pdgDB->AddParticle("J/psi_di", "J/psi_di", 0, kTRUE, 0, 0, "QCD diffr. state", 9900440);
0078   pdgDB->AddParticle("n_diffr0", "n_diffr0", 0, kTRUE, 0, 0, "QCD diffr. state", 9902110);
0079   pdgDB->AddParticle("p_diffr+", "p_diffr+", 0, kTRUE, 0, 1, "QCD diffr. state", 9902210);
0080 
0081   // From Herwig
0082   pdgDB->AddParticle("PSID    ", " ", 3.7699, kFALSE, 0.0, 0, "meson", 30443);
0083 
0084   pdgDB->AddParticle("A_00    ", " ", 0.9960, kFALSE, 0.0, 0, "meson", 9000111);
0085   pdgDB->AddParticle("A_0+    ", " ", 0.9960, kFALSE, 0.0, +3, "meson", 9000211);
0086   pdgDB->AddParticle("A_0-    ", " ", 0.9960, kFALSE, 0.0, -3, "meson", -9000211);
0087 
0088   pdgDB->AddParticle("F0P0    ", " ", 0.9960, kFALSE, 0.0, 0, "meson", 9010221);
0089 
0090   pdgDB->AddParticle("KDL_2+  ", " ", 1.773, kFALSE, 0.0, +3, "meson", 10325);
0091   pdgDB->AddParticle("KDL_2-  ", " ", 1.773, kFALSE, 0.0, -3, "meson", -10325);
0092 
0093   pdgDB->AddParticle("KDL_20  ", " ", 1.773, kFALSE, 0.0, 0, "meson", 10315);
0094   pdgDB->AddParticle("KDL_2BR0", " ", 1.773, kFALSE, 0.0, 0, "meson", -10315);
0095 
0096   pdgDB->AddParticle("PI_2+   ", " ", 1.670, kFALSE, 0.0, +3, "meson", 10215);
0097   pdgDB->AddParticle("PI_2-   ", " ", 1.670, kFALSE, 0.0, -3, "meson", -10215);
0098   pdgDB->AddParticle("PI_20   ", " ", 1.670, kFALSE, 0.0, 0, "meson", 10115);
0099 
0100   pdgDB->AddParticle("KD*+    ", " ", 1.717, kFALSE, 0.0, +3, "meson", 30323);
0101   pdgDB->AddParticle("KD*-    ", " ", 1.717, kFALSE, 0.0, -3, "meson", -30323);
0102 
0103   pdgDB->AddParticle("KD*0    ", " ", 1.717, kFALSE, 0.0, 0, "meson", 30313);
0104   pdgDB->AddParticle("KDBR*0  ", " ", 1.717, kFALSE, 0.0, 0, "meson", -30313);
0105 
0106   pdgDB->AddParticle("RHOD+   ", " ", 1.700, kFALSE, 0.0, +3, "meson", 30213);
0107   pdgDB->AddParticle("RHOD-   ", " ", 1.700, kFALSE, 0.0, -3, "meson", -30213);
0108   pdgDB->AddParticle("RHOD0   ", " ", 1.700, kFALSE, 0.0, 0, "meson", 30113);
0109 
0110   pdgDB->AddParticle("ETA_2(L)", " ", 1.632, kFALSE, 0.0, 0, "meson", 10225);
0111   pdgDB->AddParticle("ETA_2(H)", " ", 1.854, kFALSE, 0.0, 0, "meson", 10335);
0112   pdgDB->AddParticle("OMEGA(H)", " ", 1.649, kFALSE, 0.0, 0, "meson", 30223);
0113 
0114   pdgDB->AddParticle("KDH_2+  ", " ", 1.816, kFALSE, 0.0, +3, "meson", 20325);
0115   pdgDB->AddParticle("KDH_2-  ", " ", 1.816, kFALSE, 0.0, -3, "meson", -20325);
0116 
0117   pdgDB->AddParticle("KDH_20  ", " ", 1.816, kFALSE, 0.0, 0, "meson", 20315);
0118   pdgDB->AddParticle("KDH_2BR0", " ", 1.816, kFALSE, 0.0, 0, "meson", -20315);
0119 
0120   pdgDB->AddParticle("KD_3+   ", " ", 1.773, kFALSE, 0.0, +3, "meson", 327);
0121   pdgDB->AddParticle("KD_3-   ", " ", 1.773, kFALSE, 0.0, -3, "meson", -327);
0122 
0123   pdgDB->AddParticle("KD_30   ", " ", 1.773, kFALSE, 0.0, 0, "meson", 317);
0124   pdgDB->AddParticle("KD_3BR0 ", " ", 1.773, kFALSE, 0.0, 0, "meson", -317);
0125 
0126   pdgDB->AddParticle("RHO_3+  ", " ", 1.691, kFALSE, 0.0, +3, "meson", 217);
0127   pdgDB->AddParticle("RHO_3-  ", " ", 1.691, kFALSE, 0.0, -3, "meson", -217);
0128   pdgDB->AddParticle("RHO_30  ", " ", 1.691, kFALSE, 0.0, 0, "meson", 117);
0129   pdgDB->AddParticle("OMEGA_3 ", " ", 1.667, kFALSE, 0.0, 0, "meson", 227);
0130   pdgDB->AddParticle("PHI_3   ", " ", 1.854, kFALSE, 0.0, 0, "meson", 337);
0131 
0132   pdgDB->AddParticle("CHI2P_B0", " ", 10.232, kFALSE, 0.0, 0, "meson", 110551);
0133   pdgDB->AddParticle("CHI2P_B1", " ", 10.255, kFALSE, 0.0, 0, "meson", 120553);
0134   pdgDB->AddParticle("CHI2P_B2", " ", 10.269, kFALSE, 0.0, 0, "meson", 100555);
0135   pdgDB->AddParticle("UPSLON4S", " ", 10.580, kFALSE, 0.0, 0, "meson", 300553);
0136 
0137   // IONS
0138   //
0139   // Done by default now from Pythia6 table
0140   // Needed for other generators
0141   // So check if already defined
0142 
0143   Int_t ionCode = kion + 10020;
0144   if (!pdgDB->GetParticle(ionCode)) {
0145     pdgDB->AddParticle("Deuteron", "Deuteron", 1.875613, kTRUE, 0, 3, "Ion", ionCode);
0146   }
0147   pdgDB->AddAntiParticle("AntiDeuteron", -ionCode);
0148 
0149   ionCode = kion + 10030;
0150   if (!pdgDB->GetParticle(ionCode)) {
0151     pdgDB->AddParticle("Triton", "Triton", 2.80925, kFALSE, khShGev / (12.33 * kYear2Sec), 3, "Ion", ionCode);
0152   }
0153   pdgDB->AddAntiParticle("AntiTriton", -ionCode);
0154 
0155   ionCode = kion + 20030;
0156   if (!pdgDB->GetParticle(ionCode)) {
0157     pdgDB->AddParticle("HE3", "HE3", 2.80923, kFALSE, 0, 6, "Ion", ionCode);
0158   }
0159   pdgDB->AddAntiParticle("AntiHE3", -ionCode);
0160 
0161   ionCode = kion + 20040;
0162   if (!pdgDB->GetParticle(ionCode)) {
0163     pdgDB->AddParticle("Alpha", "Alpha", 3.727417, kTRUE, khShGev / (12.33 * kYear2Sec), 6, "Ion", ionCode);
0164   }
0165   pdgDB->AddAntiParticle("AntiAlpha", -ionCode);
0166 
0167   // Special particles
0168   //
0169   pdgDB->AddParticle("Cherenkov", "Cherenkov", 0, kFALSE, 0, 0, "Special", kspe + 50);
0170   pdgDB->AddParticle("FeedbackPhoton", "FeedbackPhoton", 0, kFALSE, 0, 0, "Special", kspe + 51);
0171   pdgDB->AddParticle("Lambda1520", "Lambda1520", 1.5195, kFALSE, 0.0156, 0, "Resonance", 3124);
0172   pdgDB->AddAntiParticle("Lambda1520bar", -3124);
0173 }
0174 
0175 //______________________________________________________________________________
0176 
0177 void FWSimTrackProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*) {
0178   const edm::SimTrackContainer* collection = nullptr;
0179   iItem->get(collection);
0180 
0181   if (nullptr == collection) {
0182     return;
0183   }
0184   addParticlesToPdgDataBase();
0185 
0186   TEveTrackPropagator* propagator = context().getTrackPropagator();
0187 
0188   edm::Handle<edm::SimVertexContainer> hitColl;
0189   const edm::EventBase* event = item()->getEvent();
0190   event->getByLabel(edm::InputTag("g4SimHits"), hitColl);
0191 
0192   int i = 0;
0193   for (std::vector<SimTrack>::const_iterator it = collection->begin(), end = collection->end(); it != end; ++it) {
0194     const SimTrack& iData = (*it);
0195     double vx = 0.0;
0196     double vy = 0.0;
0197     double vz = 0.0;
0198     double vt = 0.0;
0199     if (!iData.noVertex() && (hitColl.isValid() && !hitColl->empty())) {
0200       int vInd = iData.vertIndex();
0201       vx = hitColl->at(vInd).position().x();
0202       vy = hitColl->at(vInd).position().y();
0203       vz = hitColl->at(vInd).position().z();
0204       vt = hitColl->at(vInd).position().t();
0205     }
0206 
0207     TParticle* particle = new TParticle;
0208     particle->SetPdgCode(iData.type());
0209     particle->SetMomentum(iData.momentum().px(), iData.momentum().py(), iData.momentum().pz(), iData.momentum().e());
0210     particle->SetProductionVertex(vx, vy, vz, vt);
0211 
0212     TEveTrack* track = new TEveTrack(particle, ++i, propagator);
0213     if (iData.charge() == 0) {
0214       track->SetLineStyle(7);
0215     }
0216     track->AddPathMark(TEvePathMark(
0217         TEvePathMark::kReference,
0218         TEveVector(
0219             iData.trackerSurfacePosition().x(), iData.trackerSurfacePosition().y(), iData.trackerSurfacePosition().z()),
0220         TEveVector(iData.trackerSurfaceMomentum().px(),
0221                    iData.trackerSurfaceMomentum().py(),
0222                    iData.trackerSurfaceMomentum().pz())));
0223     track->MakeTrack();
0224     setupAddElement(track, product);
0225   }
0226 }
0227 
0228 REGISTER_FWPROXYBUILDER(FWSimTrackProxyBuilder,
0229                         edm::SimTrackContainer,
0230                         "SimTracks",
0231                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);