CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/SimG4CMS/EcalTestBeam/src/FakeTBEventHeaderProducer.cc

Go to the documentation of this file.
00001 /*
00002  * \file FakeTBEventHeaderProducer.cc
00003  *
00004  * $Id: FakeTBEventHeaderProducer.cc,v 1.5 2007/12/18 17:56:15 crovelli Exp $
00005  *
00006  */
00007 
00008 #include "SimG4CMS/EcalTestBeam/interface/FakeTBEventHeaderProducer.h"
00009 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00010 
00011 using namespace cms;
00012 using namespace std;
00013 
00014 
00015 FakeTBEventHeaderProducer::FakeTBEventHeaderProducer(const edm::ParameterSet& ps) {
00016   produces<EcalTBEventHeader>();
00017   ecalTBInfoLabel_ = ps.getUntrackedParameter<string>("EcalTBInfoLabel","SimEcalTBG4Object");
00018 
00019 }
00020 
00021  
00022 FakeTBEventHeaderProducer::~FakeTBEventHeaderProducer() 
00023 {
00024 }
00025 
00026  void FakeTBEventHeaderProducer::produce(edm::Event & event, const edm::EventSetup& eventSetup)
00027 {
00028   auto_ptr<EcalTBEventHeader> product(new EcalTBEventHeader());
00029 
00030   // get the vertex information from the event
00031 
00032   const PEcalTBInfo* theEcalTBInfo=0;
00033   edm::Handle<PEcalTBInfo> EcalTBInfo;
00034   event.getByLabel(ecalTBInfoLabel_,EcalTBInfo);
00035   if (EcalTBInfo.isValid()){
00036     theEcalTBInfo = EcalTBInfo.product(); 
00037   } else {
00038     edm::LogError("FakeTBEventHeaderProducer") << "Error! can't get the product " << ecalTBInfoLabel_.c_str() ;
00039   }
00040   
00041   if (!theEcalTBInfo)
00042     return;
00043   
00044   product->setEventNumber(event.id().event());
00045   product->setRunNumber(event.id().run());
00046   product->setBurstNumber(1);
00047   product->setTriggerMask(0x1);
00048   product->setCrystalInBeam(EBDetId(1,theEcalTBInfo->nCrystal(),EBDetId::SMCRYSTALMODE));
00049   
00050 //   LogDebug("FakeTBHeader") << (*product);
00051 //   LogDebug("FakeTBHeader") << (*product).eventType();
00052 //   LogDebug("FakeTBHeader") << (*product).crystalInBeam();
00053   event.put(product);
00054   
00055 }