ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/SFrameTools/src/Utils.cxx
(Generate patch)

Comparing UserCode/UHHAnalysis/SFrameTools/src/Utils.cxx (file contents):
Revision 1.6 by hoeing, Mon Oct 15 15:35:51 2012 UTC vs.
Revision 1.7 by peiffer, Fri Dec 7 10:56:32 2012 UTC

# Line 399 | Line 399 | int myPow(int x, unsigned int p) {
399    for (unsigned int j = 1; j <= p; j++)  i *= x;
400    return i;
401   }
402 +
403 + int JetFlavor(Jet *jet){
404 +
405 +  EventCalc* calc = EventCalc::Instance();
406 +
407 +  std::vector< GenParticle >* genparticles = calc->GetGenParticles();
408 +  if(genparticles){
409 +
410 +    //fill pdg IDs of all matched GenParticles
411 +    std::vector<int> matched_genparticle_ids;
412 +    for(unsigned int i=0; i<genparticles->size(); ++i){
413 +    
414 +      GenParticle genp = genparticles->at(i);
415 +
416 +      //only take status 3 particles into account
417 +      if(genp.status()!=3) continue;
418 +
419 +      if(jet->deltaR(genp)<0.5)
420 +        matched_genparticle_ids.push_back(genp.pdgId());
421 +    }
422 +
423 +    //search for b quarks first
424 +    for(unsigned int i=0; i<matched_genparticle_ids.size(); ++i){
425 +      if(abs(matched_genparticle_ids[i])==5) return matched_genparticle_ids[i];
426 +    }
427 +    //no b quark -> search for c quarks
428 +    for(unsigned int i=0; i<matched_genparticle_ids.size(); ++i){
429 +      if(abs(matched_genparticle_ids[i])==4) return matched_genparticle_ids[i];
430 +    }
431 +    for(unsigned int i=0; i<matched_genparticle_ids.size(); ++i){
432 +      if(abs(matched_genparticle_ids[i])==3) return matched_genparticle_ids[i];
433 +    }
434 +    for(unsigned int i=0; i<matched_genparticle_ids.size(); ++i){
435 +      if(abs(matched_genparticle_ids[i])==2) return matched_genparticle_ids[i];
436 +    }
437 +    for(unsigned int i=0; i<matched_genparticle_ids.size(); ++i){
438 +      if(abs(matched_genparticle_ids[i])==1) return matched_genparticle_ids[i];
439 +    }
440 +    for(unsigned int i=0; i<matched_genparticle_ids.size(); ++i){
441 +      if(abs(matched_genparticle_ids[i])==21) return matched_genparticle_ids[i];
442 +    }
443 +    
444 +  }
445 +
446 +  //no matched GenParticle -> return default value 0
447 +  return 0;
448 +
449 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines