00001
00002
00003 #include "VisReco/Analyzer/interface/VisEvent.h"
00004 #include "VisReco/Analyzer/interface/IguanaService.h"
00005 #include "VisReco/Analyzer/interface/debug.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/MakerMacros.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 #include "Iguana/Framework/interface/IgCollection.h"
00010 #include "boost/date_time/posix_time/posix_time.hpp"
00011 #include "classlib/utils/Error.h"
00012 #include <sys/time.h>
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 using namespace edm::service;
00025
00026 VisEvent::VisEvent (const edm::ParameterSet& iPSet)
00027 {}
00028
00029 void
00030 VisEvent::analyze( const edm::Event& event, const edm::EventSetup& )
00031 {
00032 edm::Service<IguanaService> config;
00033 if (! config.isAvailable ())
00034 {
00035 throw cms::Exception ("Configuration")
00036 << "VisEvent requires the IguanaService\n"
00037 "which is not present in the configuration file.\n"
00038 "You must add the service in the configuration file\n"
00039 "or remove the module that requires it";
00040 }
00041 const edm::Timestamp time = event.time ();
00042
00043 timeval eventTime;
00044 eventTime.tv_sec = time.value () >> 32;
00045 eventTime.tv_usec = 0xFFFFFFFF & time.value ();
00046
00047 boost::posix_time::ptime bt0 = boost::posix_time::from_time_t(0);
00048 boost::posix_time::ptime bt = bt0 + boost::posix_time::seconds(eventTime.tv_sec)
00049 + boost::posix_time::microseconds(eventTime.tv_usec);
00050
00051 std::stringstream oss;
00052 oss << bt << " GMT: Run " << event.id ().run ()
00053 << ", Event " << event.id ().event ()
00054 << ", LS " << event.luminosityBlock ()
00055 << ", Orbit " << event.orbitNumber ()
00056 << ", BX " << event.bunchCrossing ();
00057 std::string contents (oss.str ());
00058
00059 std::string statusText = contents;
00060
00061 LOG (1, trace, LFfwvis, "VisEvent::analyze " << contents << "\n");
00062
00063 IgDataStorage *storage = config->storage ();
00064 ASSERT (storage);
00065 IgCollection &eventColl = storage->getCollection ("Event_V1");
00066
00067 IgProperty RUN = eventColl.addProperty ("run", static_cast<int>(0));
00068 IgProperty EVENT = eventColl.addProperty ("event", static_cast<int>(0));
00069 IgProperty LS = eventColl.addProperty ("ls", static_cast<int>(0));
00070 IgProperty ORBIT = eventColl.addProperty ("orbit", static_cast<int>(0));
00071 IgProperty BX = eventColl.addProperty ("bx", static_cast<int>(0));
00072 IgProperty TIME = eventColl.addProperty ("time", std::string ());
00073
00074 IgCollectionItem eventId = eventColl.create();
00075 eventId [RUN] = static_cast<int>(event.id ().run ());
00076 eventId [EVENT] = static_cast<int>(event.id ().event ());
00077 eventId [LS] = static_cast<int>(event.luminosityBlock ());
00078 eventId [ORBIT] = static_cast<int>(event.orbitNumber ());
00079 eventId [BX] = static_cast<int>(event.bunchCrossing ());
00080 eventId [TIME] = static_cast<std::string>(contents);
00081 }
00082
00083 DEFINE_FWK_MODULE(VisEvent);