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 
17 
20 
22 
23 using namespace cms;
24 using namespace edm;
25 using namespace std;
26 
28 
29  init_ = false;
30 
31  dqmStore_ = Service<DQMStore>().operator->();
32 
33  digilabel_ = ps.getParameter<InputTag>("DigiLabel");
34  lookup_ = ps.getUntrackedParameter<FileInPath>("LookupTable");
35  outputFile_ = ps.getUntrackedParameter<string>("OutputFile","");
36  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "EcalPreshower");
37 
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 l=0; l<40; ++l)
42  senCount_[i][j][k][l] = -1;
43 
44 }
45 
47 }
48 
50  ievt_ = 0;
51 }
52 
53 void ESPedestalTask::beginRun(const Run& r, const EventSetup& c) {
54 
55  if ( ! mergeRuns_ ) this->reset();
56 
57 }
58 
59 void ESPedestalTask::endRun(const Run& r, const EventSetup& c) {
60 }
61 
63 
64 }
65 
67 
68  init_ = true;
69 
70  int iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
71  int senZ_[4288], senP_[4288], senX_[4288], senY_[4288];
72 
73  // read in look-up table
74  ifstream file;
75  file.open(lookup_.fullPath().c_str());
76  if( file.is_open() ) {
77 
78  file >> nLines_;
79 
80  for (int i=0; i<nLines_; ++i) {
81  file>> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
82 
83  senZ_[i] = iz;
84  senP_[i] = ip;
85  senX_[i] = ix;
86  senY_[i] = iy;
87 
88  iz = (senZ_[i]==1) ? 0:1;
89  senCount_[iz][senP_[i]-1][senX_[i]-1][senY_[i]-1] = i;
90  }
91  }
92  else {
93  cout<<"ESPedestalTask : Look up table file can not be found in "<<lookup_.fullPath().c_str()<<endl;
94  }
95 
96  char hname[300];
97 
98  if (dqmStore_) {
99  dqmStore_->setCurrentFolder(prefixME_ + "/ESPedestalTask");
100 
101  for (int i=0; i<nLines_; ++i) {
102  for (int is=0; is<32; ++is) {
103  sprintf(hname, "ADC Z %d P %d X %d Y %d Str %d", senZ_[i], senP_[i], senX_[i], senY_[i], is+1);
104  meADC_[i][is] = dqmStore_->book1D(hname, hname, 1000, 899.5, 1899.5);
105  }
106  }
107  }
108 
109 }
110 
112 
113  if ( ! init_ ) return;
114 
115  init_ = false;
116 }
117 
119 
120  LogInfo("ESPedestalTask") << "analyzed " << ievt_ << " events";
121 
122  if ( enableCleanup_ ) this->cleanup();
123 
124 }
125 
127 
128  if ( ! init_ ) this->setup();
129 
130  ievt_++;
131  runNum_ = e.id().run();
132 
134  e.getByLabel(digilabel_, digis);
135 
136  runtype_ = 1; // Let runtype_ = 1
137 
138  // Digis
139  int zside, plane, ix, iy, strip, iz;
140  if (digis.isValid()) {
141  for (ESDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr) {
142 
143  ESDataFrame dataframe = (*digiItr);
144  ESDetId id = dataframe.id();
145 
146  zside = id.zside();
147  plane = id.plane();
148  ix = id.six();
149  iy = id.siy();
150  strip = id.strip();
151  iz = (zside==1) ? 0:1;
152 
153  if (meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]) {
154  if(runtype_ == 1){
155  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(0).adc());
156  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(1).adc());
157  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(2).adc());
158  } else if(runtype_ == 3) {
159  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(1).adc());
160  }
161  }
162 
163  }
164  }
165 
166 }
167 
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void reset(void)
void endJob(void)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
DEFINE_FWK_MODULE(TauMET)
const ESDetId & id() const
Definition: ESDataFrame.h:21
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
virtual ~ESPedestalTask()
void analyze(const edm::Event &, const edm::EventSetup &)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
const ESSample & sample(int i) const
Definition: ESDataFrame.h:26
int j
Definition: DBlmapReader.cc:9
int zside() const
Definition: ESDetId.h:33
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
int k[5][pyjets_maxn]
void setup(void)
ESPedestalTask(const edm::ParameterSet &ps)
void endRun(const edm::Run &r, const edm::EventSetup &c)
edm::EventID id() const
Definition: EventBase.h:56
void beginJob(void)
tuple cout
Definition: gather_cfg.py:121
int adc() const
get the ADC sample (singed 16 bits)
Definition: ESSample.h:18
void reset(double vett[256])
Definition: TPedValues.cc:11
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Definition: Run.h:33
void cleanup(void)