Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:17

0001 #include "DataFormats/ParticleFlowReco/interface/PFSimParticle.h"
0002 // #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 using namespace reco;
0005 using namespace std;
0006 
0007 PFSimParticle::PFSimParticle() : PFTrack(), pdgCode_(0), id_(0), motherId_(0) {}
0008 
0009 PFSimParticle::PFSimParticle(double charge,
0010                              int pdgCode,
0011                              unsigned id,
0012                              int motherId,
0013                              const vector<int>& daughterIds,
0014                              unsigned rectrackId,
0015                              const std::vector<unsigned>& recHitContrib,
0016                              const std::vector<double>& recHitContribFrac)
0017     : PFTrack(charge),
0018       pdgCode_(pdgCode),
0019       id_(id),
0020       motherId_(motherId),
0021       daughterIds_(daughterIds),
0022       rectrackId_(rectrackId),
0023       recHitContrib_(recHitContrib),
0024       recHitContribFrac_(recHitContribFrac) {}
0025 
0026 PFSimParticle::PFSimParticle(const PFSimParticle& other)
0027     : PFTrack(other),
0028       pdgCode_(other.pdgCode_),
0029       id_(other.id_),
0030       motherId_(other.motherId_),
0031       daughterIds_(other.daughterIds_),
0032       rectrackId_(other.rectrackId_),
0033       recHitContrib_(other.recHitContrib_),
0034       recHitContribFrac_(other.recHitContribFrac_) {}
0035 
0036 ostream& reco::operator<<(ostream& out, const PFSimParticle& particle) {
0037   if (!out)
0038     return out;
0039 
0040   const reco::PFTrajectoryPoint& closestApproach = particle.trajectoryPoint(reco::PFTrajectoryPoint::ClosestApproach);
0041 
0042   out << setiosflags(ios::right);
0043   out << setiosflags(ios::fixed);
0044 
0045   out << "Particle #" << particle.id() << ", mother = " << setw(2) << particle.motherId();
0046 
0047   out << setprecision(1);
0048   out << ", charge = " << setw(5) << particle.charge();
0049   out << setprecision(3);
0050 
0051   //   modif to get "name" of particle from pdg code
0052   int partId = particle.pdgCode();
0053   std::string name;
0054 
0055   // We have here a subset of particles only.
0056   // To be filled according to the needs.
0057   switch (partId) {
0058     case 1: {
0059       name = "d";
0060       break;
0061     }
0062     case 2: {
0063       name = "u";
0064       break;
0065     }
0066     case 3: {
0067       name = "s";
0068       break;
0069     }
0070     case 4: {
0071       name = "c";
0072       break;
0073     }
0074     case 5: {
0075       name = "b";
0076       break;
0077     }
0078     case 6: {
0079       name = "t";
0080       break;
0081     }
0082     case -1: {
0083       name = "~d";
0084       break;
0085     }
0086     case -2: {
0087       name = "~u";
0088       break;
0089     }
0090     case -3: {
0091       name = "~s";
0092       break;
0093     }
0094     case -4: {
0095       name = "~c";
0096       break;
0097     }
0098     case -5: {
0099       name = "~b";
0100       break;
0101     }
0102     case -6: {
0103       name = "~t";
0104       break;
0105     }
0106     case 11: {
0107       name = "e-";
0108       break;
0109     }
0110     case -11: {
0111       name = "e+";
0112       break;
0113     }
0114     case 12: {
0115       name = "nu_e";
0116       break;
0117     }
0118     case -12: {
0119       name = "~nu_e";
0120       break;
0121     }
0122     case 13: {
0123       name = "mu-";
0124       break;
0125     }
0126     case -13: {
0127       name = "mu+";
0128       break;
0129     }
0130     case 14: {
0131       name = "nu_mu";
0132       break;
0133     }
0134     case -14: {
0135       name = "~nu_mu";
0136       break;
0137     }
0138     case 15: {
0139       name = "tau-";
0140       break;
0141     }
0142     case -15: {
0143       name = "tau+";
0144       break;
0145     }
0146     case 16: {
0147       name = "nu_tau";
0148       break;
0149     }
0150     case -16: {
0151       name = "~nu_tau";
0152       break;
0153     }
0154     case 21: {
0155       name = "gluon";
0156       break;
0157     }
0158     case 22: {
0159       name = "gamma";
0160       break;
0161     }
0162     case 23: {
0163       name = "Z0";
0164       break;
0165     }
0166     case 24: {
0167       name = "W+";
0168       break;
0169     }
0170     case 25: {
0171       name = "H0";
0172       break;
0173     }
0174     case -24: {
0175       name = "W-";
0176       break;
0177     }
0178     case 111: {
0179       name = "pi0";
0180       break;
0181     }
0182     case 113: {
0183       name = "rho0";
0184       break;
0185     }
0186     case 223: {
0187       name = "omega";
0188       break;
0189     }
0190     case 333: {
0191       name = "phi";
0192       break;
0193     }
0194     case 443: {
0195       name = "J/psi";
0196       break;
0197     }
0198     case 553: {
0199       name = "Upsilon";
0200       break;
0201     }
0202     case 130: {
0203       name = "K0L";
0204       break;
0205     }
0206     case 211: {
0207       name = "pi+";
0208       break;
0209     }
0210     case -211: {
0211       name = "pi-";
0212       break;
0213     }
0214     case 213: {
0215       name = "rho+";
0216       break;
0217     }
0218     case -213: {
0219       name = "rho-";
0220       break;
0221     }
0222     case 221: {
0223       name = "eta";
0224       break;
0225     }
0226     case 331: {
0227       name = "eta'";
0228       break;
0229     }
0230     case 441: {
0231       name = "etac";
0232       break;
0233     }
0234     case 551: {
0235       name = "etab";
0236       break;
0237     }
0238     case 310: {
0239       name = "K0S";
0240       break;
0241     }
0242     case 311: {
0243       name = "K0";
0244       break;
0245     }
0246     case -311: {
0247       name = "Kbar0";
0248       break;
0249     }
0250     case 321: {
0251       name = "K+";
0252       break;
0253     }
0254     case -321: {
0255       name = "K-";
0256       break;
0257     }
0258     case 411: {
0259       name = "D+";
0260       break;
0261     }
0262     case -411: {
0263       name = "D-";
0264       break;
0265     }
0266     case 421: {
0267       name = "D0";
0268       break;
0269     }
0270     case 431: {
0271       name = "Ds_+";
0272       break;
0273     }
0274     case -431: {
0275       name = "Ds_-";
0276       break;
0277     }
0278     case 511: {
0279       name = "B0";
0280       break;
0281     }
0282     case 521: {
0283       name = "B+";
0284       break;
0285     }
0286     case -521: {
0287       name = "B-";
0288       break;
0289     }
0290     case 531: {
0291       name = "Bs_0";
0292       break;
0293     }
0294     case 541: {
0295       name = "Bc_+";
0296       break;
0297     }
0298     case -541: {
0299       name = "Bc_+";
0300       break;
0301     }
0302     case 313: {
0303       name = "K*0";
0304       break;
0305     }
0306     case -313: {
0307       name = "K*bar0";
0308       break;
0309     }
0310     case 323: {
0311       name = "K*+";
0312       break;
0313     }
0314     case -323: {
0315       name = "K*-";
0316       break;
0317     }
0318     case 413: {
0319       name = "D*+";
0320       break;
0321     }
0322     case -413: {
0323       name = "D*-";
0324       break;
0325     }
0326     case 423: {
0327       name = "D*0";
0328       break;
0329     }
0330     case 513: {
0331       name = "B*0";
0332       break;
0333     }
0334     case 523: {
0335       name = "B*+";
0336       break;
0337     }
0338     case -523: {
0339       name = "B*-";
0340       break;
0341     }
0342     case 533: {
0343       name = "B*_s0";
0344       break;
0345     }
0346     case 543: {
0347       name = "B*_c+";
0348       break;
0349     }
0350     case -543: {
0351       name = "B*_c-";
0352       break;
0353     }
0354     case 1114: {
0355       name = "Delta-";
0356       break;
0357     }
0358     case -1114: {
0359       name = "Deltabar+";
0360       break;
0361     }
0362     case -2112: {
0363       name = "nbar0";
0364       break;
0365     }
0366     case 2112: {
0367       name = "n";
0368       break;
0369     }
0370     case 2114: {
0371       name = "Delta0";
0372       break;
0373     }
0374     case -2114: {
0375       name = "Deltabar0";
0376       break;
0377     }
0378     case 3122: {
0379       name = "Lambda0";
0380       break;
0381     }
0382     case -3122: {
0383       name = "Lambdabar0";
0384       break;
0385     }
0386     case 3112: {
0387       name = "Sigma-";
0388       break;
0389     }
0390     case -3112: {
0391       name = "Sigmabar+";
0392       break;
0393     }
0394     case 3212: {
0395       name = "Sigma0";
0396       break;
0397     }
0398     case -3212: {
0399       name = "Sigmabar0";
0400       break;
0401     }
0402     case 3214: {
0403       name = "Sigma*0";
0404       break;
0405     }
0406     case -3214: {
0407       name = "Sigma*bar0";
0408       break;
0409     }
0410     case 3222: {
0411       name = "Sigma+";
0412       break;
0413     }
0414     case -3222: {
0415       name = "Sigmabar-";
0416       break;
0417     }
0418     case 2212: {
0419       name = "p";
0420       break;
0421     }
0422     case -2212: {
0423       name = "~p";
0424       break;
0425     }
0426     case -2214: {
0427       name = "Delta-";
0428       break;
0429     }
0430     case 2214: {
0431       name = "Delta+";
0432       break;
0433     }
0434     case -2224: {
0435       name = "Deltabar--";
0436       break;
0437     }
0438     case 2224: {
0439       name = "Delta++";
0440       break;
0441     }
0442     default: {
0443       name = "unknown";
0444       cout << "Unknown code : " << partId << endl;
0445     }
0446   }
0447 
0448   out << ", pdg=" << setw(6) << particle.pdgCode() << setw(6)
0449       << name
0450 
0451       // end of modif to get name from pdg code
0452 
0453       << ", pT =" << setw(7) << closestApproach.momentum().Pt() << ", E  =" << setw(7)
0454       << closestApproach.momentum().E();
0455 
0456   out << resetiosflags(ios::right | ios::fixed);
0457 
0458   out << "\tdaughters : ";
0459   for (unsigned i = 0; i < particle.daughterIds().size(); i++)
0460     out << particle.daughterIds()[i] << " ";
0461 
0462   //   out<<endl;
0463   //   for(unsigned i=0; i<particle.trajectoryPoints_.size(); i++)
0464   //     out<<particle.trajectoryPoints_[i]<<endl;
0465 
0466   return out;
0467 }