AtlfastB.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // AtlfastB class Implementation
00003 // ================================================
00004 //
00005 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00006 //
00007 // Namespace ATLF::
00008 //
00009 
00010 #include <fstream>
00011 #include <cmath>
00012 #include <deque>
00013 #include <utility>
00014 
00015 #include "AtlfastAlgs/AtlfastB.h"
00016 #include "AtlfastAlgs/GlobalEventData.h"
00017 
00018 #include "AtlfastEvent/Jet.h"
00019 #include "AtlfastEvent/IKinematic.h"
00020 #include "AtlfastEvent/Interpolator.h"
00021 
00022 #include "AtlfastUtils/TesIO.h"
00023 #include "AtlfastUtils/HeaderPrinter.h"
00024 
00025 // Gaudi includes
00026 #include "GaudiKernel/DataSvc.h"
00027 #include "GaudiKernel/ISvcLocator.h"
00028 #include "GaudiKernel/MsgStream.h"
00029 
00030 //Other Packages used by this class
00031 // Other Packages used by this class:-
00032 
00033 #include "CLHEP/Random/Ranlux64Engine.h"
00034 #include "CLHEP/Random/RandFlat.h"
00035 #include "CLHEP/Units/SystemOfUnits.h"
00036 
00037 #include "PathResolver/PathResolver.h"
00038 
00039 //--------------------------------
00040 // Constructors and destructors
00041 //--------------------------------
00042 
00043 namespace Atlfast {
00044   
00045   using std::abs;
00046 
00047   AtlfastB::AtlfastB( const std::string& name, ISvcLocator* pSvcLocator ) 
00048     : Algorithm( name, pSvcLocator ),
00049       m_epsilonBjet(0),
00050       m_beff_interpolator(0),
00051       m_brejpu_interpolator(0),
00052       m_brejnpu_interpolator(0),
00053       m_brejtau_interpolator(0),
00054       m_brejc_interpolator(0),
00055       m_tesIO(0),
00056       m_pRandomEngine(0),
00057       m_pRandFlatGenerator(0),
00058       m_Jets(0),
00059       m_taueff_interpolator(0),
00060       m_taurej_interpolator(0)
00061   {
00062 
00063     MsgStream log( messageService(), name ) ;
00064     log << MSG::DEBUG << "Constructor" << endreq;
00065     
00066     //Default private parameters
00067     
00068     m_AtlfBJetSwitch      =  true;
00069     m_AtlfCalSwitch       =  true;
00070     m_AtlfTauSwitch       =  true;
00071     m_AtlfTauVetoSwitch   =  false;
00072     m_AtlfTrigMuoSwitch   =  false;
00073     m_atlfBNSet           =  10;
00074     m_epsitau             =  0.5;
00075     m_indtauveto          =  1;
00076     m_corrjfile           =  "atlfastDatafiles/AtlfastBjet.dat";
00077     m_corrcfile           =  "atlfastDatafiles/AtlfastBcjet.dat";
00078     m_corrtaumom          =  false;
00079     m_useTDRBParam        =  false;
00080     m_interpolateBTagging =  false;
00081     m_correctionFactor    =  1.;
00082 
00083     m_AtlfTau1P3PSwitch   =  false;
00084     m_epsitau1P           =  0.35;
00085     m_epsitau3P           =  0.08;
00086     m_Tau1P3Pcorrfile    =  "atlfastDatafiles/Tau1P3Pcorrfile.txt";
00087 
00088     // Default paths for entities in the TES
00089     m_inputLocation     = "/Event/AtlfastJets";
00090 
00091     // This is how you declare the paramemters to Gaudi so that
00092     // they can be over-written via the job options file
00093     
00094     
00095     
00096     
00097     declareProperty( "InputLocation",        m_inputLocation ) ;
00098     
00099     declareProperty( "AtlfBjetSwitch",       m_AtlfBJetSwitch ) ;
00100     declareProperty( "AtlfCalSwitch",        m_AtlfCalSwitch ) ;
00101     declareProperty( "AtlfTauSwitch",        m_AtlfTauSwitch );
00102     declareProperty( "AtlfTauVetoSwitch",    m_AtlfTauVetoSwitch );
00103     declareProperty( "AtlfTrigMuoSwitch",    m_AtlfTrigMuoSwitch );
00104     declareProperty( "AtlfTau1P3PSwitch",    m_AtlfTau1P3PSwitch );
00105 
00106     
00107     declareProperty( "AtlfBNSet",            m_atlfBNSet ) ;
00108     declareProperty( "TauEff",               m_epsitau ) ;
00109     declareProperty( "TauVetoOption",        m_indtauveto ) ;
00110     declareProperty( "Tau1PEff",             m_epsitau1P ) ;
00111     declareProperty( "Tau3PEff",             m_epsitau3P ) ;
00112     
00113     declareProperty( "JetCorrFile",          m_corrjfile ) ;
00114     declareProperty( "CJetCorrFile",         m_corrcfile ) ;
00115     declareProperty( "Tau1P3PCorrFile",      m_Tau1P3Pcorrfile ) ;
00116     
00117     declareProperty( "UseTDRBParam",         m_useTDRBParam );
00118     declareProperty( "InterpolateBTagging",  m_interpolateBTagging );
00119     declareProperty( "BCorrectionFactor",    m_correctionFactor); 
00120     // m_correctionFactor less than 1 : degradation of peformances
00121 
00122     declareProperty( "CalibrateTauMomentum", m_corrtaumom );
00123 
00124     log << MSG::DEBUG << "End of constructor" << endreq;
00125 
00126   }
00127   
00128   AtlfastB::~AtlfastB() {
00129     
00130     MsgStream log( messageService(), name() ) ;
00131     log << MSG::DEBUG << "Destructor" << endreq;
00132     if ( m_tesIO )                delete m_tesIO;
00133     if ( m_pRandomEngine )        delete m_pRandomEngine;
00134     if ( m_pRandFlatGenerator )   delete m_pRandFlatGenerator;
00135     if ( m_taueff_interpolator )  delete m_taueff_interpolator;
00136     if ( m_taurej_interpolator )  delete m_taurej_interpolator;
00137     if ( m_beff_interpolator )    delete m_beff_interpolator;
00138     if ( m_brejpu_interpolator )  delete m_brejpu_interpolator;
00139     if ( m_brejnpu_interpolator ) delete m_brejnpu_interpolator;
00140     if ( m_brejtau_interpolator ) delete m_brejtau_interpolator;
00141     if ( m_brejc_interpolator )   delete m_brejc_interpolator;
00142   }
00143   
00144   
00145   
00146   //---------------------------------
00147   // initialise() 
00148   //---------------------------------
00149   
00150   StatusCode AtlfastB::initialize(){
00151     MsgStream log( messageService(), name() ) ;
00152     log << MSG::DEBUG << "instantiating an AtlfastB" << endreq;
00153     
00154 
00155     m_corrjfile         =  PathResolver::find_file (m_corrjfile, "DATAPATH");
00156     m_corrcfile         =  PathResolver::find_file (m_corrcfile, "DATAPATH");
00157     m_Tau1P3Pcorrfile   =  PathResolver::find_file (m_Tau1P3Pcorrfile, "DATAPATH");
00158 
00159     log << MSG::DEBUG << " m_corrjfile after PathResolver: " << m_corrjfile <<endreq;
00160     log << MSG::DEBUG << " m_corrcfile after PathResolver: " << m_corrcfile <<endreq;
00161     log << MSG::DEBUG << " m_Tau1P3Pcorrfile after PathResolver: " << m_Tau1P3Pcorrfile <<endreq;
00162 
00163     //Had to move this section above the TesIO call
00164     //Flat random number generator
00165     //get the Global Event Data using singleton pattern
00166 
00167     GlobalEventData* ged = GlobalEventData::Instance();
00168     int randSeed = ged->randSeed() ;
00169     // load the location of the MC in StoreGate
00170     m_mcLocation       = ged -> mcLocation();
00171 
00172     m_tesIO= new TesIO(m_mcLocation, ged->justHardScatter());
00173     
00174     std::string fn; // For filenames
00175 
00176     if (m_useTDRBParam) {
00177       //open files for jet correction factors
00178       
00179       std::ifstream inputjetfile;
00180       inputjetfile.open(m_corrjfile.c_str());
00181       
00182       if(inputjetfile){
00183         
00184         log << MSG::INFO 
00185             << "Pt jet correction factors file " 
00186             << m_corrjfile
00187             <<" open."
00188             <<endreq;
00189         int nrow;
00190         int ncolumn;
00191         inputjetfile>>nrow;
00192         inputjetfile>>ncolumn;
00193         if(nrow != 5||ncolumn != 8) {
00194           log << MSG::ERROR
00195               <<"no. of input rows,columns: "
00196               <<nrow<<" "
00197               <<ncolumn<<" "
00198               <<"expected 5, 8 "
00199               <<endreq;  
00200           return StatusCode::FAILURE ;
00201         }
00202         
00203         for(int i=0; i<nrow;i++){
00204           for(int j=0; j<ncolumn; j++){
00205             
00206             int nset = -1;
00207             switch (j){
00208               
00209             case 0:
00210               nset=1;
00211               break;
00212             case 1:
00213               nset=2;
00214               break;
00215             case 2:
00216               nset=3;
00217               break;
00218             case 3:
00219               nset=5;
00220               break;
00221             case 4:
00222               nset=11;
00223               break;
00224             case 5:
00225               nset=12;
00226               break;
00227             case 6:
00228               nset=13;
00229               break;
00230             case 7:
00231               nset=14;
00232               break;
00233             default:
00234               log << MSG::ERROR<<"j="<<j<<" Nset= "<<nset
00235                   <<"  value not correct. Nset must b one of those: 1,2,3,5,11,12,13,14 "<<endreq;
00236               return StatusCode::FAILURE;
00237               break;
00238               
00239               
00240             }
00241             inputjetfile>>m_corrj[i][nset];
00242             
00243           }
00244         }
00245         
00246       }else{
00247         log << MSG::ERROR << "Pt jet correction factors file not found" <<endreq;
00248         return StatusCode::FAILURE ;
00249       }
00250       inputjetfile.close();
00251       
00252       std::ifstream inputcjetfile;
00253       inputcjetfile.open(m_corrcfile.c_str());
00254       
00255       if(inputcjetfile){
00256         
00257         log << MSG::INFO 
00258             << "Pt c jet correction factors file " 
00259             << m_corrcfile
00260             <<" open."
00261             <<endreq;
00262         int nrow;
00263         int ncolumn;
00264         inputcjetfile>>nrow;
00265         inputcjetfile>>ncolumn;
00266         if(nrow != 5||ncolumn != 8) {
00267           log << MSG::ERROR
00268               <<"no. of input rows,columns: "
00269               <<nrow<<" "
00270               <<ncolumn<<" "
00271               <<"expected 5, 8 "
00272               <<endreq;  
00273           return StatusCode::FAILURE ;
00274         }
00275         for(int i=0; i<nrow;i++){
00276           for(int j=0; j<ncolumn; j++){
00277             
00278             int nset;
00279             switch (j){
00280               
00281             case 0:
00282               nset=1;
00283               break;
00284             case 1:
00285               nset=2;
00286               break;
00287             case 2:
00288               nset=3;
00289               break;
00290             case 3:
00291               nset=5;
00292               break;
00293             case 4:
00294               nset=11;
00295               break;
00296             case 5:
00297               nset=12;
00298               break;
00299             case 6:
00300               nset=13;
00301               break;
00302             case 7:
00303               nset=14;
00304               break;
00305             default:
00306               log << MSG::ERROR<<"Nset value not correct. Nset must be one of these: 1,2,3,5,11,12,13,14 "<<endreq;
00307               return StatusCode::FAILURE;
00308               break;
00309             }
00310             inputcjetfile>>m_corrc[i][nset];
00311           }
00312         }
00313         
00314       }else{
00315         log << MSG::ERROR 
00316             << "Pt c jet correction factors file not found" 
00317             <<endreq;
00318         return StatusCode::FAILURE ;
00319       }
00320       inputcjetfile.close();
00321     } else {
00322       int ialgo = m_atlfBNSet; 
00323       if (ialgo < 1 || (ialgo > 14 && ialgo != 100) ) {
00324         log << MSG::FATAL << "NSET not correct. Should be between 1 and 14, or 100 for canonical b-tagging" << endreq;
00325         return StatusCode::FAILURE;
00326       }
00327       
00328       // Make new Interpolators for the b-tagging efficiencies and rejections
00329       std::string path = "atlfastDatafiles/RejectionFactor";
00330       std::ostringstream o;
00331       o << m_atlfBNSet;
00332       
00333       makeInterpolator(m_beff_interpolator,"atlfastDatafiles/BEfficiency"+o.str()+".txt",true);
00334       makeInterpolator(m_brejpu_interpolator,path+"PU"+o.str()+".txt",true);
00335       makeInterpolator(m_brejnpu_interpolator,path+"NPU"+o.str()+".txt",true);
00336       makeInterpolator(m_brejtau_interpolator,path+"Tau"+o.str()+".txt",true);
00337       makeInterpolator(m_brejc_interpolator,path+"C"+o.str()+".txt",true);
00338 
00339 
00340       // The efficiency is defined by m_atlfBNSet (for m_atlfBNSet <= 14)
00341       std::string algName = "IP2D"; 
00342       if (ialgo == 100) {
00343         algName = "Canonical";
00344         m_epsilonBjet = 0.6;
00345       } else {
00346         if (ialgo > 7){
00347           algName = "SV1+IP3D";
00348           ialgo -= 7;
00349         }
00350         m_epsilonBjet = 0.5 + (ialgo - 1)*0.05;
00351       }
00352       
00353       log << MSG::INFO << "Running with " << algName << " at eps_b = " << m_epsilonBjet << endreq;
00354       
00355     }
00356     
00357     // Read Tau1P3P energy rescaling information from file
00358     std::ifstream inputfileTau1P3P;
00359     inputfileTau1P3P.open(m_Tau1P3Pcorrfile.c_str());
00360     
00361     if(inputfileTau1P3P){
00362 
00363       int nrow;
00364       int ncolumn;
00365       inputfileTau1P3P>>nrow;
00366       inputfileTau1P3P>>ncolumn;
00367 
00368       // Read corr factor bins from file
00369       for(int i=0; i<ncolumn; i++){inputfileTau1P3P>>m_corr1P3P[i];}
00370 
00371       // Read corr factor probabilities for Tau1P in 6 PT bins
00372       for(int j=0; j<nrow; j++){
00373         for(int k=0; k<ncolumn; k++){
00374           inputfileTau1P3P>>m_corr_prob1P[j][k];
00375         }
00376       }    
00377       // Read corr factor probabilities for Tau3P in 6 PT bins
00378       for(int l=0; l<nrow; l++){
00379         for(int m=0; m<ncolumn; m++){
00380           inputfileTau1P3P>>m_corr_prob3P[l][m];
00381         }
00382       }
00383     }else{
00384       log << MSG::ERROR 
00385           << "Tau1P3P corr factor file not found" 
00386           <<endreq;
00387       return StatusCode::FAILURE ;
00388     }
00389 
00390     // Check Tau1P3P efficiencies are within range
00391     if( m_epsitau1P < 0.20){m_epsitau1P = 0.00;
00392     log << MSG::INFO<< "Tau1PEff below allowed range (<0.10). Set Tau1PEff = 0.0 "<<endreq;}
00393     if( m_epsitau1P > 0.40){m_epsitau1P = 0.40;
00394     log << MSG::INFO<< "Tau1PEff above allowed range (>0.40). Set Tau1PEff = 0.40"<<endreq;}
00395     if( m_epsitau3P < 0.05){m_epsitau3P = 0.00;
00396     log << MSG::INFO<< "Tau3PEff below allowed range (<0.05). Set Tau3PEff = 0.0 "<<endreq;}
00397     if( m_epsitau3P > 0.10){m_epsitau3P = 0.10;
00398     log << MSG::INFO<< "Tau3PEff above allowed range (>0.10). Set Tau3PEff = 0.10"<<endreq;}
00399 
00400     
00401     m_pRandomEngine = new Ranlux64Engine(randSeed);
00402     m_pRandFlatGenerator=new RandFlat(*m_pRandomEngine);
00403     
00404     // Create interpolator for tau jet efficiencies
00405     
00406     makeInterpolator(m_taueff_interpolator,"atlfastDatafiles/TauEfficiencies.txt",false);
00407     makeInterpolator(m_taurej_interpolator,"atlfastDatafiles/TauRejections.txt",false);
00408 
00409     HeaderPrinter hp("AtlfastB:", log);
00410     
00411     hp.add("TES Locations:              ");
00412     hp.add(" Jets from                     ", m_inputLocation); 
00413     hp.add("AtlfBje switch:                ", m_AtlfBJetSwitch);
00414     hp.add("AtlfBje NSet:                  ", m_atlfBNSet);
00415     hp.add("AtlfCal switch:                ", m_AtlfCalSwitch);
00416     hp.add("AtlfTau switch:                ", m_AtlfTauSwitch);    
00417     hp.add("AtlfTauVeto switch:            ", m_AtlfTauVetoSwitch);
00418     hp.add("AtlfTrigMuo switch:            ", m_AtlfTrigMuoSwitch); 
00419     hp.add("AtlfTau1P3P switch:            ", m_AtlfTau1P3PSwitch);
00420     hp.add("correction file 1:             ", m_corrjfile); 
00421     hp.add("correction file 2:             ", m_corrcfile); 
00422     hp.print();
00423     
00424     return StatusCode::SUCCESS ;
00425   }
00426   
00427   //---------------------------------
00428   // finalise() 
00429   //---------------------------------
00430   
00431   StatusCode AtlfastB::finalize(){
00432     
00433     MsgStream log( messageService(), name() ) ;
00434     log << MSG::INFO << "finalizing" << endreq;    
00435     return StatusCode::SUCCESS ;
00436   }
00437   
00438   
00439   //----------------------------------------------
00440   // execute() method called once per event
00441   //----------------------------------------------
00442   
00443   StatusCode AtlfastB::execute(){
00444     
00445     StatusCode sc;
00446     MsgStream log( messageService(), name() ) ;  
00447     
00448     log << MSG::DEBUG<<"In execute"<<endreq;
00449 
00450     if(!m_tesIO->getDH(m_Jets, m_inputLocation)){
00451       log << MSG::ERROR
00452           << "Couldn't retrieve JetCollection" << m_inputLocation 
00453           << endreq ;
00454       return StatusCode::FAILURE;
00455     }
00456     
00457     if(m_AtlfBJetSwitch){
00458       //Apply efficiency for b-jet identification
00459       
00460 
00461       
00462       sc = m_useTDRBParam ? atlfBje_TDR() : atlfBje();
00463       
00464       if(sc.isFailure()){
00465         log << MSG::ERROR<<"Error in atlfBje"<<endreq;
00466         return StatusCode::FAILURE;
00467       }
00468  
00469     }
00470 
00471     if(m_AtlfTauSwitch){
00472       
00473       //Apply efficiency for tau-jet identification
00474       
00475       sc=atlfTau(m_epsitau);
00476       
00477       if(sc.isFailure()){
00478         log << MSG::ERROR<<"Error in atlfTau"<<endreq;
00479         return StatusCode::FAILURE;
00480       }
00481 
00482     }
00483     
00484     if(m_AtlfTau1P3PSwitch){
00485 
00486       //Apply Tau1P3P efficiency for tau-jet identification
00487 
00488       sc=atlfTau1P3P();
00489 
00490       if(sc.isFailure()){
00491         log << MSG::ERROR<<"Error in atlfTau1P3P"<<endreq;
00492         return StatusCode::FAILURE;
00493       }
00494 
00495     }
00496 
00497     if(m_AtlfTauVetoSwitch){
00498       
00499       //Apply veto for tau-jet
00500       
00501       sc=atlfTauVeto(m_indtauveto);
00502       
00503       if(sc.isFailure()){
00504         log << MSG::ERROR<<"Error in atlfTauVeto"<<endreq;
00505         return StatusCode::FAILURE;
00506       }
00507 
00508     }
00509     
00510  
00511     if(m_AtlfTrigMuoSwitch){
00512       
00513       //Apply efficiency for muon trigger. Not implemented yet!
00514       
00515       sc=atlfTrigMuo();
00516       
00517       if(sc.isFailure()){
00518         log << MSG::ERROR<<"Error in atlfTrigMuo"<<endreq;
00519         return StatusCode::FAILURE;
00520       }
00521       
00522     }   
00523     
00524     
00525     if(m_AtlfCalSwitch){
00526       
00527       //Recalibrate jet energies
00528       
00529       sc=atlfCal();
00530       
00531       if(sc.isFailure()){
00532         log << MSG::ERROR<<"Error in atlfCal"<<endreq;
00533         return StatusCode::FAILURE;
00534       }
00535       
00536     }
00537     
00538     
00539     //......................................
00540     // Fill jets that have been successfully tagged and calibrated in JetCollection 
00541     //and register them in the transient event store. 
00542     
00543     
00544     /*
00545     JetCollection* myCalJets=new JetCollection;
00546     
00547     for(m_it=m_Jets.begin();m_it<m_Jets.end();++m_it){
00548       myCalJets->push_back(*m_it);
00549     }
00550 
00551     */
00552     
00553     //JetCollection::const_iterator jetcolit = m_Jets->begin();
00554     m_it = m_Jets->begin();
00555     
00556 
00557     for( ; m_it != m_Jets->end(); ++m_it ){
00558 
00559       log << MSG::DEBUG
00560           <<"original jets: PDGID= "<<(*m_it)->pdg_id()
00561           <<" B tag= "   <<(*m_it)->isBTagged()
00562           <<" B tag corr factor = " << (*m_it)->bTagCorrFactor()
00563           <<" Tau tag= " <<(*m_it)->isTauTagged()
00564           <<" Tau tag corr factor = " << (*m_it)->tauTagCorrFactor()
00565           <<" pT = "     << (*m_it)->pT() << endreq;
00566       /*
00567       log << MSG::DEBUG
00568           <<"Jets After AtlfastB: PDGID= "<<(*jetcolit)->pdg_id()
00569           <<" B tag= "    <<(*jetcolit)->isBTagged()
00570           <<" B tag corr factor = " << (*m_it)->bTagCorrFactor()
00571           <<" Tau tag= "  <<(*jetcolit)->isTauTagged()
00572           <<" Tau tag corr factor = " << (*m_it)->tauTagCorrFactor()
00573           <<" pT = " << (*jetcolit)->pT() << endreq;
00574       */
00575       //++m_it;
00576     }
00577     
00578 
00579     
00580     TesIoStat stat = m_tesIO->lock( m_Jets ) ;
00581     if(!stat){
00582       log<<MSG::ERROR<<"Could not lock jet collection"<<endreq;
00583       return stat;
00584     }
00585     
00586     
00587     return StatusCode::SUCCESS; 
00588   }
00589   
00590   //-------------------------------
00591   // helper methods implementation
00592   //-------------------------------
00593   
00594   StatusCode AtlfastB::atlfBje_TDR(){
00595     
00596     MsgStream log( messageService(), name() ) ; 
00597     
00598 
00599     switch(m_atlfBNSet){
00600       
00601     case 1:
00602       m_epsib=0.5;
00603       m_epsic=1./10.9;
00604       m_epsij=1./231.;
00605       break;
00606       
00607     case 2:
00608       m_epsib=0.60;
00609       m_epsic=1./6.7;
00610       m_epsij=1./93.;
00611       break;
00612       
00613     case 3:
00614       m_epsib=0.70;
00615       m_epsic=1./4.3;
00616       m_epsij=1./34.1;
00617       break;
00618       
00619     case 5:
00620       m_epsib=0.60;
00621       m_epsic=1./10.;
00622       m_epsij=1./100.;
00623       break;
00624       
00625     case 11:
00626       m_epsib=0.33;
00627       m_epsic=1./22.9;
00628       m_epsij=1./1381.;
00629       break;
00630       
00631     case 12:
00632       m_epsib=0.43;
00633       m_epsic=1./10.8;
00634       m_epsij=1./219.;
00635       break;
00636       
00637     case 13:
00638       m_epsib=0.53;
00639       m_epsic=1./6.7;
00640       m_epsij=1./91.;
00641       break;
00642       
00643     case 14:
00644       m_epsib=0.624;
00645       m_epsic=1./6.7;
00646       m_epsij=1./91.;
00647       break;
00648       
00649     default:
00650       log << MSG::ERROR<<"No b jet tagging efficiencies applied"<<endreq;
00651       return StatusCode::FAILURE;
00652       break;
00653     }
00654     
00655     
00656     //Apply randomized B tagging
00657     
00658     log<<MSG::DEBUG<<"Applying randomized B tagging...."<<endreq;
00659     
00660     for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
00661       
00662       double randnum;
00663       double corpt;    
00664       double corr;
00665       
00666       double ptjet=(*m_it)->pT();
00667       double etajet=(*m_it)->eta();
00668       int pdgid=(*m_it)->pdg_id();
00669       
00670       //apply b tagging as for recalibrated jets
00671       
00672       
00673       corr=fitcoreb(ptjet);
00674 
00675       ptjet=corr*ptjet;
00676 
00677       randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
00678       
00679       corpt=0.;
00680       
00681       if(abs(pdgid)==5){
00682 
00683         if((abs(etajet)<=2.5)&&(randnum<m_epsib)){
00684           (*m_it)->setBTagged("TDR");
00685         }
00686         
00687       }else if(abs(pdgid)==4){
00688         
00689         if(ptjet<=30.*GeV) corpt=m_corrc[0][m_atlfBNSet];
00690         if((ptjet>30.*GeV)&&(ptjet<= 45.*GeV)) corpt=m_corrc[1][m_atlfBNSet];
00691         if((ptjet>45.*GeV)&&(ptjet<= 60.*GeV)) corpt=m_corrc[2][m_atlfBNSet];   
00692         if((ptjet>60.*GeV)&&(ptjet<=100.*GeV)) corpt=m_corrc[3][m_atlfBNSet];
00693         if(ptjet>100.*GeV) corpt=m_corrc[4][m_atlfBNSet];
00694 
00695         if((abs(etajet)<=2.5)&&(randnum<(m_epsic/corpt))) {
00696           (*m_it)->setBTagged("TDR");
00697         }
00698         
00699       }else if(((abs(pdgid)!=4)&&(abs(pdgid)!=5))||abs(pdgid)==15){
00700         
00701         if(ptjet<=30.*GeV) corpt=m_corrj[0][m_atlfBNSet];
00702         if((ptjet>30.*GeV)&&(ptjet<=45.*GeV)) corpt=m_corrj[1][m_atlfBNSet];
00703         if((ptjet>45.*GeV)&&(ptjet<=60.*GeV)) corpt=m_corrj[2][m_atlfBNSet];    
00704         if((ptjet>60.*GeV)&&(ptjet<=100.*GeV)) corpt=m_corrj[3][m_atlfBNSet];
00705         if(ptjet>100.*GeV) corpt=m_corrj[4][m_atlfBNSet];
00706 
00707         if((abs(etajet)<=2.5)&&(randnum<(m_epsij/corpt))) {
00708           (*m_it)->setBTagged("TDR");
00709         }
00710 
00711       }
00712     } 
00713 
00714     return StatusCode::SUCCESS;
00715 
00716   }
00717   
00718   StatusCode AtlfastB::atlfBje() {
00719     
00720     MsgStream mlog(messageService(), name());
00721     //
00722     mlog << MSG::DEBUG << "Applying randomized B tagging, new parametrization" <<endreq;
00723 
00724     int debug = 0;
00725     if (mlog.level() < MSG::DEBUG) debug = 1;
00726     
00727     for(m_it=m_Jets->begin(); m_it<m_Jets->end(); ++m_it){
00728       
00729       double randnum = m_pRandFlatGenerator->shoot(m_pRandomEngine);   
00730       double ptjet   = (*m_it)->pT();
00731       double etajet  = (*m_it)->eta();
00732       int pdgid      = (*m_it)->pdg_id();
00733 
00734       // Input to interpolators
00735       deque<double> input_values;
00736       input_values.push_back(ptjet/1.e3);
00737       input_values.push_back(fabs(etajet));
00738 
00739       if ( fabs(etajet) <= 2.5 ) {
00740         if (abs(pdgid) == 5) {
00741           // useless for NSET <= 14 (flat fixed efficiency) and 100 (canonical)
00742           // useful for NSET > 14 (!=100) (fixed cut)
00743           double epsilonBjet = m_interpolateBTagging ?
00744             m_beff_interpolator->interpolate(input_values) :
00745             m_beff_interpolator->getNearestValue(input_values);
00746           mlog << MSG::DEBUG << " epsb( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< epsilonBjet << endreq;
00747           if ( randnum < epsilonBjet )
00748             (*m_it)->setBTagged("SV1+IP3D");
00749         } else if (abs(pdgid) == 4) {
00750           double RejC = m_interpolateBTagging ?
00751             m_brejc_interpolator->interpolate(input_values) :
00752             m_brejc_interpolator->getNearestValue(input_values);
00753           mlog << MSG::DEBUG << " Rc( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< RejC << endreq;
00754           if ( randnum < 1./RejC )
00755             (*m_it)->setBTagged("SV1+IP3D");
00756         } else if (abs(pdgid) == 15) {
00757           double RejTau = m_interpolateBTagging ?
00758             m_brejtau_interpolator->interpolate(input_values) :
00759             m_brejtau_interpolator->getNearestValue(input_values);
00760           mlog << MSG::DEBUG << " Rtau( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< RejTau << endreq;
00761           if ( randnum < 1./RejTau ) 
00762             (*m_it)->setBTagged("SV1+IP3D");
00763         } else {
00764           double RejLight = m_interpolateBTagging ?
00765             m_brejpu_interpolator->interpolate(input_values) :
00766             m_brejpu_interpolator->getNearestValue(input_values);
00767           double dRb   = (*m_it)->getdRbquark();
00768           double dRc   = (*m_it)->getdRcquark();
00769           double dRtau = (*m_it)->getdRhadtau();
00770           if (dRb < 0.8 || dRc < 0.8 || dRtau < 0.8) {
00771             RejLight = m_interpolateBTagging ?
00772             m_brejnpu_interpolator->interpolate(input_values) :
00773             m_brejnpu_interpolator->getNearestValue(input_values);
00774           }
00775           mlog << MSG::DEBUG << " RLight( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< RejLight << endreq;
00776           // correction factor only for light jet at zero order 
00777           // since the quality of reconstruction matters here 
00778           // (contrary to c jets, where physics dominates)
00779           if ( randnum < 1./(RejLight*m_correctionFactor) )
00780             (*m_it)->setBTagged("SV1+IP3D");
00781         }
00782       } //else{
00783         //(*m_it)->setLightTag();
00784       //}
00785     }
00786     return StatusCode::SUCCESS;
00787   }  
00788   
00789   StatusCode AtlfastB::atlfCal(){
00790     
00791     //It recalibrates the energy of all jets using parameterisation 
00792     //obtained with 'Z+jet' equivalent method
00793     
00794     MsgStream log( messageService(), name() ) ; 
00795     
00796     for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
00797       
00798       double ptjet=(*m_it)->pT();
00799       
00800       // Correction factor for b-jet momentum
00801       (*m_it)->setBTagCorrFactor("SV1+IP3D",fitcoreb(ptjet));
00802       
00803       // Correction factor for tau jets
00804       (*m_it)->setTauTagCorrFactor("Tau",1.);
00805       
00806       // Correction factor for b-jet momentum
00807       (*m_it)->setLightTagCorrFactor("Standard",fitcoreu(ptjet));      
00808       
00809     }
00810     
00811     return StatusCode::SUCCESS;
00812 
00813   }
00814   
00815   
00816   StatusCode AtlfastB::atlfTau(double epsitau){
00817     
00818     MsgStream log( messageService(), name() ) ; 
00819     //StatusCode sc;
00820     
00821     for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
00822       
00823       double randnum;
00824       
00825       double etajet=(*m_it)->eta();      
00826       double ptjet=(*m_it)->pT();
00827       int pdgid=(*m_it)->pdg_id();
00828       
00829       randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
00830       
00831       deque<double> input_values;
00832       // Efficiencies are percentages in the input file
00833       input_values.push_back(epsitau*100.);
00834       // Efficiencies considered symmetric in eta
00835       input_values.push_back(fabs(etajet));
00836       // pT in GeV in input file
00837       input_values.push_back(ptjet/GeV);
00838       
00839       
00840       if(abs(pdgid)==15){
00841         
00842         // If the jet falls outside Interpolator limits, taueff = 0
00843         double taueff = m_taueff_interpolator->interpolate(input_values);
00844         
00845         if(randnum<taueff){
00846           
00847           (*m_it)->setTauTagged("Standard");
00848           log << MSG::DEBUG << "setTauTagged(\"Standard\"), pT = " << (*m_it)->pT() << endreq;
00849           
00850         }
00851         
00852       }else if(abs(etajet)<=2.5){
00853         
00854         double taurej = m_taurej_interpolator->interpolate(input_values);
00855         // taurej = 0 if values fall outside the Interpolator limits
00856         // Assume dummy rejection of 1e9
00857         if (!taurej) taurej = 1e9;
00858         
00859         if(randnum<(1./taurej)){
00860           (*m_it)->setTauTagged("Standard");
00861           log << MSG::DEBUG << "setTauTagged(\"Standard\"), pT = " << (*m_it)->pT() << endreq;
00862         }
00863         
00864       }
00865       
00866     }
00867 
00868     return StatusCode::SUCCESS;
00869     
00870   }
00871   
00872   
00873   StatusCode AtlfastB::tautag(double pt, 
00874                               double eta, 
00875                               double efftau, 
00876                               double &rjet, int &iflag){
00877     
00878     //It computes the corresponding jet rejection rjet
00879     //inputs: pt and eta of cluster, efftau-> eff(in %)  for tau identification
00880     
00881     MsgStream log( messageService(), name() ) ; 
00882 
00883     iflag=0;   
00884 
00885 
00886     double ptInGeV = pt/GeV;
00887     
00888     if((ptInGeV<15.)||(ptInGeV>150.)){
00889       
00890       
00891       log << MSG::DEBUG<<"Tau pt value out of range (15<pt<150 GeV): pt= "<<ptInGeV
00892           <<" GeV No tau tagging efficiencies will be applied"<<endreq;
00893 
00894       iflag=1;
00895       
00896     }
00897     if(abs(eta)>2.5){
00898       
00899       log << MSG::DEBUG<<"Tau eta value out of range (eta<2.5): eta= "<<eta<<" No tau tagging efficiencies will be applied"<<endreq;
00900       
00901 
00902       iflag=1;
00903       
00904     }
00905     
00906 
00907     //eta dependence
00908     double eff=efftau;
00909     double coefe1;
00910     double coefe3;
00911     double coef1;
00912     double coef2;
00913     
00914     if(abs(eta)<0.7){
00915       coefe1=1.35-0.0035*efftau;
00916       eff=efftau/coefe1;
00917     }
00918     if(abs(eta)>1.5){
00919       coefe3=0.70+0.0030*efftau;
00920       eff=efftau/coefe3;
00921     }
00922     if(eff>100){
00923       
00924       
00925       log << MSG::WARNING<<"Tau efficiency value > 100 ! eff= "<<eff<<endreq;
00926       iflag=1;
00927     }
00928     
00929 
00930     coef1=0.027+0.00024*ptInGeV;
00931     coef2=2.28+0.027*ptInGeV;
00932 
00933     coef1=0.027+0.00024*ptInGeV;
00934     coef2=2.28+0.027*ptInGeV;
00935     rjet=pow(10,(-coef1*eff+coef2));
00936     
00937   
00938     
00939     //     log << MSG::DEBUG<<"Tau rejection value computed in tautag= "<<rjet<<endreq;
00940     
00941     
00942     return StatusCode::SUCCESS;
00943     
00944   }
00945   
00946 
00947   StatusCode AtlfastB::atlfTau1P3P(){
00948     
00949     MsgStream log( messageService(), name() ) ; 
00950     //StatusCode sc;
00951     
00952     const double MaxPTinGeV = 150.0;
00953     
00954     for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
00955       double randnum;
00956       
00957       double etajet=(*m_it)->eta();      
00958       double ptjet=(*m_it)->pT();
00959       int pdgid=(*m_it)->pdg_id();
00960       
00961       randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
00962       
00963       if(abs(pdgid)==15){
00964 
00965         if(ptjet/GeV > MaxPTinGeV){
00966         log << MSG::DEBUG<<"Jet with pT="<<ptjet/GeV<<" GeV; Outside range of Tau1P3P - Not Considered for tagging"<<endreq;
00967         }else{
00968         
00969           double tau1Peff = m_epsitau1P;
00970           double tau3Peff = m_epsitau3P;
00971 
00972           // Adjust tau3P efficiency due to lower efficiency at low PT
00973           if     ( ptjet/GeV >= 10.0 && ptjet/GeV < 20.0){ tau3Peff = 0.0; }
00974           else if( ptjet/GeV >= 20.0 && ptjet/GeV < 45.0){ tau3Peff = (0.0232*ptjet/GeV-0.044) * m_epsitau3P;}
00975           else if( ptjet/GeV >= 45.0 ){tau3Peff = m_epsitau3P;}
00976 
00977           if(randnum<tau1Peff){
00978             // tag as tau1P
00979             (*m_it)->setTauTagged("Tau1P3P:1prong");
00980             (*m_it)->setTauTagCorrFactor("Tau1P3P", 1. );
00981             log << MSG::DEBUG << "setTauTagged(\"Tau1P3P:1prong\"), pT = " << (*m_it)->pT() << endreq;
00982           }else if(randnum>=tau1Peff && randnum<(tau1Peff+tau3Peff) ){
00983             // tag as tau3P
00984             (*m_it)->setTauTagged("Tau1P3P:3prong");
00985             (*m_it)->setTauTagCorrFactor("Tau1P3P", 1. );
00986             log << MSG::DEBUG << "setTauTagged(\"Tau1P3P:3prong\"), pT = " << (*m_it)->pT() << endreq;
00987           }
00988         }       
00989       }else if(abs(etajet)<=2.5){
00990 
00991         if(ptjet/GeV > MaxPTinGeV){
00992         log << MSG::DEBUG<<"Jet with pT="<<ptjet/GeV<<" GeV; Outside range of Tau1P3P - Not Considered for tagging"<<endreq;
00993         }else{
00994 
00995           // Calculate probability of tagging jet as tau1P or tau3P
00996           double tau1Pprob = 0.0;
00997           double tau3Pprob = 0.0;
00998 
00999           if( m_epsitau1P != 0.0 ){
01000             double tau1Prej = -1.0;
01001             // Assign PT dependent rejection for Tau1P PT > 10 GeV
01002             if(ptjet/GeV >= 10. && ptjet/GeV < 20.){ 
01003               tau1Prej = exp(7.585-6.565*m_epsitau1P);}
01004             else if(ptjet/GeV >= 20. && ptjet/GeV < 30.){
01005               tau1Prej = exp(6.863-6.786*m_epsitau1P);}
01006             else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){
01007               tau1Prej = exp(6.995-7.194*m_epsitau1P);}
01008             else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){
01009               tau1Prej = exp(7.199-7.242*m_epsitau1P);}
01010             else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){
01011               tau1Prej = exp(6.857-5.511*m_epsitau1P);}
01012             else if(ptjet/GeV >= 60.){
01013               tau1Prej = exp(7.344-6.331*m_epsitau1P);}
01014 
01015             if( tau1Prej != -1.0 ){ tau1Pprob = 1/tau1Prej; }
01016           }
01017         
01018           if( m_epsitau3P != 0.0 ){
01019             double tau3Prej = -1.0;
01020             // Assign PT dependent rejection for Tau3P PT > 20GeV
01021             if(ptjet/GeV >= 20. && ptjet/GeV < 30.){
01022               tau3Prej = exp(8.351-26.997*m_epsitau3P);}
01023             else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){
01024               tau3Prej = exp(7.076-25.647*m_epsitau3P);}
01025             else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){
01026               tau3Prej = exp(6.394-21.407*m_epsitau3P);}
01027             else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){
01028               tau3Prej = exp(6.318-20.522*m_epsitau3P);}
01029             else if(ptjet/GeV >= 60.){
01030               tau3Prej = exp(6.477-19.238*m_epsitau3P);}
01031 
01032             if( tau3Prej != -1.0 ){ tau3Pprob = 1/tau3Prej; }
01033           } 
01034         
01035           if( randnum<tau1Pprob ){
01036             // Rescale Energy of fake Tau1P
01037             double corr = 0.0;
01038             double rand1P;
01039             // Do not let corr be small enough such that jet falls 
01040             // below 10 GeV jet reconstruction threshold.
01041             while( (corr * (*m_it)->pT())/GeV < 10.){
01042               // Get Random Number
01043               rand1P=m_pRandFlatGenerator->shoot(m_pRandomEngine);
01044               // Get PT bin of jet          
01045               int ptbin = 0;
01046               if(ptjet/GeV >= 10. && ptjet/GeV < 20.){      ptbin = 0; }
01047               else if(ptjet/GeV >= 20. && ptjet/GeV < 30.){ ptbin = 1; }
01048               else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){ ptbin = 2; }
01049               else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){ ptbin = 3; }
01050               else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){ ptbin = 4; }
01051               else if(ptjet/GeV >= 60.){                    ptbin = 5; }
01052               // Get Scale Factor
01053               for(int ibin = 0; ibin<20; ibin++){
01054                 if(m_corr_prob1P[ptbin][ibin] >= rand1P){
01055                   log << MSG::DEBUG << "pT = " << (*m_it)->pT() << " ptbin = " << ptbin << " rand1P = " << rand1P << " corr = " << m_corr1P3P[ibin] << endreq;
01056                   corr = m_corr1P3P[ibin];
01057                   break;
01058                 }
01059               } 
01060             }
01061             // Tag as Tau1P and rescale momentum.
01062             log << MSG::DEBUG<<"Jet tagged as Tau1P. Initial Jet PT = "<<ptjet<<"; After rescaling PT = "<<corr*(*m_it)->pT()/GeV <<endreq;
01063             (*m_it)->setTauTagged("Tau1P3P:1prong");
01064             (*m_it)->setTauTagCorrFactor("Tau1P3P",corr);
01065                   
01066           }else if( randnum>=tau1Pprob && randnum<(tau1Pprob+tau3Pprob) ){
01067           
01068             // Rescale Energy of fake Tau3P
01069             double corr = 0.0;
01070             double rand3P;
01071             // Do not let corr be small enough such that jet falls 
01072             // below 10 GeV jet reconstruction threshold.
01073             while( (corr * (*m_it)->pT())/GeV < 10.){
01074               // Get Random Number
01075               rand3P=m_pRandFlatGenerator->shoot(m_pRandomEngine);
01076               // Get PT bin of jet          
01077               int ptbin = 0;
01078               if(ptjet/GeV >= 10. && ptjet/GeV < 20.){      ptbin = 0; }
01079               else if(ptjet/GeV >= 20. && ptjet/GeV < 30.){ ptbin = 1; }
01080               else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){ ptbin = 2; }
01081               else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){ ptbin = 3; }
01082               else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){ ptbin = 4; }
01083               else if(ptjet/GeV >= 60.){                    ptbin = 5; }
01084               // Get Scale Factor
01085               for(int ibin = 0; ibin<20; ibin++){
01086                 if(m_corr_prob3P[ptbin][ibin] >= rand3P){
01087                   log << MSG::DEBUG << "pT = " << (*m_it)->pT() << " ptbin = " << ptbin << " rand3P = " << rand3P << " corr = " << m_corr1P3P[ibin] << endreq;
01088                   corr = m_corr1P3P[ibin];
01089                   break;
01090                 }
01091               }
01092             }
01093             if( corr * (*m_it)->pT()/GeV >= 20.0 ){
01094               // If rescaled ET >= 20 GeV, tag as Tau3P and rescale momentum.
01095               // If rescaled ET <  20 GeV, do not tag (tau3P low limit is 20GeV)
01096               log << MSG::DEBUG<<"Jet tagged as Tau3P. Initial Jet PT = "<<ptjet<<"; After rescaling PT = "<<corr*(*m_it)->pT()/GeV <<endreq;
01097               (*m_it)->setTauTagged("Tau1P3P:3prong");
01098               (*m_it)->setTauTagCorrFactor("Tau1P3P",corr);
01099             }
01100           }
01101         }
01102       }
01103     }
01104     return StatusCode::SUCCESS;
01105   }
01106 
01107   
01108   StatusCode  AtlfastB::atlfTauVeto(int ind){
01109     
01110     MsgStream log( messageService(), name() ) ; 
01111     
01112     
01113     StatusCode sc;
01114     
01115     for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
01116       
01117       double randnum;    
01118       double efftau;
01119       double effjet;
01120       
01121       double ptjet=(*m_it)->pT();
01122       int pdgid=(*m_it)->pdg_id();
01123 
01124       sc=tauveto(ptjet,ind,efftau,effjet);
01125       if(sc.isFailure()){
01126         log << MSG::ERROR<<"Cannot compute tau jet rejection"<<endreq;
01127         return StatusCode::FAILURE;
01128       }
01129       
01130       randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
01131       
01132 
01133       if(abs(pdgid)==15) {
01134         if(randnum<efftau/100.){
01135           // Need to unset the tau tag here
01136           //(*m_it)->setLightTag();
01137         }
01138       }else{
01139         if(randnum>effjet/100.){
01140           (*m_it)->setTauTagged("Veto");
01141         }
01142       }
01143     }
01144     
01145     return StatusCode::SUCCESS;
01146   }
01147   
01148   
01149   
01150   StatusCode AtlfastB::tauveto(double pt, int ind, double &efftau, double &effjet){ 
01151     MsgStream log( messageService(), name() ) ; 
01152     
01153     
01154 
01155     //input: pt of cluster
01156     //ind=1->fix efftau to 5% and gives effjet
01157     //ind=2->fix effjet to 90% and gives efftau
01158     //output: efftau tau efficiency in % or effjet jets efficiency in %
01159     
01160     
01161     //using calo criteria + tracks
01162     
01163     
01164     double ptInGeV = pt/GeV;
01165 
01166     if(ind==1){
01167      
01168       efftau=5.;
01169       effjet=36.+1.5*ptInGeV-0.01*pow(ptInGeV,2);
01170       if(ptInGeV>60.) effjet=90.;
01171     }
01172     else if(ind==2){
01173       effjet=90.;
01174       efftau=27.-0.35*ptInGeV;
01175       if(ptInGeV>60.) efftau=5.;
01176 
01177     }else{
01178       
01179       log << MSG::ERROR<<"Wrong ind values for tauveto method. ind= "<<ind<<"ind=1 or ind=2"<<endreq;
01180       
01181       return StatusCode::FAILURE;
01182     }
01183     
01184     
01185     
01186     return StatusCode::SUCCESS;
01187   }
01188   
01189   StatusCode AtlfastB::atlfTrigMuo(){
01190     MsgStream log( messageService(), name() ) ; 
01191     
01192     log << MSG::INFO<<"atlfTrigMuo is not yet implemented!!!!!!"<<endreq;
01193     
01194     
01195     return StatusCode::SUCCESS;
01196   }
01197   double AtlfastB::fitcoreb(double pt){
01198     
01199     
01200     MsgStream log( messageService(), name() ) ; 
01201     
01202     double core;
01203     double a0,a1,a2,a3,a4,a5;
01204     double xc;
01205     
01206     
01207     double ptInGeV = pt/GeV;
01208     
01209     if(ptInGeV<10.){
01210       
01211       core=0.;
01212     }else if(ptInGeV<55.){
01213       
01214       a0=1.26694; // Changed from 1.2715 to fix discontinuity
01215       a1=0.12241;
01216       a2=-0.10480e-01;
01217       a3=0.33310e-03;
01218       a4=-0.47454e-05;
01219       a5=0.25436e-07;
01220       core=a0+a1*ptInGeV+a2*pow(ptInGeV,2)+
01221         a3*pow(ptInGeV,3)+a4*pow(ptInGeV,4)+
01222         a5*pow(ptInGeV,5);
01223       core=core*1.006;
01224     }else if(ptInGeV<200.){
01225       
01226       a0=1.18;
01227       a1=-0.16672e-02;
01228       a2=0.44414e-05;
01229       core=a0+a1*ptInGeV+a2*pow(ptInGeV,2);
01230       
01231     }else{
01232       
01233       xc=200.;
01234       a0=1.18;
01235       a1=-0.16672e-02;
01236       a2=0.44414e-05;
01237       core=a0+a1*xc+a2*pow(xc,2);
01238     }
01239     
01240     // core corrects pt**1
01241     
01242     return core;
01243     
01244   }
01245   
01246   double AtlfastB::fitcoreu(double pt){
01247     
01248     MsgStream log( messageService(), name() ) ;     
01249     
01250     double core;
01251     double a0,a1,a2,a3,a4,a5;
01252     double xc;
01253     
01254     double ptInGeV = pt/GeV;
01255     
01256     if(ptInGeV<10.){
01257       
01258       core=0.;
01259       
01260       
01261       
01262       
01263       
01264     }else if((ptInGeV<45.)&&(ptInGeV>10.)){
01265       
01266       a0=1.5065; // Changed from 1.5085 to fix discontinuity
01267       a1=0.31468e-01;
01268       a2=-0.36973e-02;
01269       a3=0.11220e-03;
01270       a4=-0.13921e-05;
01271       a5=0.61538e-08;
01272       core=a0+a1*ptInGeV+a2*pow(ptInGeV,2)+
01273         a3*pow(ptInGeV,3)+a4*pow(ptInGeV,4)+
01274         a5*pow(ptInGeV,5);
01275       
01276     }else if(ptInGeV<200.){
01277       
01278       a0=1.18;
01279       a1=-0.16672e-02;
01280       a2=0.44414e-05;
01281       core=a0+a1*ptInGeV+a2*pow(ptInGeV,2);
01282       core=core/1.025;
01283     }else{
01284       
01285       xc=200.;
01286       a0=1.18;
01287       a1=-0.16672e-02;
01288       a2=0.44414e-05;
01289       core=a0+a1*xc+a2*pow(xc,2);
01290       core=core/1.025;
01291     }
01292     
01293     
01294     // core corrects pt**1
01295     return core;
01296     
01297   }
01298 
01299   void AtlfastB::makeInterpolator(Interpolator* &intptr, string intname, bool contbounds){
01300     MsgStream log( messageService(), name() ) ;
01301     std::string fn = PathResolver::find_file(intname, "DATAPATH");
01302     intptr = new Interpolator(fn);
01303     log << MSG::DEBUG << "Made Interpolator from input file " << fn << endreq;
01304     if (contbounds) intptr->setContinuousBoundaries();
01305     return;
01306   }
01307   
01308   
01309 } //end namespace bracket

Generated on Mon Sep 24 14:19:11 2007 for AtlfastAlgs by  doxygen 1.5.1