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  init_ = false;
29 
30  dqmStore_ = Service<DQMStore>().operator->();
31 
32  digitoken_ = consumes<ESDigiCollection>(ps.getParameter<InputTag>("DigiLabel"));
33  lookup_ = ps.getUntrackedParameter<FileInPath>("LookupTable");
34  outputFile_ = ps.getUntrackedParameter<string>("OutputFile","");
35  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "EcalPreshower");
36 
37  for (int i=0; i<2; ++i)
38  for (int j=0; j<2; ++j)
39  for (int k=0; k<40; ++k)
40  for (int l=0; l<40; ++l)
41  senCount_[i][j][k][l] = -1;
42 
43 }
44 
46 }
47 
49  ievt_ = 0;
50 }
51 
52 void ESPedestalTask::beginRun(const Run& r, const EventSetup& c) {
53 
54  if ( ! mergeRuns_ ) this->reset();
55 
56 }
57 
58 void ESPedestalTask::endRun(const Run& r, const EventSetup& c) {
59 }
60 
62 
63 }
64 
66 
67  init_ = true;
68 
69  int iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
70  int senZ_[4288], senP_[4288], senX_[4288], senY_[4288];
71 
72  // read in look-up table
73  ifstream file;
74  file.open(lookup_.fullPath().c_str());
75  if( file.is_open() ) {
76 
77  file >> nLines_;
78 
79  for (int i=0; i<nLines_; ++i) {
80  file>> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
81 
82  senZ_[i] = iz;
83  senP_[i] = ip;
84  senX_[i] = ix;
85  senY_[i] = iy;
86 
87  iz = (senZ_[i]==1) ? 0:1;
88  senCount_[iz][senP_[i]-1][senX_[i]-1][senY_[i]-1] = i;
89  }
90  }
91  else {
92  cout<<"ESPedestalTask : Look up table file can not be found in "<<lookup_.fullPath().c_str()<<endl;
93  }
94 
95  char hname[300];
96 
97  if (dqmStore_) {
98  dqmStore_->setCurrentFolder(prefixME_ + "/ESPedestalTask");
99 
100  for (int i=0; i<nLines_; ++i) {
101  for (int is=0; is<32; ++is) {
102  sprintf(hname, "ADC Z %d P %d X %d Y %d Str %d", senZ_[i], senP_[i], senX_[i], senY_[i], is+1);
103  meADC_[i][is] = dqmStore_->book1D(hname, hname, 1000, 899.5, 1899.5);
104  }
105  }
106  }
107 
108 }
109 
111 
112  if ( ! init_ ) return;
113 
114  init_ = false;
115 }
116 
118 
119  LogInfo("ESPedestalTask") << "analyzed " << ievt_ << " events";
120 
121  if ( enableCleanup_ ) this->cleanup();
122 
123 }
124 
126 
127  if ( ! init_ ) this->setup();
128 
129  ievt_++;
130  runNum_ = e.id().run();
131 
133  e.getByToken(digitoken_, digis);
134 
135  runtype_ = 1; // Let runtype_ = 1
136 
137  // Digis
138  int zside, plane, ix, iy, strip, iz;
139  if (digis.isValid()) {
140  for (ESDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr) {
141 
142  ESDataFrame dataframe = (*digiItr);
143  ESDetId id = dataframe.id();
144 
145  zside = id.zside();
146  plane = id.plane();
147  ix = id.six();
148  iy = id.siy();
149  strip = id.strip();
150  iz = (zside==1) ? 0:1;
151 
152  if (meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]) {
153  if(runtype_ == 1){
154  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(0).adc());
155  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(1).adc());
156  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(2).adc());
157  } else if(runtype_ == 3) {
158  meADC_[senCount_[iz][plane-1][ix-1][iy-1]][strip-1]->Fill(dataframe.sample(1).adc());
159  }
160  }
161 
162  }
163  }
164 
165 }
166 
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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:44
bool isValid() const
Definition: HandleBase.h:76
int k[5][pyjets_maxn]
DEFINE_FWK_MODULE(CaloMETProducer)
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:41
void cleanup(void)