114 : castorDigiCollectionToken_(
118 hiSaveFlag(ps.getUntrackedParameter<
bool>(
"hiSaveFlag",
false)),
120 verboseflag(ps.getUntrackedParameter<
bool>(
"verbose",
false)),
121 firstTS(ps.getUntrackedParameter<
int>(
"firstTS", 0)),
122 lastTS(ps.getUntrackedParameter<
int>(
"lastTS", 9)) {
135 std::cout <<
"Calculating Pedestal constants...\n";
136 std::vector<NewPedBunch>::iterator bunch_it;
137 for (bunch_it =
Bunches.begin(); bunch_it !=
Bunches.end(); ++bunch_it) {
138 if (bunch_it->usedflag) {
140 std::cout <<
"Analyzing channel sector= " << bunch_it->detid.sector()
141 <<
" module = " << bunch_it->detid.module() << std::endl;
143 bunch_it->cap[0] /= bunch_it->num[0][0];
144 bunch_it->cap[1] /= bunch_it->num[1][1];
145 bunch_it->cap[2] /= bunch_it->num[2][2];
146 bunch_it->cap[3] /= bunch_it->num[3][3];
147 bunch_it->capfc[0] /= bunch_it->num[0][0];
148 bunch_it->capfc[1] /= bunch_it->num[1][1];
149 bunch_it->capfc[2] /= bunch_it->num[2][2];
150 bunch_it->capfc[3] /= bunch_it->num[3][3];
152 bunch_it->sig[0][0] = (bunch_it->prod[0][0] / bunch_it->num[0][0]) - (bunch_it->cap[0] * bunch_it->cap[0]);
153 bunch_it->sig[0][1] = (bunch_it->prod[0][1] / bunch_it->num[0][1]) - (bunch_it->cap[0] * bunch_it->cap[1]);
154 bunch_it->sig[0][2] = (bunch_it->prod[0][2] / bunch_it->num[0][2]) - (bunch_it->cap[0] * bunch_it->cap[2]);
155 bunch_it->sig[0][3] = (bunch_it->prod[0][3] / bunch_it->num[0][3]) - (bunch_it->cap[0] * bunch_it->cap[3]);
156 bunch_it->sig[1][0] = (bunch_it->prod[1][0] / bunch_it->num[1][0]) - (bunch_it->cap[1] * bunch_it->cap[0]);
157 bunch_it->sig[1][1] = (bunch_it->prod[1][1] / bunch_it->num[1][1]) - (bunch_it->cap[1] * bunch_it->cap[1]);
158 bunch_it->sig[1][2] = (bunch_it->prod[1][2] / bunch_it->num[1][2]) - (bunch_it->cap[1] * bunch_it->cap[2]);
159 bunch_it->sig[1][3] = (bunch_it->prod[1][3] / bunch_it->num[1][3]) - (bunch_it->cap[1] * bunch_it->cap[3]);
160 bunch_it->sig[2][0] = (bunch_it->prod[2][0] / bunch_it->num[2][0]) - (bunch_it->cap[2] * bunch_it->cap[0]);
161 bunch_it->sig[2][1] = (bunch_it->prod[2][1] / bunch_it->num[2][1]) - (bunch_it->cap[2] * bunch_it->cap[1]);
162 bunch_it->sig[2][2] = (bunch_it->prod[2][2] / bunch_it->num[2][2]) - (bunch_it->cap[2] * bunch_it->cap[2]);
163 bunch_it->sig[2][3] = (bunch_it->prod[2][3] / bunch_it->num[2][3]) - (bunch_it->cap[2] * bunch_it->cap[3]);
164 bunch_it->sig[3][0] = (bunch_it->prod[3][0] / bunch_it->num[3][0]) - (bunch_it->cap[3] * bunch_it->cap[0]);
165 bunch_it->sig[3][1] = (bunch_it->prod[3][1] / bunch_it->num[3][1]) - (bunch_it->cap[3] * bunch_it->cap[1]);
166 bunch_it->sig[3][2] = (bunch_it->prod[3][2] / bunch_it->num[3][2]) - (bunch_it->cap[3] * bunch_it->cap[2]);
167 bunch_it->sig[3][3] = (bunch_it->prod[3][3] / bunch_it->num[3][3]) - (bunch_it->cap[3] * bunch_it->cap[3]);
169 bunch_it->sigfc[0][0] =
170 (bunch_it->prodfc[0][0] / bunch_it->num[0][0]) - (bunch_it->capfc[0] * bunch_it->capfc[0]);
171 bunch_it->sigfc[0][1] =
172 (bunch_it->prodfc[0][1] / bunch_it->num[0][1]) - (bunch_it->capfc[0] * bunch_it->capfc[1]);
173 bunch_it->sigfc[0][2] =
174 (bunch_it->prodfc[0][2] / bunch_it->num[0][2]) - (bunch_it->capfc[0] * bunch_it->capfc[2]);
175 bunch_it->sigfc[0][3] =
176 (bunch_it->prodfc[0][3] / bunch_it->num[0][3]) - (bunch_it->capfc[0] * bunch_it->capfc[3]);
177 bunch_it->sigfc[1][0] =
178 (bunch_it->prodfc[1][0] / bunch_it->num[1][0]) - (bunch_it->capfc[1] * bunch_it->capfc[0]);
179 bunch_it->sigfc[1][1] =
180 (bunch_it->prodfc[1][1] / bunch_it->num[1][1]) - (bunch_it->capfc[1] * bunch_it->capfc[1]);
181 bunch_it->sigfc[1][2] =
182 (bunch_it->prodfc[1][2] / bunch_it->num[1][2]) - (bunch_it->capfc[1] * bunch_it->capfc[2]);
183 bunch_it->sigfc[1][3] =
184 (bunch_it->prodfc[1][3] / bunch_it->num[1][3]) - (bunch_it->capfc[1] * bunch_it->capfc[3]);
185 bunch_it->sigfc[2][0] =
186 (bunch_it->prodfc[2][0] / bunch_it->num[2][0]) - (bunch_it->capfc[2] * bunch_it->capfc[0]);
187 bunch_it->sigfc[2][1] =
188 (bunch_it->prodfc[2][1] / bunch_it->num[2][1]) - (bunch_it->capfc[2] * bunch_it->capfc[1]);
189 bunch_it->sigfc[2][2] =
190 (bunch_it->prodfc[2][2] / bunch_it->num[2][2]) - (bunch_it->capfc[2] * bunch_it->capfc[2]);
191 bunch_it->sigfc[2][3] =
192 (bunch_it->prodfc[2][3] / bunch_it->num[2][3]) - (bunch_it->capfc[2] * bunch_it->capfc[3]);
193 bunch_it->sigfc[3][0] =
194 (bunch_it->prodfc[3][0] / bunch_it->num[3][0]) - (bunch_it->capfc[3] * bunch_it->capfc[0]);
195 bunch_it->sigfc[3][1] =
196 (bunch_it->prodfc[3][1] / bunch_it->num[3][1]) - (bunch_it->capfc[3] * bunch_it->capfc[1]);
197 bunch_it->sigfc[3][2] =
198 (bunch_it->prodfc[3][2] / bunch_it->num[3][2]) - (bunch_it->capfc[3] * bunch_it->capfc[2]);
199 bunch_it->sigfc[3][3] =
200 (bunch_it->prodfc[3][3] / bunch_it->num[3][3]) - (bunch_it->capfc[3] * bunch_it->capfc[3]);
202 for (
int i = 0;
i != 3;
i++) {
209 int fillphi = bunch_it->detid.sector();
214 dephist->Fill(bunch_it->detid.module(),
216 (bunch_it->cap[0] + bunch_it->cap[1] + bunch_it->cap[2] + bunch_it->cap[3]) / 4);
226 bunch_it->sig[3][3]);
229 widthsp.
setSigma(0, 0, bunch_it->sig[0][0]);
230 widthsp.
setSigma(0, 1, bunch_it->sig[0][1]);
231 widthsp.
setSigma(0, 2, bunch_it->sig[0][2]);
232 widthsp.
setSigma(0, 3, bunch_it->sig[0][3]);
233 widthsp.
setSigma(1, 0, bunch_it->sig[1][0]);
234 widthsp.
setSigma(1, 1, bunch_it->sig[1][1]);
235 widthsp.
setSigma(1, 2, bunch_it->sig[1][2]);
236 widthsp.
setSigma(1, 3, bunch_it->sig[1][3]);
237 widthsp.
setSigma(2, 0, bunch_it->sig[2][0]);
238 widthsp.
setSigma(2, 1, bunch_it->sig[2][1]);
239 widthsp.
setSigma(2, 2, bunch_it->sig[2][2]);
240 widthsp.
setSigma(2, 3, bunch_it->sig[2][3]);
241 widthsp.
setSigma(3, 0, bunch_it->sig[3][0]);
242 widthsp.
setSigma(3, 1, bunch_it->sig[3][1]);
243 widthsp.
setSigma(3, 2, bunch_it->sig[3][2]);
244 widthsp.
setSigma(3, 3, bunch_it->sig[3][3]);
252 bunch_it->sigfc[0][0],
253 bunch_it->sigfc[1][1],
254 bunch_it->sigfc[2][2],
255 bunch_it->sigfc[3][3]);
258 widthspfc.
setSigma(0, 0, bunch_it->sigfc[0][0]);
259 widthspfc.
setSigma(0, 1, bunch_it->sigfc[0][1]);
260 widthspfc.
setSigma(0, 2, bunch_it->sigfc[0][2]);
261 widthspfc.
setSigma(0, 3, bunch_it->sigfc[0][3]);
262 widthspfc.
setSigma(1, 0, bunch_it->sigfc[1][0]);
263 widthspfc.
setSigma(1, 1, bunch_it->sigfc[1][1]);
264 widthspfc.
setSigma(1, 2, bunch_it->sigfc[1][2]);
265 widthspfc.
setSigma(1, 3, bunch_it->sigfc[1][3]);
266 widthspfc.
setSigma(2, 0, bunch_it->sigfc[2][0]);
267 widthspfc.
setSigma(2, 1, bunch_it->sigfc[2][1]);
268 widthspfc.
setSigma(2, 2, bunch_it->sigfc[2][2]);
269 widthspfc.
setSigma(2, 3, bunch_it->sigfc[2][3]);
270 widthspfc.
setSigma(3, 0, bunch_it->sigfc[3][0]);
271 widthspfc.
setSigma(3, 1, bunch_it->sigfc[3][1]);
272 widthspfc.
setSigma(3, 2, bunch_it->sigfc[3][2]);
273 widthspfc.
setSigma(3, 3, bunch_it->sigfc[3][3]);
294 dephist->SetDrawOption(
"colz");
295 dephist->GetXaxis()->SetTitle(
"module");
296 dephist->GetYaxis()->SetTitle(
"sector");
298 std::stringstream tempstringout;
300 std::string name1 = tempstringout.str() +
"_pedplots_1d.png";
303 TStyle* theStyle =
new TStyle(
"style",
"null");
304 theStyle->SetPalette(1,
nullptr);
305 theStyle->SetCanvasDefH(1200);
306 theStyle->SetCanvasDefW(1600);
352 std::stringstream tempstringout;
354 runnum_string = tempstringout.str();
360 XMLfilename = runnum_string +
"-peds_ADC_complete.xml";
361 XMLtag =
"Castor_pedestals_" + runnum_string;
365 CASTORMeans =
fs->make<TH1F>(
"All Ped Means CASTOR",
"All Ped Means CASTOR", 100, 0, 9);
366 CASTORWidths =
fs->make<TH1F>(
"All Ped Widths CASTOR",
"All Ped Widths CASTOR", 100, 0, 3);
368 dephist =
fs->make<TH2F>(
"Pedestals (ADC)",
"All Castor", 14, 0., 14.5, 16, .5, 16.5);
371 std::vector<HcalGenericDetId> listEMap = myRefEMap->
allPrecisionId();
372 for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); ++it) {
374 if (mygenid.isHcalCastorDetId()) {
380 for (
int i = 0;
i != 4;
i++) {
383 for (
int j = 0;
j != 4;
j++) {
397 std::vector<NewPedBunch>::iterator bunch_it;
401 for (bunch_it =
Bunches.begin(); bunch_it !=
Bunches.end(); ++bunch_it)
402 if (bunch_it->detid.rawId() == digi.
id().
rawId())
404 bunch_it->usedflag =
true;
410 bunch_it->capfc[digi.
sample(ts).
capid()] += charge1;
414 if ((ts + 1 < digi.
size()) && (ts + 1 <
lastTS)) {
421 if ((ts + 2 < digi.
size()) && (ts + 2 <
lastTS)) {
428 if ((ts + 3 < digi.
size()) && (ts + 3 <
lastTS)) {
const edm::ESGetToken< CastorDbService, CastorDbRecord > tok_cond_
static const std::string kSharedResource
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
void setSigma(int fCapId1, int fCapId2, float fSigma)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::vector< NewPedBunch > Bunches
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
const HcalQIESample & sample(int i) const
access a sample
std::vector< T >::const_iterator const_iterator
std::string widthsfCfilename
~CastorPedestalsAnalysis() override
int size() const
total number of samples in the digi
#define DEFINE_FWK_MODULE(type)
std::string widthsADCfilename
const HcalCastorDetId & id() const
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
std::vector< HcalGenericDetId > allPrecisionId() const
const edm::EDGetTokenT< CastorDigiCollection > castorDigiCollectionToken_
constexpr uint32_t rawId() const
get the raw id
std::string pedsADCfilename
CastorPedestalsAnalysis(const edm::ParameterSet &ps)
bool addValues(const Item &myItem)
const edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcd > tok_map_
constexpr int capid() const
get the Capacitor id
std::string pedsfCfilename
constexpr int adc() const
get the ADC sample