00001 #include "RecoBTag/MCTools/interface/MCParton.h"
00002 #include <Math/GenVector/VectorUtil.h>
00003
00004 using namespace HepMC;
00005 using namespace std;
00006
00007 MCParton::MCParton() {
00008 reset() ;
00009 }
00010
00011
00012 MCParton::MCParton(const HepMC::GenParticle* particle, const HepMC::GenEvent* event,
00013 const HepMC::GenParticle* lastParton) :
00014 MCBaseParticle(particle,event),
00015 lastParton_(lastParton)
00016 {
00017 reset();
00018 setParticleProperties( );
00019 }
00020
00021 void MCParton::reset ( ) {
00022
00023 flavour_ = 0 ;
00024 flavourAbs_ = 0 ;
00025 statusPythia_ = -1 ;
00026 motherLundCode_ = 0 ;
00027 motherStatusPythia_ = -1 ;
00028 fromPrimaryProcess_ = false ;
00029 fromRadiation_ = false ;
00030 fromGluonSplitting_ = false ;
00031 isFinalParton_ = false ;
00032
00033 splitsToD_ = false ;
00034 splitsToU_ = false ;
00035 splitsToS_ = false ;
00036 splitsToC_ = false ;
00037 splitsToB_ = false ;
00038
00039
00040 daughterLines_.clear();
00041 summedDaughters_.SetPx (0.0) ;
00042 summedDaughters_.SetPy (0.0) ;
00043 summedDaughters_.SetPz (0.0) ;
00044 summedDaughters_.SetE (0.0) ;
00045
00046 isInitialParton_ = false ;
00047 initialPartonHasCloseHF_ = false ;
00048 }
00049
00050
00051 void MCParton::setParticleProperties( ) {
00052
00053
00054
00055
00056 flavour_ = particleInfo().lundCode () ;
00057 flavourAbs_ = abs ( flavour_ ) ;
00058 statusPythia_ = hepParticle->status() ;
00059
00060
00061 bool hasMother = false ;
00062
00063 MCParticleInfo motherParticleInfo ;
00064
00065 if ( hepParticle->production_vertex() )
00066 if ( hepParticle->production_vertex()->particles_begin(HepMC::parents) !=
00067 hepParticle->production_vertex()->particles_end(HepMC::parents)) {
00068 mother_ = *(hepParticle->production_vertex()->particles_begin(HepMC::parents));
00069 motherParticleInfo.setCode ( mother_->pdg_id()) ;
00070 motherLundCode_ = motherParticleInfo.lundCode() ;
00071 motherStatusPythia_ = mother_->status() ;
00072 hasMother = true ;
00073 } else {
00074 mother_ = 0;
00075 }
00076 else {
00077 mother_ = 0;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 HepMC::GenEvent::particle_const_iterator p;
00089 if ( statusPythia_==3 ) {
00090 for (p = hepEvent->particles_begin(); (*p) != lastParton_; ++p) {
00091 int statusP = (**p).status() ;
00092 if( (*p)->production_vertex() ) {
00093 if ( statusP==2 && (*((*p)->production_vertex()->particles_begin(HepMC::parents)) == hepParticle) ) {
00094
00095 daughterLines_.push_back (*p) ;
00096 summedDaughters_ += math::XYZTLorentzVector ( (**p).momentum() );
00097 }
00098 }
00099 }
00100 }
00101
00102
00103
00104
00105
00106
00107 if ( daughterLines_.size() >= 1 && motherLundCode_ != 2212 ) isInitialParton_ = true ;
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 if (isInitialParton_) {
00123 for (p = hepEvent->particles_begin(); (*p) != lastParton_; ++p) {
00124 int statusP = (**p).status() ;
00125 MCParticleInfo lundCodeP((**p).pdg_id()) ;
00126 int flavourP = abs ( lundCodeP.lundCode() ) ;
00127 double deltaRP = ROOT::Math::VectorUtil::DeltaR(math::XYZTLorentzVector((**p).momentum()), math::XYZTLorentzVector(hepParticle->momentum()));
00128 if( (*p)->production_vertex() ){
00129 if ( statusP==2 &&
00130 *((*p)->production_vertex()->particles_begin(HepMC::parents)) != hepParticle &&
00131 (flavourP==4 || flavourP==5) &&
00132 deltaRP<0.8 ) {
00133 initialPartonHasCloseHF_ = true ;
00134 }
00135 }
00136 }
00137 }
00138
00139
00140
00141
00142
00143 if ( hasMother && motherParticleInfo.isParton() && motherStatusPythia_ == 3 )
00144 fromPrimaryProcess_ = true ;
00145
00146 for (p = hepEvent->particles_begin(); (*p) != lastParton_; ++p) {
00147 if((*p)->production_vertex()){
00148 if ( ((**p).status() == 3) &&
00149 (*((*p)->production_vertex()->particles_begin(HepMC::parents)) == hepParticle) )
00150 fromPrimaryProcess_ = false ;
00151 }
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 if ( statusPythia_==2 &&
00163 flavourAbs_>=0 && flavourAbs_<=5 &&
00164 motherStatusPythia_==3 &&
00165 flavour_ != motherLundCode_ ) fromGluonSplitting_ = true ;
00166
00167
00168
00169
00170
00171 isFinalParton_ = true ;
00172 if ( statusPythia_ != 2 ) isFinalParton_ = false ;
00173 for (p = hepEvent->particles_begin(); (*p) != lastParton_; ++p) {
00174 if((*p)->production_vertex()) if ( *((*p)->production_vertex()->particles_begin(HepMC::parents)) == hepParticle ) isFinalParton_ = false ;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 if ( particleInfo().isGluon() || particleInfo().isD() || particleInfo().isU() || particleInfo().isS() ) {
00186 int nD (0) , nDBar (0) ;
00187 int nU (0) , nUBar (0) ;
00188 int nS (0) , nSBar (0) ;
00189 int nC (0) , nCBar (0) ;
00190 int nB (0) , nBBar (0) ;
00191 for (p = hepEvent->particles_begin(); (*p) != lastParton_; ++p) {
00192 if((*p)->production_vertex()) if ( *((*p)->production_vertex()->particles_begin(HepMC::parents)) == hepParticle ) {
00193 int pid = (**p).pdg_id();
00194 if ( pid == 1 ) nD++ ;
00195 if ( pid == 2 ) nU++ ;
00196 if ( pid == 3 ) nS++ ;
00197 if ( pid == 4 ) nC++ ;
00198 if ( pid == 5 ) nB++ ;
00199
00200 if ( pid == -1 ) nDBar++ ;
00201 if ( pid == -2 ) nUBar++ ;
00202 if ( pid == -3 ) nSBar++ ;
00203 if ( pid == -4 ) nCBar++ ;
00204 if ( pid == -5 ) nBBar++ ;
00205 }
00206 }
00207 if ( nD>0 && nDBar>0 ) splitsToD_ = true ;
00208 if ( nU>0 && nUBar>0 ) splitsToU_ = true ;
00209 if ( nS>0 && nSBar>0 ) splitsToS_ = true ;
00210 if ( nC>0 && nCBar>0 ) splitsToC_ = true ;
00211 if ( nB>0 && nBBar>0 ) splitsToB_ = true ;
00212 }
00213
00214 }
00215
00216
00217
00218 void MCParton::print() const {
00219
00220 cout << "--> MCParton:" << endl;
00221 cout << "--> LundCode, flavour, statusPythia: ";
00222 cout.width(8); cout << particleInfo().lundCode();
00223 cout.width(8); cout << flavour_;
00224 cout.width(8); cout << statusPythia_ << endl;
00225
00226 cout << "--> Mother Lund Code, status : ";
00227 cout.width(8); cout << motherLundCode_;
00228 cout.width(16); cout << motherStatusPythia_ << endl;
00229
00230 if ( fromPrimaryProcess_) cout << "--> fromPrimaryProcess ";
00231 if ( fromRadiation_ ) cout << "--> fromRadiation ";
00232 if ( fromGluonSplitting_) cout << "--> fromGluonSplitting ";
00233 if ( isFinalParton_ ) cout << "--> isFinalParton ";
00234 if ( isInitialParton_ ) cout << "--> isInitialParton ";
00235 if ( fromPrimaryProcess_ || fromRadiation_ || fromGluonSplitting_ || isFinalParton_ ||
00236 isInitialParton_ ) cout << endl;
00237
00238
00239 if (splitsToD_ || splitsToU_ || splitsToS_ || splitsToC_ || splitsToB_)
00240 cout <<"--> splits to : ";
00241 if (splitsToD_) cout << " D";
00242 if (splitsToU_) cout << " U";
00243 if (splitsToS_) cout << " S";
00244 if (splitsToC_) cout << " C";
00245 if (splitsToB_) cout << " B";
00246 if (splitsToD_ || splitsToU_ || splitsToS_ || splitsToC_ || splitsToB_)
00247 cout << endl;
00248
00249
00250
00251
00252
00253
00254
00255 cout << "--> Momentum, eta, phi :" << fourVector().px()<< " , "
00256 << fourVector().py() << " , " << fourVector().pz() << " , "
00257 << fourVector().eta()<< " , " << fourVector().phi() <<endl;
00258 cout << "--> Summed daugther momentum :" << summedDaughters_.px()<< " , "
00259 << summedDaughters_.py() << " , " << summedDaughters_.pz() << " , "
00260 << summedDaughters_.eta()<< " , " << summedDaughters_.phi() <<endl;
00261 cout << endl;
00262
00263 }
00264