CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESPedestalTask.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <fstream>
3 #include <iostream>
4 
7 
11 
16 
19 
21 
22 using namespace cms;
23 using namespace edm;
24 using namespace std;
25 
27 
28  digitoken_ = consumes<ESDigiCollection>(ps.getParameter<InputTag>("DigiLabel"));
29  lookup_ = ps.getUntrackedParameter<FileInPath>("LookupTable");
30  outputFile_ = ps.getUntrackedParameter<string>("OutputFile","");
31  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "EcalPreshower");
32 
33  for (int i=0; i<2; ++i)
34  for (int j=0; j<2; ++j)
35  for (int k=0; k<40; ++k)
36  for (int l=0; l<40; ++l)
37  senCount_[i][j][k][l] = -1;
38 
39  ievt_ = 0;
40 }
41 
43 {
44  int iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
45  int senZ_[4288], senP_[4288], senX_[4288], senY_[4288];
46 
47  // read in look-up table
48  ifstream file(lookup_.fullPath().c_str());
49  if(!file.is_open())
50  throw cms::Exception("FileNotFound") << lookup_.fullPath();
51 
52  file >> nLines_;
53 
54  for (int i=0; i<nLines_; ++i) {
55  file>> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
56 
57  senZ_[i] = iz;
58  senP_[i] = ip;
59  senX_[i] = ix;
60  senY_[i] = iy;
61 
62  iz = (senZ_[i]==1) ? 0:1;
63  senCount_[iz][senP_[i]-1][senX_[i]-1][senY_[i]-1] = i;
64  }
65 
66  char hname[300];
67 
68  iBooker.setCurrentFolder(prefixME_ + "/ESPedestalTask");
69 
70  for (int i=0; i<nLines_; ++i) {
71  for (int is=0; is<32; ++is) {
72  sprintf(hname, "ADC Z %d P %d X %d Y %d Str %d", senZ_[i], senP_[i], senX_[i], senY_[i], is+1);
73  meADC_[i][is] = iBooker.book1D(hname, hname, 1000, 899.5, 1899.5);
74  }
75  }
76 }
77 
79 
80  LogInfo("ESPedestalTask") << "analyzed " << ievt_ << " events";
81 
82 }
83 
84 void ESPedestalTask::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
85 
86  ievt_++;
87  runNum_ = e.id().run();
88 
90  e.getByToken(digitoken_, digis);
91 
92  runtype_ = 1; // Let runtype_ = 1
93 
94  // Digis
95  int zside, plane, ix, iy, strip, iz;
96  if (digis.isValid()) {
97  for (ESDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr) {
98 
99  ESDataFrame dataframe = (*digiItr);
100  ESDetId id = dataframe.id();
101 
102  zside = id.zside();
103  plane = id.plane();
104  ix = id.six();
105  iy = id.siy();
106  strip = id.strip();
107  iz = (zside==1) ? 0:1;
108 
109  if (meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]) {
110  if(runtype_ == 1){
111  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(0).adc());
112  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(1).adc());
113  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(2).adc());
114  } else if(runtype_ == 3) {
115  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(1).adc());
116  }
117  }
118 
119  }
120  }
121 
122 }
123 
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void endJob(void)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const ESDetId & id() const
Definition: ESDataFrame.h:21
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
int zside(DetId const &)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
const ESSample & sample(int i) const
Definition: ESDataFrame.h:26
int j
Definition: DBlmapReader.cc:9
int zside() const
Definition: ESDetId.h:44
bool isValid() const
Definition: HandleBase.h:75
ESPedestalTask(const edm::ParameterSet &ps)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
edm::EventID id() const
Definition: EventBase.h:60
int adc() const
get the ADC sample (singed 16 bits)
Definition: ESSample.h:18
Definition: Run.h:43
void analyze(const edm::Event &, const edm::EventSetup &) override