CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimDataFormats/Track/src/CoreSimTrack.cc

Go to the documentation of this file.
00001 #include "SimDataFormats/Track/interface/CoreSimTrack.h"
00002 
00003 float CoreSimTrack::charge()const { 
00004   return float(CoreSimTrack::chargeValue(thePID)/3.);
00005 }
00006 
00007 
00008 int CoreSimTrack::chargeValue(const int& Id)const{
00009 
00010   
00011   //...Purpose: to give three times the charge for a particle/parton.
00012 
00013   //      ID     = particle ID
00014   //      hepchg = particle charge times 3
00015 
00016   int kqa,kq1,kq2,kq3,kqj,irt,kqx,kqn;
00017   int hepchg;
00018 
00019 
00020   int ichg[109]={-1,2,-1,2,-1,2,-1,2,0,0,-3,0,-3,0,-3,0,
00021 -3,0,0,0,0,0,0,3,0,0,0,0,0,0,3,0,3,6,0,0,3,6,0,0,-1,2,-1,2,-1,2,0,0,0,0,
00022 -3,0,-3,0,-3,0,0,0,0,0,-1,2,-1,2,-1,2,0,0,0,0,
00023 -3,0,-3,0,-3,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
00024 
00025 
00026   //...Initial values. Simple case of direct readout.
00027   hepchg=0;
00028   kqa=abs(Id);
00029   kqn=kqa/1000000000%10;
00030   kqx=kqa/1000000%10;
00031   kq3=kqa/1000%10;
00032   kq2=kqa/100%10;
00033   kq1=kqa/10%10;
00034   kqj=kqa%10;
00035   irt=kqa%10000;
00036 
00037   //...illegal or ion
00038   //...set ion charge to zero - not enough information
00039   if(kqa==0 || kqa >= 10000000) {
00040 
00041     if(kqn==1) {hepchg=0;}
00042   }
00043   //... direct translation
00044   else if(kqa<=100) {hepchg = ichg[kqa-1];}
00045   //... deuteron or tritium
00046   else if(kqa==100 || kqa==101) {hepchg = -3;}
00047   //... alpha or He3
00048   else if(kqa==102 || kqa==104) {hepchg = -6;}
00049   //... KS and KL (and undefined)
00050   else if(kqj == 0) {hepchg = 0;}
00051   //C... direct translation
00052   else if(kqx>0 && irt<100)
00053     {
00054       hepchg = ichg[irt-1];
00055       if(kqa==1000017 || kqa==1000018) {hepchg = 0;}
00056       if(kqa==1000034 || kqa==1000052) {hepchg = 0;}
00057       if(kqa==1000053 || kqa==1000054) {hepchg = 0;}
00058       if(kqa==5100061 || kqa==5100062) {hepchg = 6;}
00059     }
00060   //...Construction from quark content for heavy meson, diquark, baryon.
00061   //...Mesons.
00062   else if(kq3==0)
00063     {
00064       hepchg = ichg[kq2-1]-ichg[kq1-1];
00065       //...Strange or beauty mesons.
00066       if((kq2==3) || (kq2==5)) {hepchg = ichg[kq1-1]-ichg[kq2-1];}
00067     }
00068   else if(kq1 == 0) {
00069     //...Diquarks.
00070     hepchg = ichg[kq3-1] + ichg[kq2-1];
00071   }
00072 
00073   else{
00074     //...Baryons
00075     hepchg = ichg[kq3-1]+ichg[kq2-1]+ichg[kq1-1];
00076   }
00077 
00078   //... fix sign of charge
00079   if(Id<0 && hepchg!=0) {hepchg = -1*hepchg;}
00080 
00081   // cout << hepchg<< endl;
00082   return hepchg;
00083 }
00084 
00085 
00086 
00087 std::ostream & operator <<(std::ostream & o , const CoreSimTrack& t) 
00088 {
00089     o << t.type() << ", ";
00090     o << t.momentum();
00091     return o;
00092 }