CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/FastSimulation/L1CaloTriggerProducer/src/FastL1CaloSim.cc

Go to the documentation of this file.
00001 
00002 // -*- C++ -*-
00003 //
00004 // Package:    L1CaloTriggerProducer
00005 // Class:      FastL1CaloSim
00006 // 
00014 //
00015 // Original Author:  Chi Nhan Nguyen
00016 //         Created:  Mon Feb 19 13:25:24 CST 2007
00017 // $Id: FastL1CaloSim.cc,v 1.13 2009/03/28 14:40:52 chinhan Exp $
00018 //
00019 //
00020 
00021 #include "FastSimulation/L1CaloTriggerProducer/interface/FastL1CaloSim.h"
00022 
00023 
00024 //
00025 // constructors and destructor
00026 //
00027 FastL1CaloSim::FastL1CaloSim(const edm::ParameterSet& iConfig)
00028 {
00029   //register your products
00030   /* old labels
00031   produces<l1extra::L1EtMissParticle>("MET");
00032   produces<l1extra::L1JetParticleCollection>("TauJets");
00033   produces<l1extra::L1JetParticleCollection>("CenJets");
00034   produces<l1extra::L1JetParticleCollection>("ForJets");
00035   produces<l1extra::L1EmParticleCollection>("Egammas");
00036   produces<l1extra::L1EmParticleCollection>("isoEgammas");
00037   */
00038 
00039   //produces<l1extra::L1EtMissParticle>();
00040   produces<l1extra::L1EtMissParticleCollection>("MET");
00041   produces<l1extra::L1JetParticleCollection>("Tau");
00042   produces<l1extra::L1JetParticleCollection>("Central");
00043   produces<l1extra::L1JetParticleCollection>("Forward");
00044   produces<l1extra::L1EmParticleCollection>("NonIsolated");
00045   produces<l1extra::L1EmParticleCollection>("Isolated");
00046   produces<l1extra::L1MuonParticleCollection>(); // muon is dummy for L1extraParticleMap!
00047 
00048   m_AlgorithmSource = iConfig.getParameter<std::string>("AlgorithmSource");
00049 
00050   // No BitInfos for release versions
00051   m_DoBitInfo = iConfig.getParameter<bool>("DoBitInfo");
00052   if (m_DoBitInfo)
00053     produces<FastL1BitInfoCollection>("L1BitInfos");
00054 
00055   m_FastL1GlobalAlgo = new FastL1GlobalAlgo(iConfig);
00056 }
00057 
00058 FastL1CaloSim::~FastL1CaloSim()
00059 {
00060   delete m_FastL1GlobalAlgo;
00061 }
00062 
00063 
00064 //
00065 // member functions
00066 //
00067 
00068 // ------------ method called to produce the data  ------------
00069 void
00070 FastL1CaloSim::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00071 {
00072   //edm::LogInfo("FastL1CaloSim::produce()");
00073 
00074   if (m_AlgorithmSource == "RecHits") {
00075     m_FastL1GlobalAlgo->FillL1Regions(iEvent, iSetup);
00076     m_FastL1GlobalAlgo->FillEgammas(iEvent);
00077   } else if (m_AlgorithmSource == "TrigPrims") {
00078     m_FastL1GlobalAlgo->FillL1RegionsTP(iEvent,iSetup);
00079     m_FastL1GlobalAlgo->FillEgammasTP(iEvent);
00080   } else {
00081     std::cerr<<"AlgorithmSource not valid: "<<m_AlgorithmSource<<std::endl;
00082     return;
00083   }
00084   m_FastL1GlobalAlgo->FillMET(iEvent); // using CaloTowers
00085   //m_FastL1GlobalAlgo->FillMET();     // using Regions
00086   m_FastL1GlobalAlgo->FillJets(iSetup);
00087   
00088   if (m_DoBitInfo)
00089     m_FastL1GlobalAlgo->FillBitInfos();
00090 
00091   //std::auto_ptr<l1extra::L1EtMissParticle> METResult(new l1extra::L1EtMissParticle);
00092   std::auto_ptr<l1extra::L1EtMissParticleCollection> METResult(new l1extra::L1EtMissParticleCollection);
00093   std::auto_ptr<l1extra::L1JetParticleCollection> TauJetResult(new l1extra::L1JetParticleCollection);
00094   std::auto_ptr<l1extra::L1JetParticleCollection> CenJetResult(new l1extra::L1JetParticleCollection);
00095   std::auto_ptr<l1extra::L1JetParticleCollection> ForJetResult(new l1extra::L1JetParticleCollection);
00096   std::auto_ptr<l1extra::L1EmParticleCollection> EgammaResult(new l1extra::L1EmParticleCollection);
00097   std::auto_ptr<l1extra::L1EmParticleCollection> isoEgammaResult(new l1extra::L1EmParticleCollection);
00098   // muon is dummy!
00099   std::auto_ptr<l1extra::L1MuonParticleCollection> muonDummy(new l1extra::L1MuonParticleCollection);
00100   //
00101   //*METResult = m_FastL1GlobalAlgo->getMET();
00102   for (int i=0; i<(int)m_FastL1GlobalAlgo->getMET().size(); i++) {
00103     METResult->push_back(m_FastL1GlobalAlgo->getMET().at(i));
00104   }
00105   for (int i=0; i<std::min(4,(int)m_FastL1GlobalAlgo->getTauJets().size()); i++) {
00106     TauJetResult->push_back(m_FastL1GlobalAlgo->getTauJets().at(i));
00107   }
00108   for (int i=0; i<std::min(4,(int)m_FastL1GlobalAlgo->getCenJets().size()); i++) {
00109     CenJetResult->push_back(m_FastL1GlobalAlgo->getCenJets().at(i));
00110   }
00111   for (int i=0; i<std::min(4,(int)m_FastL1GlobalAlgo->getForJets().size()); i++) {
00112     ForJetResult->push_back(m_FastL1GlobalAlgo->getForJets().at(i));
00113   }
00114   for (int i=0; i<std::min(4,(int)m_FastL1GlobalAlgo->getEgammas().size()); i++) {
00115     EgammaResult->push_back(m_FastL1GlobalAlgo->getEgammas().at(i));
00116   }
00117   for (int i=0; i<std::min(4,(int)m_FastL1GlobalAlgo->getisoEgammas().size()); i++) {
00118     isoEgammaResult->push_back(m_FastL1GlobalAlgo->getisoEgammas().at(i));
00119   }
00120 
00121   if (m_DoBitInfo) {
00122   std::auto_ptr<FastL1BitInfoCollection> L1BitInfoResult(new FastL1BitInfoCollection);
00123     for (int i=0; i<(int)m_FastL1GlobalAlgo->getBitInfos().size(); i++) {
00124       L1BitInfoResult->push_back(m_FastL1GlobalAlgo->getBitInfos().at(i));
00125     }
00126     iEvent.put(L1BitInfoResult,"L1BitInfos");
00127   }
00128 
00129   // put the collections into the event
00130   /* old labels
00131   iEvent.put(METResult,"MET");
00132   iEvent.put(TauJetResult,"TauJets");
00133   iEvent.put(CenJetResult,"CenJets");
00134   iEvent.put(ForJetResult,"ForJets");
00135   iEvent.put(EgammaResult,"Egammas");
00136   iEvent.put(isoEgammaResult,"isoEgammas");
00137   */
00138   iEvent.put(METResult);
00139   iEvent.put(TauJetResult,"Tau");
00140   iEvent.put(CenJetResult,"Central");
00141   iEvent.put(ForJetResult,"Forward");
00142   iEvent.put(EgammaResult,"NonIsolated");
00143   iEvent.put(isoEgammaResult,"Isolated");
00144   iEvent.put(muonDummy);
00145 
00146 }
00147 
00148 //define this as a plug-in
00149 DEFINE_FWK_MODULE(FastL1CaloSim);