Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 // ================================================
002 // AtlfastC class Implementation
003 // ================================================
004 //
005 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
006 //
007 // Namespace ATLF::
008 //
009 
010 #include <fstream>
011 #include <cmath>
012 #include <string>
013 
014 #include "AtlfastAlgs/AtlfastC.h"
015 #include "AtlfastAlgs/GlobalEventData.h"
016 
017 
018 #include "AtlfastEvent/Jet.h"
019 #include "AtlfastEvent/ReconstructedParticle.h"
020 #include "AtlfastEvent/IKinematic.h"
021 #include "AtlfastEvent/CollectionDefs.h"
022 #include "AtlfastEvent/Interpolator.h"
023 
024 #include "AtlfastUtils/TesIO.h"
025 #include "AtlfastUtils/HeaderPrinter.h"
026 
027 // Gaudi includes
028 #include "GaudiKernel/DataSvc.h"
029 #include "GaudiKernel/ISvcLocator.h"
030 #include "GaudiKernel/MsgStream.h"
031 
032 //Other Packages used by this class
033 // Other Packages used by this class:-
034 
035 #include "CLHEP/Random/Ranlux64Engine.h"
036 #include "CLHEP/Random/RandFlat.h"
037 #include "CLHEP/Units/SystemOfUnits.h"
038 
039 #include "PathResolver/PathResolver.h"
040 
041 //sea: header file for our interface class
042 
043 //--------------------------------
044 // Constructors and destructors
045 //--------------------------------
046 
047 namespace Atlfast {
048   
049   using std::abs;
050   AtlfastC::AtlfastC( const std::string& name, ISvcLocator* pSvcLocator ) 
051     : Algorithm( name, pSvcLocator )
052     , m_tesIO( 0 )
053     , m_pRandomEngine( 0 )
054     , m_pRandFlatGenerator( 0 )
055     , m_AtlfastCJets( 0 )
056     , m_electron_interpolator( 0 )
057     , m_photon_interpolator( 0 )
058     , m_muon_interpolator( 0 )
059     , m_jet_interpolator( 0 )
060     , m_elecphot_interpolator( 0 )
061     , m_elecmuon_interpolator( 0 )
062     , m_elecjet_interpolator( 0 )
063     , m_photelec_interpolator( 0 )
064     , m_photmuon_interpolator( 0 )
065     , m_photjet_interpolator( 0 )
066     , m_muonelec_interpolator( 0 )
067     , m_muonphot_interpolator( 0 )
068     , m_muonjet_interpolator( 0 )
069     , m_jetelec_interpolator( 0 )
070     , m_jetphot_interpolator( 0 )
071     , m_jetmuon_interpolator( 0 )
072 {
073      //Default private parameters
074     
075     m_ApplyElecElecEff  =  true;
076     m_ApplyElecPhotEff  =  true;
077     m_ApplyElecMuonEff  =  true;
078     m_ApplyPhotPhotEff  =  true;
079     m_ApplyPhotElecEff  =  true; 
080     m_ApplyPhotMuonEff  =  true; 
081     m_ApplyMuonPhotEff  =  true;
082     m_ApplyMuonElecEff  =  true; 
083     m_ApplyMuonMuonEff  =  true;
084     m_ApplyJetJetEff    =  true;
085     m_ApplyJetPhotEff   =  true;
086     m_ApplyJetElecEff   =  true; 
087     m_ApplyJetMuonEff   =  true;
088     m_ApplyPhotJetEff   =  false;
089     m_ApplyElecJetEff   =  false; 
090     m_ApplyMuonJetEff   =  false;
091  
092 
093 
094  
095     
096     // Default paths for entities in the TES
097     m_inputeLocation         = "/Event/AtlfastIsolatedElectrons";
098     m_inputphotonLocation    = "/Event/AtlfastIsolatedPhotons";
099     m_inputmuonLocation      = "/Event/AtlfastIsolatedMuons" ;
100     m_inputjetLocation       = "/Event/AtlfastJets" ;
101     // input from AtlfastB jets
102     //    m_inputjetLocation       = "/Event/AtlfastCalJets" ;
103 
104     m_outputeLocation        = "/Event/AtlfastCElectrons";
105     m_outputphotonLocation   = "/Event/AtlfastCPhotons";
106     m_outputmuonLocation     = "/Event/AtlfastCMuons" ;
107     m_outputjetLocation      = "/Event/AtlfastCJets" ;
108 
109 
110     m_elecelecEfile          = "atlfastDatafiles/electron_electronEff.dat";
111     m_elecphotEfile          = "atlfastDatafiles/electron_photonEff.dat";
112     m_elecmuonEfile          = "atlfastDatafiles/electron_muid_muonEff.dat";
113     m_elecjetEfile           = "atlfastDatafiles/electron_ktjetEff.dat";
114     //    m_elecmuonEfile          = "atlfastDatafiles/electron_staco_muonEff.dat";
115     m_photelecEfile          = "atlfastDatafiles/photon_electronEff.dat";
116     m_photphotEfile          = "atlfastDatafiles/photon_photonEff.dat";
117     m_photmuonEfile          = "atlfastDatafiles/photon_muid_muonEff.dat";
118     m_photjetEfile           = "atlfastDatafiles/photon_ktjetEff.dat";
119     //    m_photmuonEfile          = "atlfastDatafiles/photon_staco_muonEff.dat";
120     m_muonelecEfile          = "atlfastDatafiles/muon_electronEff.dat";
121     m_muonphotEfile          = "atlfastDatafiles/muon_photonEff.dat";
122     m_muonmuonEfile          = "atlfastDatafiles/muon_muid_muonEff.dat";
123     m_muonjetEfile           = "atlfastDatafiles/muon_ktjetEff.dat";
124     //    m_muonmuonEfile          = "atlfastDatafiles/muon_staco_muonEff.dat";
125     m_jetelecEfile           = "atlfastDatafiles/ktjet_electronEff.dat";
126     m_jetphotEfile           = "atlfastDatafiles/ktjet_photonEff.dat";
127     m_jetmuonEfile           = "atlfastDatafiles/ktjet_muid_muonEff.dat";
128     m_jetjetEfile            = "atlfastDatafiles/ktjet_ktjetEff.dat";
129     //    m_jetmuonEfile          = "atlfastDatafiles/jet_staco_muonEff.dat";
130 
131 
132     // This is how you declare the paramemters to Gaudi so that
133     // they can be over-written via the job options file
134         
135     declareProperty( "InputeLocation",           m_inputeLocation ) ;
136     declareProperty( "InputphotonLocation",      m_inputphotonLocation ) ;
137     declareProperty( "InputmuonLocation",        m_inputmuonLocation ) ;
138     declareProperty( "InputjetLocation",         m_inputjetLocation ) ;
139 
140     declareProperty( "OutputeLocation",          m_outputeLocation ) ;
141     declareProperty( "OutputphotonLocation",     m_outputphotonLocation ) ;
142     declareProperty( "OutputmuonLocation",       m_outputmuonLocation ) ;
143     declareProperty( "OutputjetLocation",        m_outputjetLocation ) ;
144     
145     declareProperty( "ApplyElecElecEff",         m_ApplyElecElecEff);
146     declareProperty( "ApplyElecPhotEff",         m_ApplyElecPhotEff);
147     declareProperty( "ApplyElecMuonEff",         m_ApplyElecMuonEff);
148     declareProperty( "ApplyPhotPhotEff",         m_ApplyPhotPhotEff);
149     declareProperty( "ApplyPhotElecEff",         m_ApplyPhotElecEff);
150     declareProperty( "ApplyPhotMuonEff",         m_ApplyPhotMuonEff);
151     declareProperty( "ApplyMuonElecEff",         m_ApplyMuonElecEff);
152     declareProperty( "ApplyMuonPhotEff",         m_ApplyMuonPhotEff);
153     declareProperty( "ApplyMuonMuonEff",         m_ApplyMuonMuonEff);
154     declareProperty( "ApplyJetElecEff",          m_ApplyJetElecEff);
155     declareProperty( "ApplyJetPhotEff",          m_ApplyJetPhotEff);
156     declareProperty( "ApplyJetMuonEff",          m_ApplyJetMuonEff);
157     declareProperty( "ApplyJetJetEff",           m_ApplyJetJetEff);
158     declareProperty( "ApplyElecJetEff",          m_ApplyElecJetEff);
159     declareProperty( "ApplyPhotJetEff",          m_ApplyPhotJetEff);
160     declareProperty( "ApplyMuonJetEff",          m_ApplyMuonJetEff);
161 
162 
163 
164     declareProperty( "ElecElecFile", m_elecelecEfile);
165     declareProperty( "ElecPhotFile", m_elecphotEfile);
166     declareProperty( "ElecMuonFile", m_elecmuonEfile);
167     declareProperty( "PhotElecFile", m_photelecEfile);
168     declareProperty( "PhotPhotFile", m_photphotEfile);
169     declareProperty( "PhotMuonFile", m_photmuonEfile);
170     declareProperty( "MuonElecFile", m_muonelecEfile);
171     declareProperty( "MuonPhotFile", m_muonphotEfile);
172     declareProperty( "MuonMuonFile", m_muonmuonEfile);
173     declareProperty( "JetElecFile", m_jetelecEfile);
174     declareProperty( "JetPhotFile", m_jetphotEfile);
175     declareProperty( "JetMuonFile", m_jetmuonEfile);
176     declareProperty( "JetJetFile",  m_jetjetEfile);
177     declareProperty( "ElecJetFile", m_elecjetEfile);
178     declareProperty( "PhotJetFile", m_photjetEfile);
179     declareProperty( "MuonJetFile", m_muonjetEfile);
180 
181   }
182   
183   AtlfastC::~AtlfastC() {
184     
185     MsgStream log( messageService(), name() ) ;
186     log << MSG::DEBUG << "Destructor" << endreq;
187     if( m_tesIO) {
188       delete m_tesIO;
189     }
190     if( m_pRandomEngine) {
191       delete m_pRandomEngine;
192     }
193     if( m_pRandFlatGenerator) {
194       delete m_pRandFlatGenerator;
195     }
196 
197     //    delete dummy_cluster ;
198 
199   }
200   
201   
202   
203   //---------------------------------
204   // initialise() 
205   //---------------------------------
206   
207   StatusCode AtlfastC::initialize(){
208     MsgStream log( messageService(), name() ) ;
209     log << MSG::DEBUG << "instantiating an AtlfastC" << endreq;
210     
211 
212      m_elecelecEfile = PathResolver::find_file (m_elecelecEfile, "DATAPATH"); 
213      m_elecphotEfile = PathResolver::find_file (m_elecphotEfile, "DATAPATH");  
214      m_elecmuonEfile = PathResolver::find_file (m_elecmuonEfile, "DATAPATH");  
215      m_photelecEfile = PathResolver::find_file (m_photelecEfile, "DATAPATH"); 
216      m_photphotEfile = PathResolver::find_file (m_photphotEfile, "DATAPATH"); 
217      m_photmuonEfile = PathResolver::find_file (m_photmuonEfile, "DATAPATH");  
218      m_muonelecEfile = PathResolver::find_file (m_muonelecEfile, "DATAPATH"); 
219      m_muonphotEfile = PathResolver::find_file (m_muonphotEfile, "DATAPATH");  
220      m_muonmuonEfile = PathResolver::find_file (m_muonmuonEfile, "DATAPATH");  
221      m_jetelecEfile  = PathResolver::find_file (m_jetelecEfile, "DATAPATH"); 
222      m_jetphotEfile  = PathResolver::find_file (m_jetphotEfile, "DATAPATH");  
223      m_jetmuonEfile  = PathResolver::find_file (m_jetmuonEfile, "DATAPATH");  
224      m_jetjetEfile   = PathResolver::find_file (m_jetjetEfile, "DATAPATH");  
225      m_elecjetEfile  = PathResolver::find_file (m_elecjetEfile, "DATAPATH"); 
226      m_photjetEfile  = PathResolver::find_file (m_photjetEfile, "DATAPATH");  
227      m_muonjetEfile  = PathResolver::find_file (m_muonjetEfile, "DATAPATH");  
228         
229      log << MSG::DEBUG << " m_elecelecEfile after PathResolver" << m_elecelecEfile << endreq;
230      log << MSG::DEBUG << " m_elecphotEfile after PathResolver" << m_elecphotEfile << endreq;
231      log << MSG::DEBUG << " m_photmuonEfile after PathResolver" << m_photmuonEfile << endreq;
232      log << MSG::DEBUG << " m_photphotEfile after PathResolver" << m_photphotEfile << endreq;
233      log << MSG::DEBUG << " m_muonelecEfile after PathResolver" << m_muonelecEfile << endreq;
234      log << MSG::DEBUG << " m_muonphotEfile after PathResolver" << m_muonphotEfile << endreq;
235      log << MSG::DEBUG << " m_muonmuonEfile after PathResolver" << m_muonmuonEfile << endreq;
236      log << MSG::DEBUG << " m_jetelecEfile after PathResolver" << m_jetelecEfile << endreq;
237      log << MSG::DEBUG << " m_jetphotEfile after PathResolver" << m_jetphotEfile << endreq;
238      log << MSG::DEBUG << " m_jetmuonEfile after PathResolver" << m_jetmuonEfile << endreq;
239      log << MSG::DEBUG << " m_jetjetEfile after PathResolver" << m_jetjetEfile << endreq;
240      log << MSG::DEBUG << " m_elecjetEfile after PathResolver" << m_elecjetEfile << endreq;
241      log << MSG::DEBUG << " m_photjetEfile after PathResolver" << m_photjetEfile << endreq;
242      log << MSG::DEBUG << " m_photphotEfile after PathResolver" << m_photphotEfile << endreq;
243      log << MSG::DEBUG << " m_muonjetEfile after PathResolver" << m_muonjetEfile << endreq;
244 
245      if(m_elecelecEfile == ""){
246        log << MSG::ERROR << "electronelectron dat file not found" <<endreq;
247        return StatusCode::FAILURE;
248      }
249      if(m_elecphotEfile == ""){
250        log << MSG::ERROR << "electronphoton dat file not found" <<endreq;
251        return StatusCode::FAILURE;
252      }
253      if(m_elecmuonEfile == ""){
254        log << MSG::ERROR << "electronmuon dat file not found" <<endreq;
255        return StatusCode::FAILURE;
256      }
257      if(m_elecjetEfile == ""){
258        log << MSG::ERROR << "electronjet dat file not found" <<endreq;
259        return StatusCode::FAILURE;
260      }
261      if(m_photelecEfile == ""){
262        log << MSG::ERROR << "photonelectron dat file not found" <<endreq;
263        return StatusCode::FAILURE;
264      }
265      if(m_photphotEfile == ""){
266        log << MSG::ERROR << "photonphoton dat file not found" <<endreq;
267        return StatusCode::FAILURE;
268      }
269      if(m_photmuonEfile == ""){
270        log << MSG::ERROR << "photonmuon dat file not found" <<endreq;
271        return StatusCode::FAILURE;
272      }
273      if(m_photjetEfile == ""){
274        log << MSG::ERROR << "photonjet dat file not found" <<endreq;
275        return StatusCode::FAILURE;
276      }
277      if(m_muonelecEfile == ""){
278        log << MSG::ERROR << "muonelectron dat file not found" <<endreq;
279        return StatusCode::FAILURE;
280      }
281      if(m_muonphotEfile == ""){
282        log << MSG::ERROR << "muonphoton dat file not found" <<endreq;
283        return StatusCode::FAILURE;
284      }
285      if(m_muonmuonEfile == ""){
286        log << MSG::ERROR << "muonmuon dat file not found" <<endreq;
287        return StatusCode::FAILURE;
288      }
289      if(m_muonjetEfile == ""){
290        log << MSG::ERROR << "muonjet dat file not found" <<endreq;
291        return StatusCode::FAILURE;
292      }
293      if(m_jetelecEfile == ""){
294        log << MSG::ERROR << "jetelectron dat file not found" <<endreq;
295        return StatusCode::FAILURE;
296      }
297      if(m_jetphotEfile == ""){
298        log << MSG::ERROR << "jetphoton dat file not found" <<endreq;
299        return StatusCode::FAILURE;
300      }
301      if(m_jetmuonEfile == ""){
302        log << MSG::ERROR << "jetmuon dat file not found" <<endreq;
303        return StatusCode::FAILURE;
304      }
305      if(m_jetjetEfile == ""){
306        log << MSG::ERROR << "jetjet dat file not found" <<endreq;
307        return StatusCode::FAILURE;
308      }
309      log << MSG::DEBUG << " starting interpolators..." << endreq;
310 
311      m_electron_interpolator = new Interpolator(m_elecelecEfile);
312      m_photon_interpolator =   new Interpolator(m_photphotEfile);
313      m_muon_interpolator =     new Interpolator(m_muonmuonEfile);
314      m_jet_interpolator =      new Interpolator(m_jetjetEfile);
315      m_elecphot_interpolator = new Interpolator(m_elecphotEfile);
316      m_elecmuon_interpolator = new Interpolator(m_elecmuonEfile);
317      m_elecjet_interpolator  = new Interpolator(m_elecjetEfile);
318      m_photelec_interpolator = new Interpolator(m_photelecEfile);
319      m_photmuon_interpolator = new Interpolator(m_photmuonEfile);
320      m_photjet_interpolator = new Interpolator(m_photjetEfile);
321      m_muonelec_interpolator = new Interpolator(m_muonelecEfile);
322      m_muonphot_interpolator = new Interpolator(m_muonphotEfile);
323      m_muonjet_interpolator = new Interpolator(m_muonjetEfile);
324      m_jetelec_interpolator = new Interpolator(m_jetelecEfile);
325      m_jetphot_interpolator = new Interpolator(m_jetphotEfile);
326      m_jetmuon_interpolator = new Interpolator(m_jetmuonEfile);
327 
328     //Flat random number generator
329     //get the Global Event Data using singleton pattern
330 
331     GlobalEventData* ged = GlobalEventData::Instance();
332     int randSeed = ged->randSeed() ;
333     // load the location of the MC in StoreGate
334     m_mcLocation       = ged -> mcLocation();
335 
336     m_tesIO= new TesIO(m_mcLocation, ged->justHardScatter());
337 
338     m_pRandomEngine = new Ranlux64Engine(randSeed);
339     m_pRandFlatGenerator=new RandFlat(*m_pRandomEngine);
340     
341     
342     HeaderPrinter hp("AtlfastC:", log);
343     
344     hp.add("TES Locations:              "); 
345     hp.add( "Electrons from                      ",m_inputeLocation ) ;
346     hp.add( "Photons from                        ",m_inputphotonLocation ) ;
347     hp.add( "Muons from                          ",m_inputmuonLocation ) ;
348     hp.add( "Jets from                           ",m_inputjetLocation ) ;
349 
350     hp.add( "Electrons after efficiency & mis-id ",m_outputeLocation ) ;
351     hp.add( "Photons after efficiency & mis-id   ",m_outputphotonLocation ) ;
352     hp.add( "Muons after efficiency & mis-id     ",m_outputmuonLocation ) ;
353     hp.add( "Jets after efficiency & mis-id      ",m_outputjetLocation ) ;
354     
355     hp.add( "Apply ElecElec Efficiency            ",         m_ApplyElecElecEff);
356     hp.add( "Apply ElecPhot Mis id                ",         m_ApplyElecPhotEff);
357     hp.add( "Apply ElecMuon Mis id                ",         m_ApplyElecMuonEff);
358     hp.add( "Apply PhotPhot Efficiency            ",         m_ApplyPhotPhotEff);
359     hp.add( "Apply PhotElec Mis id                ",         m_ApplyPhotElecEff);
360     hp.add( "Apply PhotMuon Mis id                ",         m_ApplyPhotMuonEff);
361     hp.add( "Apply MuonPhot Efficiency            ",         m_ApplyMuonPhotEff);
362     hp.add( "Apply MuonElec Mis id                ",         m_ApplyMuonElecEff);
363     hp.add( "Apply MuonMuon Mis id                ",         m_ApplyMuonMuonEff);
364     hp.add( "Apply JetJet Efficiency             ",         m_ApplyJetJetEff);
365     hp.add( "Apply JetPhot Mis id                ",         m_ApplyJetPhotEff);
366     hp.add( "Apply JetElec Mis id                ",         m_ApplyJetElecEff);
367     hp.add( "Apply JetMuon Mis id                ",         m_ApplyJetMuonEff);
368     hp.add( "Apply PhotJet Mis id                ",         m_ApplyPhotJetEff);
369     hp.add( "Apply ElecJet Mis id                ",         m_ApplyElecJetEff);
370     hp.add( "Apply MuonJet Mis id                ",         m_ApplyMuonJetEff);
371 
372     hp.print();
373     
374     return StatusCode::SUCCESS ;
375   }  
376 
377   
378   //---------------------------------
379   // finalise() 
380   //---------------------------------
381   
382   StatusCode AtlfastC::finalize(){
383     
384     MsgStream log( messageService(), name() ) ;
385     log << MSG::INFO << "finalizing" << endreq;    
386     return StatusCode::SUCCESS ;
387   }
388   
389   
390   //----------------------------------------------
391   // execute() method called once per event
392   //----------------------------------------------
393   
394   StatusCode AtlfastC::execute(){
395     
396 
397     StatusCode sc;
398     MsgStream log( messageService(), name() ) ;  
399     
400     log << MSG::DEBUG<<"In execute"<<endreq;
401     originalElectrons.clear();
402     originalPhotons.clear();
403     originalJets.clear();
404     originalMuons.clear();
405 
406     if( ! m_tesIO->copy<ReconstructedParticleCollection>( originalElectrons, m_inputeLocation ) ) {
407       log << MSG::INFO << "No Electrons in TES " << endreq;
408     }  
409     
410     if( ! m_tesIO->copy<ReconstructedParticleCollection>( originalPhotons, m_inputphotonLocation ) ) {
411       log << MSG::INFO << "No Photons in TES " << endreq;
412       
413     } 
414     
415     if( ! m_tesIO->copy<JetCollection>( originalJets, m_inputjetLocation ) ) {
416       log << MSG::INFO << "No Jets in TES " << endreq;
417     }  
418     
419     if( ! m_tesIO->copy<ReconstructedParticleCollection>( originalMuons, m_inputmuonLocation ) ) {
420       log << MSG::INFO << "No Muons in TES " << endreq;
421       
422     }  
423      
424      m_AtlfastCElectrons = new ReconstructedParticleCollection;
425      m_AtlfastCPhotons   = new ReconstructedParticleCollection;
426      m_AtlfastCMuons     = new ReconstructedParticleCollection;
427      m_AtlfastCJets      = new JetCollection;
428      
429 
430      if(m_ApplyElecElecEff && originalElectrons.size()!=0 ){
431        sc=ApplyEfficiency(originalElectrons,m_AtlfastCElectrons,m_electron_interpolator,11) ;
432        if(!sc){
433          log << MSG::ERROR<<"Error in Electron Electron Element"<<endreq;
434          return StatusCode::FAILURE;
435        }
436      }
437      
438      if(m_ApplyElecPhotEff && originalElectrons.size()!=0 ){
439        sc=ApplyEfficiency(originalElectrons,m_AtlfastCPhotons,m_elecphot_interpolator,22) ;
440        if(!sc){ 
441          log << MSG::ERROR<<"Error in Electron Photon Element"<<endreq;
442          return StatusCode::FAILURE;
443        }
444      }
445      
446      if(m_ApplyElecMuonEff && originalElectrons.size()!=0 ){
447        sc=ApplyEfficiency(originalElectrons,m_AtlfastCMuons,m_elecmuon_interpolator,13) ;
448        if(!sc){ 
449          log << MSG::ERROR<<"Error in Electron Muon Element"<<endreq;
450          return StatusCode::FAILURE;
451        }
452      }
453 
454      if(m_ApplyElecJetEff && originalElectrons.size()!=0 ){
455        sc=ApplyEfficiency(originalElectrons,m_AtlfastCJets,m_elecjet_interpolator) ;
456        if(!sc){ 
457          log << MSG::ERROR<<"Error in Electron Jet Element"<<endreq;
458          return StatusCode::FAILURE;
459        }
460      }
461           
462      if(m_ApplyPhotElecEff && originalPhotons.size()!=0 ){
463        sc=ApplyEfficiency(originalPhotons,m_AtlfastCElectrons,m_photelec_interpolator,11) ;
464        if(!sc){ 
465          log << MSG::ERROR<<"Error in Photon Electron Element"<<endreq;
466          return StatusCode::FAILURE;
467        }
468      }
469 
470      if(m_ApplyPhotPhotEff && originalPhotons.size()!=0 ){
471        sc=ApplyEfficiency(originalPhotons,m_AtlfastCPhotons,m_photon_interpolator,22) ;
472        if(!sc){
473          log << MSG::ERROR<<"Error in Photon Photon Element"<<endreq;
474          return StatusCode::FAILURE;
475        }
476      }
477 
478      if(m_ApplyPhotMuonEff && originalPhotons.size()!=0 ){
479        sc=ApplyEfficiency(originalPhotons,m_AtlfastCMuons,m_photmuon_interpolator,13) ;
480        if(!sc){ 
481          log << MSG::ERROR<<"Error in Photon Muon Element"<<endreq;
482          return StatusCode::FAILURE;
483        }
484      }
485 
486      if(m_ApplyPhotJetEff && originalPhotons.size()!=0 ){
487        sc=ApplyEfficiency(originalPhotons,m_AtlfastCJets,m_photjet_interpolator) ;
488        if(!sc){ 
489          log << MSG::ERROR<<"Error in Photon Jet Element"<<endreq;
490          return StatusCode::FAILURE;
491        }
492      }
493 
494      if(m_ApplyMuonElecEff && originalMuons.size()!=0 ){
495        sc=ApplyEfficiency(originalMuons,m_AtlfastCElectrons,m_muonelec_interpolator,11) ;
496        if(!sc){ 
497          log << MSG::ERROR<<"Error in Muon Electron Element"<<endreq;
498          return StatusCode::FAILURE;
499        }
500      }
501 
502      if(m_ApplyMuonPhotEff && originalMuons.size()!=0 ){
503        sc=ApplyEfficiency(originalMuons,m_AtlfastCPhotons,m_muonphot_interpolator,22) ;
504        if(!sc){
505          log << MSG::ERROR<<"Error in Muon Photon Element"<<endreq;
506          return StatusCode::FAILURE;
507        }
508      }
509 
510      if(m_ApplyMuonMuonEff && originalMuons.size()!=0 ){
511        sc=ApplyEfficiency(originalMuons,m_AtlfastCMuons,m_muon_interpolator,13) ;
512        if(!sc){ 
513          log << MSG::ERROR<<"Error in Muon Muon Element"<<endreq;
514          return StatusCode::FAILURE;
515        }
516      }
517 
518      if(m_ApplyMuonJetEff && originalMuons.size()!=0 ){
519        sc=ApplyEfficiency(originalMuons,m_AtlfastCJets,m_muonjet_interpolator) ;
520        if(!sc){ 
521          log << MSG::ERROR<<"Error in Muon Jet Element"<<endreq;
522          return StatusCode::FAILURE;
523        }
524      }
525 
526      if(m_ApplyJetElecEff && originalJets.size()!=0 ){
527        sc=ApplyEfficiency(originalJets,m_AtlfastCElectrons,m_jetelec_interpolator,11) ;
528        if(!sc){
529          log << MSG::ERROR<<"Error in Jet Electron Element"<<endreq;
530          return StatusCode::FAILURE;
531        }
532      }
533      
534      if(m_ApplyJetPhotEff && originalJets.size()!=0 ){
535        sc=ApplyEfficiency(originalJets,m_AtlfastCPhotons,m_jetphot_interpolator,22) ;
536        if(!sc){ 
537          log << MSG::ERROR<<"Error in Jet Photon Element"<<endreq;
538          return StatusCode::FAILURE;
539        }
540      }
541      
542      if(m_ApplyJetMuonEff && originalJets.size()!=0 ){
543        sc=ApplyEfficiency(originalJets,m_AtlfastCMuons,m_elecmuon_interpolator,13) ;
544        if(!sc){ 
545          log << MSG::ERROR<<"Error in Jet Muon Element"<<endreq;
546          return StatusCode::FAILURE;
547        }
548      }
549      
550      if(m_ApplyJetJetEff && originalJets.size()!=0 ){
551        sc=ApplyEfficiency(originalJets,m_AtlfastCJets,m_jet_interpolator) ;
552        if(!sc){ 
553          log << MSG::ERROR<<"Error in Jet Jet Element"<<endreq;
554          return StatusCode::FAILURE;
555        }
556      }
557      
558 
559      
560      TesIoStat stat;
561      stat = m_tesIO->store( m_AtlfastCElectrons, m_outputeLocation);
562      if(!stat){
563        log << MSG::ERROR << "Could not store AtlfastC electrons"<< endreq;
564        return stat;
565      }
566      
567      stat = m_tesIO->store( m_AtlfastCPhotons, m_outputphotonLocation);
568      if(!stat){
569        log << MSG::ERROR << "Could not store AtlfastC photons"<< endreq;
570        return stat;
571      }
572      stat = m_tesIO->store( m_AtlfastCMuons, m_outputmuonLocation);
573      if(!stat){
574        log << MSG::ERROR << "Could not store AtlfastC muons"<< endreq;
575        return stat;
576      }
577      stat = m_tesIO->store( m_AtlfastCJets, m_outputjetLocation);
578      if(!stat){
579        log << MSG::ERROR << "Could not store AtlfastC jets"<< endreq;
580        return stat;
581      }
582      
583      
584      
585      return StatusCode::SUCCESS; 
586   }
587   
588   //-------------------------------
589   // helper methods implementation
590   //-------------------------------
591   StatusCode AtlfastC::ApplyEfficiency(std::vector<ReconstructedParticle*> OriginalList, ReconstructedParticleCollection* NewList, Interpolator* InterpolatorName ,int pdgidnew){
592    
593     MsgStream log( messageService(), name() ) ;     
594     //Apply randomized particle to particle efficiency
595     log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
596     
597     for(m_it=OriginalList.begin(); m_it<OriginalList.end();++m_it){
598       
599       log<<MSG::DEBUG<<"In the particle particle loop...."<<endreq;
600       
601       double recopt=(*m_it)->pT();
602       double recoeta=(*m_it)->eta();
603       //      int pdgid=(*m_it)->pdg_id();
604       
605       double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
606       
607       // pass the pt, eta, pdg_id to something else...      
608       double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
609       
610       if(randnum < epsilon_ij){
611         log<<MSG::DEBUG<<"in-out: " << **m_it << endreq;
612         // to make a reconstructed particle and give it a different pdg_id:
613         ReconstructedParticle* candidate = new ReconstructedParticle ( pdgidnew /*m_particleType*/, (*m_it)->momentum(), (*m_it)->truth() );            
614         NewList->push_back(candidate);
615         log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
616       }
617     }
618     return StatusCode::SUCCESS;
619 
620   }
621 
622   StatusCode AtlfastC::ApplyEfficiency(std::vector<Jet*> OriginalList, ReconstructedParticleCollection* NewList, Interpolator* InterpolatorName ,int pdgidnew){
623    
624     MsgStream log( messageService(), name() ) ;     
625     //Apply randomized jet to particle
626     log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
627     
628     for(j_it=OriginalList.begin(); j_it<OriginalList.end();++j_it){
629       
630       log<<MSG::DEBUG<<"In the jet particle loop...."<<endreq;
631       
632       double recopt=(*j_it)->pT();
633       double recoeta=(*j_it)->eta();
634       //      int pdgid=(*m_it)->pdg_id();
635       
636       double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
637       
638       // pass the pt, eta, pdg_id to something else...      
639       double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
640       
641       if(randnum < epsilon_ij){
642         log<<MSG::DEBUG<<"in-out: " << **j_it << endreq;
643         // to make a reconstructed particle and give it a different pdg_id:
644         HepMC::GenParticle* dummy_truth(0) ;
645         ReconstructedParticle* candidate = new ReconstructedParticle ( pdgidnew /*m_particleType*/, (*j_it)->momentum() , dummy_truth);         
646         NewList->push_back(candidate);
647         log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
648       }
649     }
650     return StatusCode::SUCCESS;
651 
652   }
653   // not sure for the next two methods concerning new Jet using newpdgid
654   StatusCode AtlfastC::ApplyEfficiency(std::vector<ReconstructedParticle*> OriginalList, JetCollection* NewList, Interpolator* InterpolatorName ){
655    
656     MsgStream log( messageService(), name() ) ;     
657     //Apply randomized particle to jet efficiency
658     log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
659     
660     for(m_it=OriginalList.begin(); m_it<OriginalList.end();++m_it){
661       
662       log<<MSG::DEBUG<<"In the particle jet loop...."<<endreq;
663       
664       double recopt=(*m_it)->pT();
665       double recoeta=(*m_it)->eta();
666       //      int pdgid=(*m_it)->pdg_id();
667       
668       double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
669       
670       // pass the pt, eta, pdg_id to something else...      
671       double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
672 
673       if(randnum < epsilon_ij){
674         log<<MSG::DEBUG<<"in-out: " << **m_it << endreq;
675         
676         Jet* candidate = this->createJet(*m_it);
677         if(candidate!=0){
678           NewList->push_back(candidate);
679         }else{
680           log<<MSG::ERROR << "particle->jet: No clusters found from which to make jet"<<endreq;
681         }
682         log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
683       }
684     }
685     return StatusCode::SUCCESS;
686 
687   }
688 
689   StatusCode AtlfastC::ApplyEfficiency(std::vector<Jet*> OriginalList, JetCollection* NewList, Interpolator* InterpolatorName){
690    
691     MsgStream log( messageService(), name() ) ;     
692     //Apply randomized jet to jet efficiency
693     log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
694     
695     for(j_it=OriginalList.begin(); j_it<OriginalList.end();++j_it){
696       
697       log<<MSG::DEBUG<<"In the jet jet loop...."<<endreq;
698       
699       double recopt=(*j_it)->pT();
700       double recoeta=(*j_it)->eta();
701       //      int pdgid=(*m_it)->pdg_id();
702       
703       double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
704       
705       // pass the pt, eta, pdg_id to something else...      
706       double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
707       
708       if(randnum < epsilon_ij){
709         log<<MSG::DEBUG<<"in-out: " << **j_it << endreq;
710         // to make a reconstructed particle and give it a different pdg_id:
711 
712 
713         Jet* candidate = new Jet ( **j_it );            
714         NewList->push_back(candidate);
715         log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
716       }
717     }
718     return StatusCode::SUCCESS;
719 
720   }
721 
722   double AtlfastC::getEfficiencyMatrixElement(double pt, double eta, Interpolator* InterpolatorName){
723     MsgStream log( messageService(), name() ) ;
724  
725     double Efficiency = 0;
726 
727     deque<double> input_values;
728     input_values.push_back(pt/GeV);
729     input_values.push_back(fabs(eta));
730     
731     
732     Efficiency = InterpolatorName->interpolate(input_values);
733 
734     //    log<<MSG::ERROR << "pt" << pt/GeV <<  "eta" << eta << "eff is " << Efficiency <<endreq;
735 
736     return Efficiency;
737   }
738 
739   //sea:try putting converter create jet here:
740 
741  Jet* AtlfastC::createJet(const ReconstructedParticle* rp){
742     
743     Jet* jet = 0;
744     MsgStream log( messageService(), name() );
745     HepLorentzVector vec = rp->momentum();
746 
747     //No smearing applied - jets keep their particle smearing.
748     
749     // Get associations of ReconstructedParticle 
750     const IAOO* iaooRP = rp;
751     TypeVisitor tv =
752       ContainerDispatcher( iaooRP->begin(), iaooRP->end(), TypeVisitor() );
753     
754     // Select the vector of Clusters (should just be one)
755     std::vector<const Cluster*> cv = tv.typeVector(Cluster());
756     log << MSG::INFO << "TypeVisitor found " << cv.size() 
757         << " Clusters in this ReconstructedParticle" << endreq;
758     
759     if ( cv.size() == 1 ){
760       Cluster* ic = const_cast<Cluster*>(cv[0]);
761       jet = new Jet(vec, *ic);
762       log << MSG::INFO << "Unsmeared Cluster: " << *ic << endreq;
763       log << MSG::INFO << "Smeared Jet      : " << jet << endreq ;
764     }
765 
766     return jet;
767     
768   }  
769 
770 
771 
772 }
773  //end namespace bracket
774 

source navigation ] diff markup ] identifier search ] general search ]

Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems
This page was automatically generated by the LXR engine. Valid HTML 4.01!