CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESDigiToRaw.cc
Go to the documentation of this file.
4 
6 
10 
11 using namespace std;
12 using namespace edm;
13 
14 ESDigiToRaw::ESDigiToRaw(const edm::ParameterSet& ps) : ESDataFormatter_(0)
15 {
16 
17  label_ = ps.getParameter<string>("Label");
18  instanceName_ = ps.getParameter<string>("InstanceES");
19  edm::InputTag ESTag = edm::InputTag(label_, instanceName_);
20  ESDigiToken_ = consumes<ESDigiCollection>(ESTag);
21  debug_ = ps.getUntrackedParameter<bool>("debugMode", false);
22  formatMajor_ = ps.getUntrackedParameter<int>("formatMajor", 4);
23  formatMinor_ = ps.getUntrackedParameter<int>("formatMinor", 1);
24  lookup_ = ps.getUntrackedParameter<FileInPath>("LookupTable");
25 
26  counter_ = 0;
27  kchip_ec_ = 0;
28  kchip_bc_ = 0;
29 
30  produces<FEDRawDataCollection>();
31 
32  if (formatMajor_ == 4)
34  else
36 
37  // initialize look-up table
38  for (int i=0; i<2; ++i)
39  for (int j=0; j<2; ++j)
40  for (int k=0 ;k<40; ++k)
41  for (int m=0; m<40; m++)
42  fedId_[i][j][k][m] = -1;
43 
44  // read in look-up table
45  int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
46  ifstream file;
47  file.open(lookup_.fullPath().c_str());
48  if( file.is_open() ) {
49 
50  file >> nLines;
51  for (int i=0; i<nLines; ++i) {
52  file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx ;
53  fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed;
54  }
55  } else {
56  cout<<"[ESDigiToRaw] Look up table file can not be found in "<<lookup_.fullPath().c_str() <<endl;
57  }
58 
59  file.close();
60 }
61 
64 }
65 
67 }
68 
70 
71  run_number_ = ev.id().run();
74 
75  lv1_ = ev.id().event();
78  counter_++;
79 
86 
88  ev.getByToken(ESDigiToken_, digis);
89 
90  int ifed;
92  Digis.clear();
93 
94  for (ESDigiCollection::const_iterator it=digis->begin(); it!=digis->end(); ++it) {
95 
96  const ESDataFrame& df = *it;
97  const ESDetId& detId = it->id();
98 
99  ifed = fedId_[(3-detId.zside())/2-1][detId.plane()-1][detId.six()-1][detId.siy()-1];
100  if (ifed < 0) continue;
101 
102  Digis[ifed].push_back(df);
103  }
104 
105  auto_ptr<FEDRawDataCollection> productRawData( new FEDRawDataCollection );
106 
107  ESDataFormatter::Digis::const_iterator itfed;
108  for (itfed = Digis.begin(); itfed != Digis.end(); ++itfed) {
109  int fId = (*itfed).first ;
110 
111  FEDRawData& fedRawData = productRawData->FEDData(fId);
112  ESDataFormatter_->DigiToRaw(fId, Digis, fedRawData);
113 
114  if (debug_) cout<<"FED : "<<fId<<" Data size : "<<fedRawData.size()<<" (Bytes)"<<endl;
115  }
116 
117  ev.put(productRawData);
118 
119  return;
120 }
121 
123 }
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static const int KCHIP_EC_RANGE
Definition: ESDigiToRaw.h:43
void produce(edm::Event &e, const edm::EventSetup &es)
Definition: ESDigiToRaw.cc:69
virtual void DigiToRaw(int fedId, Digis &digis, FEDRawData &fedRawData)=0
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
virtual ~ESDigiToRaw()
Definition: ESDigiToRaw.cc:62
virtual void setRunNumber(int i)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
int orbit_number_
Definition: ESDigiToRaw.h:48
bool ev
int six() const
Definition: ESDetId.h:48
virtual void setKchipEC(int i)
std::string label_
Definition: ESDigiToRaw.h:56
edm::EDGetTokenT< ESDigiCollection > ESDigiToken_
Definition: ESDigiToRaw.h:58
std::map< int, DetDigis > Digis
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int formatMinor_
Definition: ESDigiToRaw.h:62
ESDataFormatter * ESDataFormatter_
Definition: ESDigiToRaw.h:64
virtual void setKchipBC(int i)
int siy() const
Definition: ESDetId.h:50
edm::FileInPath lookup_
Definition: ESDigiToRaw.h:59
virtual void setBX(int i)
int formatMajor_
Definition: ESDigiToRaw.h:61
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
int fedId_[2][2][40][40]
Definition: ESDigiToRaw.h:54
std::string instanceName_
Definition: ESDigiToRaw.h:57
int j
Definition: DBlmapReader.cc:9
virtual void setOrbitNumber(int i)
int run_number_
Definition: ESDigiToRaw.h:49
int zside() const
Definition: ESDetId.h:44
virtual void setLV1(int i)
void beginJob()
Definition: ESDigiToRaw.cc:66
ESDigiToRaw(const edm::ParameterSet &ps)
Definition: ESDigiToRaw.cc:14
edm::EventID id() const
Definition: EventBase.h:60
static const int KCHIP_BC_RANGE
Definition: ESDigiToRaw.h:42
int plane() const
Definition: ESDetId.h:46
tuple cout
Definition: gather_cfg.py:121
void endJob()
Definition: ESDigiToRaw.cc:122
static const int LHC_BX_RANGE
Definition: ESDigiToRaw.h:41