NtupleReader/NtupleReader/MyTauJet.ixx

00001 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00002 // 24.10.2006, AUTHOR: THIES EHRICH
00003 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00004 
00005 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00006 //:: IMPLEMENTATION OF INLINE METHODS DEFINED IN THE CLASS MyTauJet ::
00007 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00008 
00009 //*****************************************************************************
00010 
00011   //:::::::::::::::::
00012   //:: METHOD init ::
00013   //:::::::::::::::::
00014 
00015 inline void MyTauJet::init(const TLorentzVector & p,
00016                            const double & charge, 
00017                            const int & rec_flag,
00018                            const int & index,
00019                            const double & emRadius,
00020                            const double & isolationFraction,
00021                            const double & centralityFraction,
00022                            const double & stripWidth2,
00023                            const double & nStripCells,
00024                            const double & llh,
00025                            const double & lowPtTauEleDiscriminant,
00026                            const double & tauENeuralNetwork,
00027                            const double & tauJetNeuralnetwork,
00028                            const double & etHadCalib, 
00029                            const double & etEMCalib,
00030                            const int & nb_tracks,
00031                            const TLorentzVector & track_1, 
00032                            const TLorentzVector & track_2, 
00033                            const TLorentzVector & track_3,
00034                            const int & track_TRTHits_1,
00035                            const int & track_TRTHighThresholdHits_1,
00036                            const int & track_TRTHits_2,
00037                            const int & track_TRTHighThresholdHits_2,
00038                            const int & track_TRTHits_3,
00039                            const int & track_TRTHighThresholdHits_3
00040                            ) {
00041 
00042     m_dataset_info = &MyDatasetInfo::Instance();
00043     m_tlv = p;
00044     m_charge = charge;
00045     m_rec_flag = rec_flag;
00046     m_index = index;
00047     m_emRadius= emRadius;
00048     m_isolationFraction=isolationFraction;
00049     m_centralityFraction=centralityFraction;
00050     m_stripWidth2=stripWidth2;
00051     m_nStripCells=nStripCells;
00052     m_llh = llh;
00053     m_lowPtTauEleDiscriminant = lowPtTauEleDiscriminant ;
00054     m_tauENeuralNetwork = tauENeuralNetwork;
00055     m_tauJetNeuralnetwork = tauJetNeuralnetwork;
00056     m_etHadCalib = etHadCalib;
00057     m_etEMCalib = etEMCalib;
00058     m_nb_tracks = nb_tracks;
00059     m_track_1 = track_1;
00060     m_track_2 = track_2;
00061     m_track_3 = track_3;
00062     m_track_TRTHits_1 = track_TRTHits_1;
00063     m_track_TRTHighThresholdHits_1 = track_TRTHighThresholdHits_1;
00064     m_track_TRTHits_2 = track_TRTHits_2;
00065     m_track_TRTHighThresholdHits_2 = track_TRTHighThresholdHits_2;
00066     m_track_TRTHits_3 = track_TRTHits_3;
00067     m_track_TRTHighThresholdHits_3 = track_TRTHighThresholdHits_3;
00068     m_type = "tau_jet";
00069     m_pdgId = TMath::Sign(1,(int)m_charge)*-15;
00070     m_matchingflag = 0;
00071 
00072     return;
00073 
00074   }
00075 
00076 //*****************************************************************************
00077 
00078   //::::::::::::::::::::::::::::::::
00079   //:: METHOD reconstruction_flag ::
00080   //::::::::::::::::::::::::::::::::
00081 
00082 inline int MyTauJet::reconstruction_flag(void) const {
00083 
00084     return m_rec_flag;
00085 
00086   }
00087 
00088 //*****************************************************************************
00089 
00090   //::::::::::::::::
00091   //:: METHOD llh ::
00092   //::::::::::::::::
00093 
00094 inline double MyTauJet::llh(void) const {
00095 
00096     return m_llh;
00097 
00098   }
00099 
00100 //*****************************************************************************
00101 
00102   //::::::::::::::::::::::::::::::::::::
00103   //:: METHOD lowPtTauEleDiscriminant ::
00104   //::::::::::::::::::::::::::::::::::::
00105 
00106 inline double MyTauJet::lowPtTauEleDiscriminant(void) const {
00107 
00108     return m_lowPtTauEleDiscriminant;
00109 
00110   }
00111 //*****************************************************************************
00112 
00113   //::::::::::::::::::::::::::::::
00114   //:: METHOD tauENeuralNetwork ::
00115   //::::::::::::::::::::::::::::::
00116 
00117 inline double MyTauJet::tauENeuralNetwork(void) const {
00118 
00119     return m_tauENeuralNetwork;
00120 
00121   }
00122 //*****************************************************************************
00123 
00124   //::::::::::::::::::::::::::::::::
00125   //:: METHOD tauJetNeuralnetwork ::
00126   //::::::::::::::::::::::::::::::::
00127 
00128 inline double MyTauJet::tauJetNeuralnetwork(void) const {
00129 
00130     return m_tauJetNeuralnetwork;
00131 
00132   }
00133 
00134 //*****************************************************************************
00135 
00136   //::::::::::::::::::::::::::::::::::::
00137   //:: METHOD set_reconstruction_flag ::
00138   //::::::::::::::::::::::::::::::::::::
00139 
00140 inline void MyTauJet::set_reconstruction_flag(const int & flag) {
00141 
00142     m_rec_flag = flag;
00143     return;
00144 
00145   }
00146 
00147 //*****************************************************************************
00148 
00149   //:::::::::::::::::::::::
00150   //:: METHOD emRadius ::
00151   //:::::::::::::::::::::::
00152 
00153 inline double MyTauJet::emRadius(void) const{
00154 
00155     return m_emRadius;
00156 
00157   }
00158 //*****************************************************************************
00159 
00160   //:::::::::::::::::::::::
00161   //:: METHOD isolationFraction ::
00162   //:::::::::::::::::::::::
00163 
00164 inline double MyTauJet::isolationFraction(void) const{
00165 
00166     return m_isolationFraction;
00167 
00168   }
00169 //*****************************************************************************
00170 
00171   //:::::::::::::::::::::::
00172   //:: METHOD etHadCalib ::
00173   //:::::::::::::::::::::::
00174 
00175 inline double MyTauJet::centralityFraction(void) const{
00176 
00177     return m_centralityFraction;
00178 
00179   }
00180 //*****************************************************************************
00181 
00182   //:::::::::::::::::::::::
00183   //:: METHOD etHadCalib ::
00184   //:::::::::::::::::::::::
00185 
00186 inline double MyTauJet::stripWidth2(void) const{
00187 
00188     return m_stripWidth2;
00189 
00190   }
00191 //*****************************************************************************
00192 
00193   //:::::::::::::::::::::::
00194   //:: METHOD nStripCells ::
00195   //:::::::::::::::::::::::
00196 
00197 inline double MyTauJet::nStripCells(void) const{
00198 
00199     return m_nStripCells;
00200 
00201   }
00202 //*****************************************************************************
00203 
00204   //:::::::::::::::::::::::
00205   //:: METHOD etHadCalib ::
00206   //:::::::::::::::::::::::
00207 
00208 inline double MyTauJet::ethadcalib(void) const{
00209 
00210     return m_etHadCalib;
00211 
00212   }
00213 //*****************************************************************************
00214 
00215   //::::::::::::::::::::::
00216   //:: METHOD etEMCalib ::
00217   //::::::::::::::::::::::
00218 
00219 inline double MyTauJet::etemcalib(void) const {
00220 
00221     return m_etEMCalib;
00222 
00223   }
00224 //*****************************************************************************
00225 
00226   //::::::::::::::::::::::
00227   //:: METHOD nb_tracks ::
00228   //::::::::::::::::::::::
00229 
00230 inline int MyTauJet::nb_tracks(void) const {
00231 
00232     return m_nb_tracks;
00233 
00234   }
00235 //*****************************************************************************
00236 
00237   //:::::::::::::::::::::::
00238   //:: METHOD pt_track_1 ::
00239   //:::::::::::::::::::::::
00240 
00241 inline TLorentzVector MyTauJet::track_1(void) const {
00242 
00243     return m_track_1;
00244 
00245   }
00246 //*****************************************************************************
00247 
00248   //:::::::::::::::::::::::
00249   //:: METHOD pt_track_2 ::
00250   //:::::::::::::::::::::::
00251 
00252 inline TLorentzVector MyTauJet::track_2(void) const {
00253 
00254     return m_track_2;
00255 
00256   }
00257 //*****************************************************************************
00258 
00259   //:::::::::::::::::::::::
00260   //:: METHOD pt_track_3 ::
00261   //:::::::::::::::::::::::
00262 
00263 inline TLorentzVector MyTauJet::track_3(void) const {
00264 
00265     return m_track_3;
00266 
00267   }
00268 //*****************************************************************************
00269 
00270   //::::::::::::::::::::::::::::
00271   //:: METHOD track_TRTHits_1 ::
00272   //::::::::::::::::::::::::::::
00273 
00274 inline int MyTauJet::track_TRTHits_1(void) const {
00275 
00276     return m_track_TRTHits_1;
00277 
00278   }
00279 //*****************************************************************************
00280 
00281   //:::::::::::::::::::::::::::::::::::::::::
00282   //:: METHOD track_TRTHighThresholdHits_1 ::
00283   //:::::::::::::::::::::::::::::::::::::::::
00284 
00285 inline int MyTauJet::track_TRTHighThresholdHits_1(void) const {
00286 
00287     return m_track_TRTHighThresholdHits_1;
00288 
00289   }
00290 //*****************************************************************************
00291 
00292   //::::::::::::::::::::::::::::
00293   //:: METHOD track_TRTHits_2 ::
00294   //::::::::::::::::::::::::::::
00295 
00296 inline int MyTauJet::track_TRTHits_2(void) const {
00297 
00298     return m_track_TRTHits_2;
00299 
00300   }
00301 //*****************************************************************************
00302 
00303   //:::::::::::::::::::::::::::::::::::::::::
00304   //:: METHOD track_TRTHighThresholdHits_2 ::
00305   //:::::::::::::::::::::::::::::::::::::::::
00306 
00307 inline int MyTauJet::track_TRTHighThresholdHits_2(void) const {
00308 
00309     return m_track_TRTHighThresholdHits_2;
00310 
00311   }
00312 //*****************************************************************************
00313 
00314   //::::::::::::::::::::::::::::
00315   //:: METHOD track_TRTHits_3 ::
00316   //::::::::::::::::::::::::::::
00317 
00318 inline int MyTauJet::track_TRTHits_3(void) const {
00319 
00320     return m_track_TRTHits_3;
00321 
00322   }
00323 //*****************************************************************************
00324 
00325   //:::::::::::::::::::::::::::::::::::::::::
00326   //:: METHOD track_TRTHighThresholdHits_3 ::
00327   //:::::::::::::::::::::::::::::::::::::::::
00328 
00329 inline int MyTauJet::track_TRTHighThresholdHits_3(void) const {
00330 
00331     return m_track_TRTHighThresholdHits_3;
00332 
00333   }
00334 //*****************************************************************************
00335 
00336   //::::::::::::::::::
00337   //:: METHOD clone ::
00338   //::::::::::::::::::
00339 
00340 inline MyTauJet* MyTauJet::Clone(void) const {
00341 
00342     double Px = this->tlv().Px();
00343     double Py = this->tlv().Py();
00344     double Pz = this->tlv().Pz();
00345     double E = this->tlv().E();
00346     double charge = this->charge();
00347     int rec_flag = this->reconstruction_flag();
00348     int index = this->index();
00349     double llh = this->llh();
00350     double emRadius = this->emRadius();
00351     double centralityFraction= this->centralityFraction();
00352     double isolationFraction= this->isolationFraction();
00353     double stripWidth2= this->stripWidth2();
00354     double nStripCells= this->nStripCells();
00355     double lowPtTauEleDiscriminant = this->lowPtTauEleDiscriminant();
00356     double tauENeuralNetwork = this->tauENeuralNetwork();
00357     double tauJetNeuralnetwork = this->tauJetNeuralnetwork();
00358     double etHadCalib = this->ethadcalib();
00359     double etEMCalib = this->etemcalib();
00360     int nb_tracks = this->nb_tracks();
00361     double track_px_1 = this->track_1().Px();
00362     double track_py_1 = this->track_1().Py();
00363     double track_pz_1 = this->track_1().Pz();
00364     double track_e_1 = this->track_1().E();
00365     double track_px_2 = this->track_2().Px();
00366     double track_py_2 = this->track_2().Py();
00367     double track_pz_2 = this->track_2().Pz();
00368     double track_e_2 = this->track_2().E();
00369     double track_px_3 = this->track_2().Px();
00370     double track_py_3 = this->track_3().Py();
00371     double track_pz_3 = this->track_3().Pz();
00372     double track_e_3 = this->track_3().E();
00373     int track_TRTHits_1 = this->track_TRTHits_1();
00374     int track_TRTHighThresholdHits_1 = this->track_TRTHighThresholdHits_1();
00375     int track_TRTHits_2 = this->track_TRTHits_2();
00376     int track_TRTHighThresholdHits_2 = this->track_TRTHighThresholdHits_2();
00377     int track_TRTHits_3 = this->track_TRTHits_3();
00378     int track_TRTHighThresholdHits_3 = this->track_TRTHighThresholdHits_3();
00379     
00380 
00381 
00382     MyTauJet* cloned_taujet 
00383         = new MyTauJet(TLorentzVector(Px,Py,Pz,E),charge,
00384                        rec_flag, index,
00385                        emRadius,
00386                        centralityFraction,
00387                        isolationFraction,
00388                        stripWidth2,
00389                        nStripCells,
00390                        llh, lowPtTauEleDiscriminant, 
00391                        tauENeuralNetwork, tauJetNeuralnetwork,
00392                        etHadCalib, etEMCalib, nb_tracks,
00393                        TLorentzVector(track_px_1,track_py_1,track_pz_1, track_e_1), 
00394                        TLorentzVector(track_px_2,track_py_2,track_pz_2, track_e_2),
00395                        TLorentzVector(track_px_3,track_py_3,track_pz_3, track_e_3),
00396                        track_TRTHits_1,
00397                        track_TRTHighThresholdHits_1,
00398                        track_TRTHits_2,
00399                        track_TRTHighThresholdHits_2,
00400                        track_TRTHits_3,
00401                        track_TRTHighThresholdHits_3
00402                        ); 
00403     
00404     return cloned_taujet;
00405 
00406   }
00407 //*****************************************************************************
00408 
00409   //:::::::::::::::::::::::::::::
00410   //:: METHOD get corrected Et ::
00411   //:::::::::::::::::::::::::::::
00412 
00413 inline TLorentzVector MyTauJet::tlv_corr(void) const {
00414 
00415     double m_gev;
00416     m_gev = m_dataset_info->get_scale();
00417     
00418     double m_ptetacorrectionsntr1[9] = { 0.8339,   0.8125,   0.8254,
00419                                          0.8747,   0.8583,   0.8594,
00420                                          0.9088,   0.9013,   0.8922};
00421     double m_ptetacorrectionsntr23[9]= { 0.9000,   0.8593,   0.9034,
00422                                          0.9208,   0.8791,   0.9132,
00423                                          0.9359,   0.9231,   0.9033};
00424 
00425     const int m_nptbins  = 3;
00426     const int m_netabins = 3;
00427 
00428     double m_ptpoints[m_nptbins+1] = {15000.*m_gev, 35000.*m_gev, 150000.*m_gev, 0.};
00429     double m_etapoints[m_netabins+1] = {0.25, 1.0, 2.0, 0.};
00430 
00431     double et_corr = m_etEMCalib+m_etHadCalib;
00432     double eta = fabs( m_tlv.Eta() );
00433     double corr = 1, fudge = 1.011;
00434 
00435     unsigned int lowpt_idx = 0;
00436     unsigned int loweta_idx = 0;
00437 
00438     double lowpt_frac = 0;
00439     double loweta_frac = 0;
00440                         
00441     double e_corr;
00442     double p_corr;
00443     double pt_corr;
00444     TLorentzVector m_tlv_corr;
00445                         
00446     while ( lowpt_idx < m_nptbins-1 && et_corr > m_ptpoints[lowpt_idx+1] )
00447         lowpt_idx++;
00448 
00449     lowpt_frac = ( m_ptpoints[lowpt_idx+1] - et_corr ) / ( m_ptpoints[lowpt_idx+1] -
00450                                                            m_ptpoints[lowpt_idx] );
00451     // will be >1 if et_corr is out of bounds
00452 
00453     if ( lowpt_frac > 1 )
00454         lowpt_frac =  1;
00455     if( lowpt_frac < 0 ) {   
00456         //should never happen, only if ptNumberOfBins is set wrong (which is checked now)
00457         std::cerr << "FIXME: lowpt_frac < 0 !!" << std::endl;
00458     }
00459 
00460     while ( loweta_idx < m_netabins-1 && eta > m_etapoints[loweta_idx+1] )
00461         loweta_idx++;
00462 
00463     loweta_frac = ( m_etapoints[loweta_idx+1] - eta ) / 
00464         ( m_etapoints[loweta_idx+1] - m_etapoints[loweta_idx] );
00465     // will be >1 if eta is out of bounds, 
00466 
00467     if ( loweta_frac > 1)
00468         loweta_frac = 1;
00469     if( loweta_frac < 0 ) {    //should never happen, only if etaNumberOfBins is set wrong
00470         std::cerr << "FIXME: loweta_frac < 0 !!" << std::endl;
00471     }
00472 
00473     double coeff_matrix[2][2] = { {0, 0}, {0, 0} };
00474 
00475     if ( m_nb_tracks <= 1 ) {
00476         coeff_matrix[0][0] = m_ptetacorrectionsntr1[lowpt_idx*m_netabins+loweta_idx];
00477         if( lowpt_idx < m_nptbins-1 )
00478             coeff_matrix[1][0] = m_ptetacorrectionsntr1[(lowpt_idx+1)*m_netabins+loweta_idx];
00479         if( loweta_idx < m_netabins-1 )
00480             coeff_matrix[0][1] = m_ptetacorrectionsntr1[lowpt_idx*m_netabins+(loweta_idx+1)];
00481         if( lowpt_idx < m_nptbins-1 && loweta_idx < m_netabins-1 )
00482             coeff_matrix[1][1] = m_ptetacorrectionsntr1[(lowpt_idx+1)*m_netabins+(loweta_idx+1)];
00483     } else {
00484         coeff_matrix[0][0] = m_ptetacorrectionsntr23[lowpt_idx*m_netabins+loweta_idx];
00485         if( lowpt_idx < m_nptbins-1 )
00486             coeff_matrix[1][0] = m_ptetacorrectionsntr23[(lowpt_idx+1)*m_netabins+loweta_idx];
00487         if( loweta_idx < m_netabins-1 )
00488             coeff_matrix[0][1] = m_ptetacorrectionsntr23[lowpt_idx*m_netabins+(loweta_idx+1)];
00489         if( lowpt_idx < m_nptbins-1 && loweta_idx < m_netabins-1 )
00490             coeff_matrix[1][1] = m_ptetacorrectionsntr23[(lowpt_idx+1)*m_netabins+(loweta_idx+1)];
00491     }
00492 
00493     corr = ( coeff_matrix[0][0] * lowpt_frac * loweta_frac ) 
00494         + ( coeff_matrix[1][0] * (1-lowpt_frac) * loweta_frac );
00495     
00496     corr += ( coeff_matrix[0][1] * lowpt_frac * (1-loweta_frac) ) 
00497         + ( coeff_matrix[1][1] * (1-lowpt_frac) * (1-loweta_frac) );
00498 
00499     et_corr *= corr*fudge;
00500                         
00502     //create lorentzvector//
00504     
00505     e_corr=sqrt(pow(et_corr,2)+pow(et_corr,2)*pow(cos(m_tlv.Theta())/sin(m_tlv.Theta()),2));
00506     
00507     p_corr=sqrt(pow(et_corr,2)+pow(et_corr,2)*pow(cos(m_tlv.Theta())/sin(m_tlv.Theta()),2)
00508                 -pow(1776.99*m_gev,2));
00509     
00510     pt_corr=p_corr*sin(m_tlv.Theta());
00511     
00512     m_tlv_corr. SetPtEtaPhiE(pt_corr,m_tlv.Eta(),m_tlv.Phi(),e_corr);
00513 
00514                         
00515     return m_tlv_corr;
00516   }
00517 
00518 //*****************************************************************************
00519 
00520   //::::::::::::::::::::::::::
00521   //:: METHOD PrintParticle ::
00522   //::::::::::::::::::::::::::
00523 
00524 inline void MyTauJet::PrintParticle(std::string option) {
00525 
00526     std::cout << "   rec_flag, emRadius, isolFrac: " 
00527               << Form("%i, %.2f, %.2f",
00528                       this->reconstruction_flag(),
00529                       this->emRadius(),
00530                       this->isolationFraction() ) << std::endl;
00531               
00532     if(option=="v"){
00533         
00534         std::cout << "   centrFrac, strWi2, nStrCells: " 
00535                   << Form("%.2f, %.2f, %.2f",
00536                           this->centralityFraction(),
00537                           this->stripWidth2(),
00538                           this->nStripCells() ) << std::endl;
00539 
00540         std::cout << "   lowPtTauEleDiscr, tauENN:     " 
00541                   << Form("%.2f, %.2f",
00542                           m_lowPtTauEleDiscriminant,
00543                           m_tauENeuralNetwork) << std::endl;
00544 
00545         std::cout << "   tauJetNeuralnetwork, llh:     " 
00546                   << Form("%.2f, %.2f",
00547                           m_tauJetNeuralnetwork,
00548                           m_llh ) << std::endl;
00549 
00550         std::cout << "   ethadcalib, etemcalib, n_trk: " 
00551                   << Form("%.2f, %.2f, %i",
00552                           m_etHadCalib,
00553                           m_etEMCalib,
00554                           m_nb_tracks ) << std::endl;
00555     
00556         if(this->nb_tracks()>0){
00557             std::cout << "   trk1-TRT HiThrHits, Hits:     " 
00558                       << Form("%i, %i",
00559                               m_track_TRTHighThresholdHits_1,
00560                               m_track_TRTHits_1 ) << std::endl;
00561             std::cout << "   trk1 Pt, Eta, Phi:            "
00562                       << Form("%.2f, %.2f, %.2f",
00563                               m_track_1.Pt(), 
00564                               m_track_1.Eta(), 
00565                               m_track_1.Phi()) << std::endl;
00566         }
00567     
00568         if(this->nb_tracks()>1){
00569             std::cout << "   trk2-TRT HiThrHits, Hits:     " 
00570                       << Form("%i, %i",
00571                               m_track_TRTHighThresholdHits_2,
00572                               m_track_TRTHits_2 ) << std::endl;
00573             std::cout << "   trk2 Pt, Eta, Phi:            "
00574                       << Form("%.2f, %.2f, %.2f",
00575                               m_track_2.Pt(), 
00576                               m_track_2.Eta(), 
00577                               m_track_2.Phi()) << std::endl;
00578         }
00579     
00580         if(this->nb_tracks()>2){
00581             std::cout << "   trk2-TRT HiThrHits, Hits:     " 
00582                       << Form("%i, %i",
00583                               m_track_TRTHighThresholdHits_3,
00584                               m_track_TRTHits_3 ) << std::endl;
00585             std::cout << "   trk3 Pt, Eta, Phi:            "
00586                       << Form("%.2f, %.2f, %.2f",
00587                               m_track_3.Pt(), 
00588                               m_track_3.Eta(), 
00589                               m_track_3.Phi()) << std::endl;
00590         }
00591 
00592     }
00593 
00594     return;
00595   }

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