NtupleReader/src/MyTools.cxx

00001 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002 // 10.12.2006, AUTHOR: ALL
00003 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00004 
00005 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00006 //:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS MyTools ::
00007 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00008 
00009 //::::::::::::::::::
00010 //:: HEADER FILES ::
00011 //::::::::::::::::::
00012 
00013 #include "NtupleReader/MyTools.h"
00014 
00015 
00016 //::::::::::::::::::::::::
00017 //:: NAMESPACE SETTINGS ::
00018 //::::::::::::::::::::::::
00019 
00020 using namespace std;
00021 
00022 
00023 //*****************************************************************************
00024 
00025 //:::::::::::::::::
00026 //:: METHOD init ::
00027 //:::::::::::::::::
00028 
00029 void MyTools::init() {
00030 
00031     m_nb_multiple_matches = 0;
00032 }
00033 
00034 //*****************************************************************************
00035 
00036 //:::::::::::::::::::::
00037 //:: METHOD destruct ::
00038 //:::::::::::::::::::::
00039 
00040 void MyTools::destruct(void) {
00041 
00042     return;
00043 
00044 }
00045 
00046 
00047 
00048 //*****************************************************************************
00049 
00050 //:::::::::::::::::::::::::::::::::::
00051 //:: METHOD find_matching_particle ::
00052 //:::::::::::::::::::::::::::::::::::
00053 
00054 MyParticle*
00055 MyTools::find_matching_particle( TLorentzVector particle_tlv, 
00056                                  std::vector<MyParticle*> & particle_vector, 
00057                                  double deltaR_cut,
00058                                  bool bool_matchingflag,
00059                                  bool bool_usematching){
00060 
00061     // Variables //
00062 
00063     double deltaR = 0.;
00064     double deltaR_min = 10.5;
00065 
00066     int k_min = -1;
00067     int nb_foundparticles =  0;
00068     //double deltaEta = 0;
00069     //double deltaPhi = 0;
00070 
00071     // loop over particles in vector // 
00072 
00073     for (unsigned int k=0; k<particle_vector.size(); k++) {
00074 
00075         // don't use particle, if it has already been matched before // 
00076 
00077         if(bool_usematching) {
00078             if( !(particle_vector[k]->matchingflag() == 0) )  continue; 
00079         }
00080 
00081         //deltaEta = particle->tlv().Eta()-particle_vector[k]->tlv().Eta();
00082         //deltaPhi = particle->tlv().Phi()-particle_vector[k]->tlv().Phi();
00083         //if(deltaPhi > 3.14159) deltaPhi = deltaPhi- 2.*3.1415; 
00084         //if(deltaPhi < -3.14159) deltaPhi = deltaPhi+ 2.*3.1415; 
00085         //deltaR = sqrt(pow(deltaEta,2)+pow(deltaPhi,2));
00086 
00087         deltaR = particle_tlv.DeltaR( particle_vector[k]->tlv() );
00088         //check the influence of a delta pt cut in matching
00089         //double delta_pt_rel;
00090         //delta_pt_rel = TMath::Abs((particle->tlv().Pt() - particle_vector[k]->tlv().Pt())) / particle->tlv().Pt();
00091         //if(delta_pt_rel<0.1){
00092 
00093         // select particle with dR < dR_cut                               //
00094         // if more than one canditate select the one with the smallest dR //
00095 
00096         if( deltaR < deltaR_cut && deltaR < deltaR_min){
00097             k_min = k;
00098             deltaR_min = deltaR; 
00099             nb_foundparticles++;
00100         }
00101         //} // end of influence of a delta pt cut
00102 
00103     }
00104 
00105     // if more than one particle with dR < dR_cut was found //
00106     // increase m_nb_multiple_matches                       //
00107 
00108     if(nb_foundparticles>1){ 
00109         m_nb_multiple_matches++;
00110     }
00111 
00112     if(nb_foundparticles==0){
00113         return NULL;
00114     }
00115     else{
00116         if(bool_matchingflag) particle_vector[k_min]->set_matchingflag(1);
00117         return particle_vector[k_min];
00118     }
00119 
00120   }
00121 
00122 //*****************************************************************************
00123 
00124 //:::::::::::::::::::::::::::::::::::
00125 //:: METHOD find_matching_particle ::
00126 //:::::::::::::::::::::::::::::::::::
00127 
00128 MyParticle*
00129 MyTools::find_matching_particle( MyParticle* particle, 
00130                                  std::vector<MyParticle*> & particle_vector, 
00131                                  double deltaR_cut,
00132                                  bool bool_matchingflag,
00133                                  bool bool_usematching){
00134     return find_matching_particle(particle->tlv(),
00135                                  particle_vector, 
00136                                  deltaR_cut,
00137                                  bool_matchingflag,
00138                                  bool_usematching);
00139 }
00140 
00141 //*****************************************************************************
00142 
00143 Int_t 
00144 MyTools::nb_multiple_matches(void){
00145 
00146     return m_nb_multiple_matches;
00147 
00148 }
00149 //*****************************************************************************
00150 
00151 void 
00152 MyTools::clear_vector(std::vector<MyParticle*> & particle_vector){
00153 
00154     for(unsigned int k =0;k<particle_vector.size(); k++ ){
00155         particle_vector[k]->set_matchingflag(0);
00156     }
00157 
00158 }
00159 //*****************************************************************************
00160 
00161 void 
00162 MyTools::clear_nb_multiple_matches(){
00163 
00164     m_nb_multiple_matches = 0;
00165 
00166 }
00167 
00168 //*****************************************************************************
00169 
00170 //:::::::::::::::::::::::::::
00171 //:: METHOD remove_overlap ::
00172 //:::::::::::::::::::::::::::
00173 
00174 std::vector<MyParticle*>
00175 MyTools::remove_overlap( std::vector<MyParticle*> vec_part_tb_rm,
00176                          std::vector<MyParticle*> vec_part_rm_with, 
00177                          double deltaR_cut) {
00178 
00179     std::vector<MyParticle*> vec_tmp;
00180 
00181     MyParticle* tmp_part_overlaps = NULL;
00182 
00183     // loop over given vector
00184     for (unsigned int k=0; k<vec_part_tb_rm.size(); k++){
00185 
00186         tmp_part_overlaps = 
00187             find_matching_particle( vec_part_tb_rm[k], vec_part_rm_with, 
00188                                     deltaR_cut, false, false);
00189 
00190         // if maching particle was found go to the next in the vector
00191         if(tmp_part_overlaps!=NULL){
00192             continue;
00193         }
00194 
00195         vec_tmp.push_back( vec_part_tb_rm[k] );
00196     }
00197 
00198     return vec_tmp;
00199 
00200 }
00201 
00202 //*****************************************************************************
00203 
00204 //:::::::::::::::::::::::::::
00205 //:: METHOD sort_particles ::
00206 //:::::::::::::::::::::::::::
00207 
00208 std::vector<MyParticle*>
00209 MyTools::sort_particles( std::vector<MyParticle*> p_vector ){
00210 
00211 
00212     std::vector<MyParticle*> sorted_p_vector(0);
00213 
00214     unsigned int orig_size = p_vector.size();
00215 
00216     for (unsigned int cycle=0; cycle<orig_size; cycle++){
00217 
00218         int    k_max=-1; 
00219         double abspt_max=-1;
00220 
00221         for (unsigned int k=0; k<p_vector.size(); k++) {
00222 
00223             double abspt =  TMath::Abs(p_vector[k]->tlv().Pt());
00224 
00225             if( abspt > abspt_max ){
00226                 k_max = k;
00227                 abspt_max = abspt; 
00228             }
00229 
00230         }
00231 
00232         //cout << "in sorter, cycle: " << cycle 
00233         //   << ", abspt_max: " << abspt_max << endl; 
00234 
00235         sorted_p_vector.push_back( p_vector[k_max] );
00236         p_vector.erase(p_vector.begin()+k_max);
00237 
00238     }
00239 
00240     return sorted_p_vector;
00241 
00242 }
00243 
00244 //*****************************************************************************
00245 
00246 //::::::::::::::::::::::::
00247 //:: METHOD check_order ::
00248 //::::::::::::::::::::::::
00249 
00250 void
00251 MyTools::check_order( std::vector<MyParticle*> p_vector ){
00252 
00253     double abspt_min=0;
00254 
00255     if (p_vector.size()==0) return;
00256 
00257     for (unsigned int k=0; k<p_vector.size(); k++) {
00258 
00259         double abspt =  TMath::Abs(p_vector[k]->tlv().Pt());
00260 
00261         if(k!=0 && abspt>abspt_min){
00262             //cout << "k: " << k << "abspt_min: " << abspt_min << endl; 
00263             //cout << "k: " << k << "abspt    : " << abspt  << endl; 
00264             cerr << endl
00265                  << "Class MyTools, method check_order: ERROR!\n"
00266                  << "vector: " << p_vector[0]->type() << " not sorted" << endl;
00267             //exit(1);
00268         }
00269 
00270         //cout << "k: " << k << "abspt_min: " << abspt_min << endl; 
00271         abspt_min = abspt; 
00272     }
00273 
00274     return; 
00275 }
00276 
00277 
00278 //*****************************************************************************
00279 
00280 //:::::::::::::::::::::::
00281 //:: METHOD pt_eta_cut ::
00282 //:::::::::::::::::::::::
00283 
00284 std::vector<MyParticle*> 
00285 MyTools::pt_eta_cut( const vector<MyParticle*> p_vector,
00286                      const double pt_min,  const double pt_max,
00287                      const double eta_min, const double eta_max) {
00288 
00289     std::vector<MyParticle*> tmp_v;
00290     tmp_v.clear();
00291 
00292     for (unsigned int i=0; i<p_vector.size(); i++){
00293 
00294         double pt  = (p_vector[i])->tlv().Pt();
00295         double eta = TMath::Abs((p_vector[i])->tlv().Eta());
00296 
00297         if(pt_min>-1){
00298             if(pt < pt_min) continue; 
00299         }
00300         if(pt_max>-1){
00301             if(pt > pt_max) continue; 
00302         }
00303         if(eta_min>-1){
00304             if(eta < eta_min) continue; 
00305         }
00306         if(eta_max>-1){
00307             if(eta > eta_max) continue; 
00308         }
00309 
00310         tmp_v.push_back(p_vector[i]);
00311 
00312     }
00313 
00314     return tmp_v;
00315 }
00316 
00317 //*****************************************************************************
00318 
00319 //:::::::::::::::::::::::
00320 //:: METHOD et_eta_cut ::
00321 //:::::::::::::::::::::::
00322 
00323 std::vector<MyParticle*> 
00324 MyTools::et_eta_cut( const vector<MyParticle*> p_vector,
00325                      const double et_min,  const double et_max,
00326                      const double eta_min, const double eta_max) {
00327 
00328     std::vector<MyParticle*> tmp_v;
00329     tmp_v.clear();
00330 
00331     for (unsigned int i=0; i<p_vector.size(); i++){
00332 
00333         double et  = (p_vector[i])->tlv().Et();
00334         double eta = TMath::Abs((p_vector[i])->tlv().Eta());
00335 
00336         if(et_min>-1){
00337             if(et < et_min) continue; 
00338         }
00339         if(et_max>-1){
00340             if(et > et_max) continue; 
00341         }
00342         if(eta_min>-1){
00343             if(eta < eta_min) continue; 
00344         }
00345         if(eta_max>-1){
00346             if(eta > eta_max) continue; 
00347         }
00348 
00349         tmp_v.push_back(p_vector[i]);
00350 
00351     }
00352 
00353     return tmp_v;
00354 }
00355 
00356 //*****************************************************************************
00357 
00358 //::::::::::::::::::::::::::
00359 //:: METHOD append_vector ::
00360 //::::::::::::::::::::::::::
00361 
00362 std::vector<MyParticle*> 
00363 MyTools::append_vector(std::vector<MyParticle*> first_vector, 
00364                        std::vector<MyParticle*> second_vector) {
00365 
00366     std::vector<MyParticle*> added_vector(0);
00367     
00368     for (unsigned int j=0;j<first_vector.size();j++) {
00369         added_vector.push_back(first_vector[j]);
00370     }
00371     
00372     for (unsigned int j=0;j<second_vector.size();j++) {
00373         added_vector.push_back(second_vector[j]);
00374     }
00375     
00376     return added_vector;
00377 }
00378 
00379 //*****************************************************************************
00380 
00381   //:::::::::::::::::::::::::::::::
00382   //:: METHOD remove_own_overlap ::
00383   //:::::::::::::::::::::::::::::::
00384 
00385   /*vector<MyParticle*> MyTools::remove_own_overlap( std::vector<MyParticle*> particle_vector, double radius ){
00386     double deltaR;
00387     double ptmax=0;
00388     int i_best=-1;
00389     vector<MyParticle*> new_vector;
00390     vector<MyParticle*> tmp_vector;
00391     new_vector.clear();
00392     tmp_vector.clear();
00393     cout <<"vector size  "<<particle_vector.size()<<endl;
00394     if (particle_vector.size()==1) return particle_vector;
00395     else {
00396     for (unsigned int i=1; i<particle_vector.size();i++) {
00397     for (unsigned int j=0; j<i;j++) {
00398     cout <<"i="<<i<<",  j="<<j<<endl;
00399     deltaR = particle_vector[i]->tlv().DeltaR(particle_vector[j]->tlv());
00400     if (radius>deltaR) {
00401     cout <<"same particles  ";
00402     if (particle_vector[i]->tlv().Pt()>particle_vector[j]->tlv().Pt()) {tmp_vector.push_back(particle_vector[i]);cout << i<<endl;}
00403     else if (particle_vector[i]->tlv().Pt()<particle_vector[j]->tlv().Pt()) {tmp_vector.push_back(particle_vector[j]);cout << j<<endl;}
00404     else cerr <<"WARNING: Container has particles with exactly same Pt (?)... "<<endl;
00405     }
00406     else {
00407     cout <<"not same particles "<<i<<"  "<<j<<endl;
00408     new_vector.push_back(particle_vector[i]);
00409     }
00410     }
00411     }
00412     }
00413     for (unsigned int i=0; i<tmp_vector.size();i++) {
00414     if (particle_vector[i]->tlv().Pt()>ptmax) {
00415     i_best=i;
00416     }
00417     }
00418     if (i_best!=-1) new_vector.push_back(tmp_vector[i_best]);
00419     return new_vector;
00420     }
00421   */
00422 
00423 
00424 vector<MyParticle*>
00425 MyTools::delete_doubles( vector<MyParticle*> p_vector, double delta_r){
00426     vector<MyParticle*> tmp_v;
00427     tmp_v = p_vector;
00428     //cout<<"delta_r: "<<delta_r<<endl;
00429     double dpt;
00430     double dr;
00431     dpt = 0;
00432     int n_doubles;
00433     bool double_exists;
00434     double_exists = false;
00435     n_doubles = 0;
00436     TLorentzVector tlv1;
00437     TLorentzVector tlv2;
00438     // loop starting from the last entry in the vector
00439     for (int j=tmp_v.size()-1; j>=0; j--){
00440         double_exists = false;
00441         tlv1 = (tmp_v[j])->tlv();
00442         // loop starting from the first entry up to the one
00443         // from the outer loop
00444         for (int k=0; k<j; k++){
00445             if(j==k)cerr<<"j==k in MyTools::delete_doubles"<<endl;
00446             tlv2 = (tmp_v[k])->tlv();
00447             dr = tlv1.DeltaR(tlv2);
00448             dpt = tlv1.Pt() - tlv2.Pt();
00449             if(dr<delta_r && dpt<0){
00450                 // delete this particle
00451                 n_doubles++;
00452                 double_exists = true;
00453                 //cout<<"double exists, dR: "<<dr<<", dPt: "<<dpt<<endl;
00454                 //cout<<"pt1(to delete): "<<tlv1.Pt()<<", pt2(survives): "<<tlv2.Pt()<<endl;
00455             }
00456         }
00457         
00458         if(double_exists){
00459             //cout<<"removing particle at position: "<<j<<endl;
00460             tmp_v.erase(tmp_v.begin()+j);
00461         }
00462     }
00463     //cout<<"n_doubles: "<<n_doubles<<endl;
00464     return tmp_v; 
00465    
00466 }
00467 //*****************************************************************************
00468 
00469 //:::::::::::::::::::::::::::::::
00470 //:: METHOD tauRec_ETcorr      ::
00471 //:::::::::::::::::::::::::::::::
00472 
00473 double MyTools::tauRec_ETcorr(double et_in, double eta_in, int ntrk){
00474   
00475   double m_ptetacorrectionsntr1[9] = { 0.8339,   0.8125,   0.8254,
00476                                        0.8747,   0.8583,   0.8594,
00477                                        0.9088,   0.9013,   0.8922};
00478   double m_ptetacorrectionsntr23[9]= { 0.9000,   0.8593,   0.9034,
00479                                        0.9208,   0.8791,   0.9132,
00480                                        0.9359,   0.9231,   0.9033};
00481   
00482   const int m_nptbins  = 3;
00483   const int m_netabins = 3;
00484   
00485   double m_ptpoints[m_nptbins+1] = {15., 35., 150., 0.};
00486   //  if (m_gev==1) = {15000, 35000, 150000, 0.};
00487   double m_etapoints[m_netabins+1] = {0.25, 1.0, 2.0, 0.0};
00488   
00489   double et = et_in;
00490   double eta = fabs( eta_in );
00491   double corr = 1, fudge = 1.011;
00492   
00493   unsigned int lowpt_idx = 0;
00494   unsigned int loweta_idx = 0;
00495   
00496   double lowpt_frac = 0;
00497   double loweta_frac = 0;
00498   
00499   while ( lowpt_idx < m_nptbins-1 && et > m_ptpoints[lowpt_idx+1] ) lowpt_idx++;
00500   
00501   lowpt_frac = ( m_ptpoints[lowpt_idx+1] - et ) / ( m_ptpoints[lowpt_idx+1] -
00502                                                     m_ptpoints[lowpt_idx] );   
00503   // will be >1 if et is out of bounds
00504   
00505   if ( lowpt_frac > 1 ) lowpt_frac =  1;
00506   if( lowpt_frac < 0 ) {   //should never happen, only if ptNumberOfBins is set wrong (which is checked now)
00507       std::cerr << "FIXME: lowpt_frac < 0 !!" << std::endl;
00508 //       std::cerr <<  et << std::endl;
00509 //       std::cerr <<  m_nptbins     << std::endl;
00510 //       std::cerr <<  m_ptpoints[0] << std::endl;
00511 //       std::cerr <<  m_ptpoints[1] << std::endl;
00512 //       std::cerr <<  m_ptpoints[2] << std::endl;
00513 //       std::cerr <<  lowpt_idx     << std::endl;
00514 //       std::cerr << m_ptpoints[lowpt_idx+1] << std::endl;
00515   }
00516   
00517   while ( loweta_idx < m_netabins-1 && eta > m_etapoints[loweta_idx+1] ) loweta_idx++;
00518 
00519   loweta_frac = ( m_etapoints[loweta_idx+1] - eta ) / (
00520                                                        m_etapoints[loweta_idx+1] - 
00521                                                        m_etapoints[loweta_idx] );   
00522   // will be >1 if eta is out of bounds, 
00523 
00524 //  if (eta>2){
00525 //       std::cerr << "---TEST---" << std::endl;
00526 //       std::cerr <<  eta << std::endl;
00527 //       std::cerr <<  m_netabins     << std::endl;
00528 //       std::cerr <<  m_etapoints[0] << std::endl;
00529 //       std::cerr <<  m_etapoints[1] << std::endl;
00530 //       std::cerr <<  m_etapoints[2] << std::endl;
00531 //       std::cerr <<  loweta_idx     << std::endl;
00532 //       std::cerr << m_etapoints[loweta_idx+1] << std::endl;
00533 //       std::cerr << m_etapoints[loweta_idx] << std::endl;
00534 //       std::cerr <<  loweta_frac     << std::endl;
00535 //       std::cerr << "--------" << std::endl;
00536 //   }
00537   if ( loweta_frac > 1) loweta_frac = 1;
00538   if( loweta_frac < 0 ) {    //should never happen, only if etaNumberOfBins is set wrong
00539       std::cerr << "FIXME: loweta_frac < 0 !!" << std::endl;
00540 //       std::cerr <<  eta << std::endl;
00541 //       std::cerr <<  m_netabins     << std::endl;
00542 //       std::cerr <<  m_etapoints[0] << std::endl;
00543 //       std::cerr <<  m_etapoints[1] << std::endl;
00544 //       std::cerr <<  m_etapoints[2] << std::endl;
00545 //       std::cerr <<  loweta_idx     << std::endl;
00546 //       std::cerr << m_etapoints[loweta_idx+1] << std::endl;
00547   }
00548   
00549   double coeff_matrix[2][2] = { {0, 0}, {0, 0} };
00550   
00551   if ( ntrk <= 1 ) {
00552     coeff_matrix[0][0] =
00553       m_ptetacorrectionsntr1[lowpt_idx*m_netabins+loweta_idx];
00554     if( lowpt_idx < m_nptbins-1 ){
00555       coeff_matrix[1][0] =
00556         m_ptetacorrectionsntr1[(lowpt_idx+1)*m_netabins+loweta_idx];
00557     }
00558     if( loweta_idx < m_netabins-1 ){
00559       coeff_matrix[0][1] =
00560         m_ptetacorrectionsntr1[lowpt_idx*m_netabins+(loweta_idx+1)];
00561     }
00562     if( lowpt_idx < m_nptbins-1 && loweta_idx < m_netabins-1 ){
00563       coeff_matrix[1][1] =
00564         m_ptetacorrectionsntr1[(lowpt_idx+1)*m_netabins+(loweta_idx+1)];
00565     }
00566   } else {
00567     coeff_matrix[0][0] =
00568       m_ptetacorrectionsntr23[lowpt_idx*m_netabins+loweta_idx];
00569     if( lowpt_idx < m_nptbins-1 ){
00570       coeff_matrix[1][0] =
00571         m_ptetacorrectionsntr23[(lowpt_idx+1)*m_netabins+loweta_idx];
00572     }
00573     if( loweta_idx < m_netabins-1 ){
00574       coeff_matrix[0][1] =
00575         m_ptetacorrectionsntr23[lowpt_idx*m_netabins+(loweta_idx+1)];
00576     }
00577     if( lowpt_idx < m_nptbins-1 && loweta_idx < m_netabins-1 ){
00578       coeff_matrix[1][1] =
00579         m_ptetacorrectionsntr23[(lowpt_idx+1)*m_netabins+(loweta_idx+1)];
00580     }
00581   }
00582   
00583   corr = ( coeff_matrix[0][0] * lowpt_frac * loweta_frac ) + 
00584     ( coeff_matrix[1][0] *   (1-lowpt_frac) * loweta_frac );
00585   corr += ( coeff_matrix[0][1] * lowpt_frac * (1-loweta_frac) ) + 
00586     ( coeff_matrix[1][1] *   (1-lowpt_frac) * (1-loweta_frac) );
00587   
00588   et *= corr*fudge;
00589   
00590   return et;
00591 
00592 }
00593 
00594 //:::::::::::::::::::::::::::::::
00595 //:: METHOD  correct_tau_et    ::
00596 //:::::::::::::::::::::::::::::::
00597 
00598 vector<MyParticle*> MyTools::correct_tau_et( std::vector<MyParticle*> tau_vector){
00599 
00600         vector<MyParticle*> new_vector;
00601         new_vector.clear();
00602         MyTauJet *tmp_tau = new MyTauJet;
00603         for (unsigned int k=0; k<tau_vector.size();k++) {
00604 
00605           double tau_et=((MyTauJet*)(tau_vector[k]))->ethadcalib()
00606             +((MyTauJet*)(tau_vector[k]))->etemcalib();
00607           double tau_eta=(tau_vector[k])->tlv().Eta();
00608           double tau_phi=(tau_vector[k])->tlv().Phi();
00609           int tau_ntrk=((MyTauJet*)(tau_vector[k]))->nb_tracks();
00610           
00611           
00612           double tau_et_recalib=tauRec_ETcorr(tau_et, tau_eta, tau_ntrk);
00613 
00614           double tau_e_recalib=tau_et_recalib*cosh(tau_eta);
00615           double tau_p2_recalib=tau_e_recalib*tau_e_recalib-1.77699*1.77699;
00616           double tau_p_recalib=sqrt(tau_p2_recalib);
00617           double tau_pt_recalib=tau_p_recalib/cosh(tau_eta);;
00618 
00619           TLorentzVector new_tlv;
00620           new_tlv.SetPtEtaPhiE(tau_pt_recalib,tau_eta,tau_phi,tau_e_recalib);
00621 
00622           tmp_tau=((MyTauJet*)tau_vector[k])->Clone();
00623           tmp_tau->set_tlv(new_tlv);
00624           new_vector.push_back(tmp_tau);
00625 
00626         }
00627         return new_vector;
00628 
00629 }
00630 
00631 //*****************************************************************************
00632 
00633 //::::::::::::::::::::::::
00634 //:: METHOD PrintVector ::
00635 //::::::::::::::::::::::::
00636 
00637 void
00638 MyTools::PrintVector( vector<MyParticle*> p_vector, std::string option){
00639     
00640     for (unsigned int k=0; k<p_vector.size(); k++) {
00641         (p_vector[k])->Print(option);
00642     } 
00643 
00644 }
00645 
00646 
00647 
00648 //*****************************************************************************
00649 
00650 //::::::::::::::::::::::::::::::::::
00651 //:: METHOD particles_from_vertex ::
00652 //::::::::::::::::::::::::::::::::::
00653 
00654 vector<MyParticle*> 
00655 MyTools::particles_from_vertex(const vector<MyParticle*> & p_vector, const int vertex) {
00656     
00657     vector<MyParticle*> particles;
00658 
00659     for (unsigned int k=0; k<p_vector.size(); k++) {
00660         
00661         if(p_vector[k]->vertexIndex() == vertex){
00662             particles.push_back(p_vector[k]);
00663         }
00664     }
00665     
00666     return particles;
00667     
00668 }
00669 
00670 //:::::::::::::::::::::::::::::::
00671 //:: METHOD change_btag_weight ::
00672 //:::::::::::::::::::::::::::::::
00673 
00674 double MyTools::change_btag_weight(double current_btag_weight, double delta_weight){
00675 
00676   double new_weight;
00677   new_weight = current_btag_weight + delta_weight;
00678 
00679   return new_weight;
00680 
00681 }
00682 
00683 //:::::::::::::::::::::::::
00684 //:: METHOD scale_b_tags ::
00685 //:::::::::::::::::::::::::
00686 
00687 void MyTools::scale_b_tags(std::vector<MyParticle*> * jets, int flavour, double delta_bweight){
00688 
00689   for (unsigned int il=0;il<jets->size();il++){
00690 
00691     double bweight=((MyParticleJet*)((*jets)[il]))->b_tag_weight();
00692     int pdgId=((MyParticleJet*)((*jets)[il]))->truth_flavour();
00693     double new_bweight=bweight;
00694 
00695     if (pdgId==flavour){
00696       new_bweight=change_btag_weight(bweight,delta_bweight);
00697     }
00698 
00699     ((MyParticleJet*)((*jets)[il]))->set_b_tag_weight(new_bweight);
00700 
00701 //     cout<<"flavour="<<pdgId<<" old="<<bweight<<" delta="<<delta_bweight<<" new="<<new_bweight
00702 //      <<" new_pack="<<((MyParticleJet*)((*jets)[il]))->b_tag_weight()<<"\n";
00703 
00704   }
00705 
00706 }

Generated on Tue Oct 21 11:50:46 2008 for NtupleAnalysis by  doxygen 1.5.1