CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelDigiToRaw.cc
Go to the documentation of this file.
1 #include "SiPixelDigiToRaw.h"
2 
5 
7 
12 
15 
18 using namespace std;
19 
21  cablingTree_(0),
22  config_(pset)
23 {
24 
25  // Define EDProduct type
26  produces<FEDRawDataCollection>();
27 
28  // start the counters
29  eventCounter = 0;
30  allDigiCounter = 0;
31  allWordCounter = 0;
32 
33 }
34 
35 // -----------------------------------------------------------------------------
37  delete cablingTree_;
38 }
39 
40 // -----------------------------------------------------------------------------
41 
42 // -----------------------------------------------------------------------------
44  const edm::EventSetup& es)
45 {
46  using namespace sipixelobjects;
47  eventCounter++;
48  edm::LogInfo("SiPixelDigiToRaw") << "[SiPixelDigiToRaw::produce] "
49  << "event number: " << eventCounter;
50 
52  label = config_.getParameter<edm::InputTag>("InputLabel");
54 
56  typedef vector< edm::DetSet<PixelDigi> >::const_iterator DI;
57 
58  int digiCounter = 0;
59  for (DI di=digiCollection->begin(); di != digiCollection->end(); di++) {
60  digiCounter += (di->data).size();
61  digis[ di->id] = di->data;
62  }
63  allDigiCounter += digiCounter;
64 
65  if (recordWatcher.check( es )) {
67  es.get<SiPixelFedCablingMapRcd>().get( cablingMap );
68  if (cablingTree_) delete cablingTree_; cablingTree_= cablingMap->cablingTree();
69  }
70 
72  if (debug) LogDebug("SiPixelDigiToRaw") << cablingTree_->version();
73 
75 
76  // create product (raw data)
77  std::auto_ptr<FEDRawDataCollection> buffers( new FEDRawDataCollection );
78 
79  const vector<const PixelFEDCabling *> fedList = cablingTree_->fedList();
80 
81  typedef vector<const PixelFEDCabling *>::const_iterator FI;
82  for (FI it = fedList.begin(); it != fedList.end(); it++) {
83  LogDebug("SiPixelDigiToRaw")<<" PRODUCE DATA FOR FED_id: " << (**it).id();
84  FEDRawData * rawData = formatter.formatData( ev.id().event(),(**it).id(), digis);
85  FEDRawData& fedRawData = buffers->FEDData( (**it).id() );
86  fedRawData = *rawData;
87  LogDebug("SiPixelDigiToRaw")<<"size of data in fedRawData: "<<fedRawData.size();
88  delete rawData;
89  }
90  allWordCounter += formatter.nWords();
91  if (debug) LogDebug("SiPixelDigiToRaw")
92 
93  << "Words/Digis this ev: "<<digiCounter<<"(fm:"<<formatter.nDigis()<<")/"
94  <<formatter.nWords()
95  <<" all: "<< allDigiCounter <<"/"<<allWordCounter;
96 
97 
98  ev.put( buffers );
99 
100 }
101 
102 // -----------------------------------------------------------------------------
103 
#define LogDebug(id)
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
SiPixelDigiToRaw(const edm::ParameterSet &)
ctor
static MessageDrop * instance()
Definition: MessageDrop.cc:61
unsigned long eventCounter
static bool debugEnabled
Definition: MessageDrop.h:97
virtual void produce(edm::Event &, const edm::EventSetup &)
get data, convert to raw event, attach again to Event
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
virtual ~SiPixelDigiToRaw()
dtor
tuple pset
Definition: CrabTask.py:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
virtual std::string version() const
map version
const T & get() const
Definition: EventSetup.h:55
edm::ESWatcher< SiPixelFedCablingMapRcd > recordWatcher
edm::ParameterSet config_
FEDRawData * formatData(unsigned int lvl1_ID, int fedId, const Digis &digis)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:59
edm::EventID id() const
Definition: EventBase.h:56
std::map< uint32_t, DetDigis > Digis
SiPixelFedCablingTree * cablingTree_
std::vector< const PixelFEDCabling * > fedList() const
tuple size
Write out results.
edm::InputTag label