117 : castorDigiCollectionTag(ps.getParameter<edm::
InputTag>(
"castorDigiCollectionTag")) {
127 tok_cond_ = esConsumes<CastorDbService, CastorDbRecord>();
128 tok_map_ = esConsumes<CastorElectronicsMap, CastorElectronicsMapRcd>();
138 std::cout <<
"Calculating Pedestal constants...\n";
139 std::vector<NewPedBunch>::iterator bunch_it;
140 for (bunch_it =
Bunches.begin(); bunch_it !=
Bunches.end(); ++bunch_it) {
141 if (bunch_it->usedflag) {
143 std::cout <<
"Analyzing channel sector= " << bunch_it->detid.sector()
144 <<
" module = " << bunch_it->detid.module() << std::endl;
146 bunch_it->cap[0] /= bunch_it->num[0][0];
147 bunch_it->cap[1] /= bunch_it->num[1][1];
148 bunch_it->cap[2] /= bunch_it->num[2][2];
149 bunch_it->cap[3] /= bunch_it->num[3][3];
150 bunch_it->capfc[0] /= bunch_it->num[0][0];
151 bunch_it->capfc[1] /= bunch_it->num[1][1];
152 bunch_it->capfc[2] /= bunch_it->num[2][2];
153 bunch_it->capfc[3] /= bunch_it->num[3][3];
155 bunch_it->sig[0][0] = (bunch_it->prod[0][0] / bunch_it->num[0][0]) - (bunch_it->cap[0] * bunch_it->cap[0]);
156 bunch_it->sig[0][1] = (bunch_it->prod[0][1] / bunch_it->num[0][1]) - (bunch_it->cap[0] * bunch_it->cap[1]);
157 bunch_it->sig[0][2] = (bunch_it->prod[0][2] / bunch_it->num[0][2]) - (bunch_it->cap[0] * bunch_it->cap[2]);
158 bunch_it->sig[0][3] = (bunch_it->prod[0][3] / bunch_it->num[0][3]) - (bunch_it->cap[0] * bunch_it->cap[3]);
159 bunch_it->sig[1][0] = (bunch_it->prod[1][0] / bunch_it->num[1][0]) - (bunch_it->cap[1] * bunch_it->cap[0]);
160 bunch_it->sig[1][1] = (bunch_it->prod[1][1] / bunch_it->num[1][1]) - (bunch_it->cap[1] * bunch_it->cap[1]);
161 bunch_it->sig[1][2] = (bunch_it->prod[1][2] / bunch_it->num[1][2]) - (bunch_it->cap[1] * bunch_it->cap[2]);
162 bunch_it->sig[1][3] = (bunch_it->prod[1][3] / bunch_it->num[1][3]) - (bunch_it->cap[1] * bunch_it->cap[3]);
163 bunch_it->sig[2][0] = (bunch_it->prod[2][0] / bunch_it->num[2][0]) - (bunch_it->cap[2] * bunch_it->cap[0]);
164 bunch_it->sig[2][1] = (bunch_it->prod[2][1] / bunch_it->num[2][1]) - (bunch_it->cap[2] * bunch_it->cap[1]);
165 bunch_it->sig[2][2] = (bunch_it->prod[2][2] / bunch_it->num[2][2]) - (bunch_it->cap[2] * bunch_it->cap[2]);
166 bunch_it->sig[2][3] = (bunch_it->prod[2][3] / bunch_it->num[2][3]) - (bunch_it->cap[2] * bunch_it->cap[3]);
167 bunch_it->sig[3][0] = (bunch_it->prod[3][0] / bunch_it->num[3][0]) - (bunch_it->cap[3] * bunch_it->cap[0]);
168 bunch_it->sig[3][1] = (bunch_it->prod[3][1] / bunch_it->num[3][1]) - (bunch_it->cap[3] * bunch_it->cap[1]);
169 bunch_it->sig[3][2] = (bunch_it->prod[3][2] / bunch_it->num[3][2]) - (bunch_it->cap[3] * bunch_it->cap[2]);
170 bunch_it->sig[3][3] = (bunch_it->prod[3][3] / bunch_it->num[3][3]) - (bunch_it->cap[3] * bunch_it->cap[3]);
172 bunch_it->sigfc[0][0] =
173 (bunch_it->prodfc[0][0] / bunch_it->num[0][0]) - (bunch_it->capfc[0] * bunch_it->capfc[0]);
174 bunch_it->sigfc[0][1] =
175 (bunch_it->prodfc[0][1] / bunch_it->num[0][1]) - (bunch_it->capfc[0] * bunch_it->capfc[1]);
176 bunch_it->sigfc[0][2] =
177 (bunch_it->prodfc[0][2] / bunch_it->num[0][2]) - (bunch_it->capfc[0] * bunch_it->capfc[2]);
178 bunch_it->sigfc[0][3] =
179 (bunch_it->prodfc[0][3] / bunch_it->num[0][3]) - (bunch_it->capfc[0] * bunch_it->capfc[3]);
180 bunch_it->sigfc[1][0] =
181 (bunch_it->prodfc[1][0] / bunch_it->num[1][0]) - (bunch_it->capfc[1] * bunch_it->capfc[0]);
182 bunch_it->sigfc[1][1] =
183 (bunch_it->prodfc[1][1] / bunch_it->num[1][1]) - (bunch_it->capfc[1] * bunch_it->capfc[1]);
184 bunch_it->sigfc[1][2] =
185 (bunch_it->prodfc[1][2] / bunch_it->num[1][2]) - (bunch_it->capfc[1] * bunch_it->capfc[2]);
186 bunch_it->sigfc[1][3] =
187 (bunch_it->prodfc[1][3] / bunch_it->num[1][3]) - (bunch_it->capfc[1] * bunch_it->capfc[3]);
188 bunch_it->sigfc[2][0] =
189 (bunch_it->prodfc[2][0] / bunch_it->num[2][0]) - (bunch_it->capfc[2] * bunch_it->capfc[0]);
190 bunch_it->sigfc[2][1] =
191 (bunch_it->prodfc[2][1] / bunch_it->num[2][1]) - (bunch_it->capfc[2] * bunch_it->capfc[1]);
192 bunch_it->sigfc[2][2] =
193 (bunch_it->prodfc[2][2] / bunch_it->num[2][2]) - (bunch_it->capfc[2] * bunch_it->capfc[2]);
194 bunch_it->sigfc[2][3] =
195 (bunch_it->prodfc[2][3] / bunch_it->num[2][3]) - (bunch_it->capfc[2] * bunch_it->capfc[3]);
196 bunch_it->sigfc[3][0] =
197 (bunch_it->prodfc[3][0] / bunch_it->num[3][0]) - (bunch_it->capfc[3] * bunch_it->capfc[0]);
198 bunch_it->sigfc[3][1] =
199 (bunch_it->prodfc[3][1] / bunch_it->num[3][1]) - (bunch_it->capfc[3] * bunch_it->capfc[1]);
200 bunch_it->sigfc[3][2] =
201 (bunch_it->prodfc[3][2] / bunch_it->num[3][2]) - (bunch_it->capfc[3] * bunch_it->capfc[2]);
202 bunch_it->sigfc[3][3] =
203 (bunch_it->prodfc[3][3] / bunch_it->num[3][3]) - (bunch_it->capfc[3] * bunch_it->capfc[3]);
205 for (
int i = 0;
i != 3;
i++) {
212 int fillphi = bunch_it->detid.sector();
217 dephist->Fill(bunch_it->detid.module(),
219 (bunch_it->cap[0] + bunch_it->cap[1] + bunch_it->cap[2] + bunch_it->cap[3]) / 4);
229 bunch_it->sig[3][3]);
232 widthsp.
setSigma(0, 0, bunch_it->sig[0][0]);
233 widthsp.
setSigma(0, 1, bunch_it->sig[0][1]);
234 widthsp.
setSigma(0, 2, bunch_it->sig[0][2]);
235 widthsp.
setSigma(0, 3, bunch_it->sig[0][3]);
236 widthsp.
setSigma(1, 0, bunch_it->sig[1][0]);
237 widthsp.
setSigma(1, 1, bunch_it->sig[1][1]);
238 widthsp.
setSigma(1, 2, bunch_it->sig[1][2]);
239 widthsp.
setSigma(1, 3, bunch_it->sig[1][3]);
240 widthsp.
setSigma(2, 0, bunch_it->sig[2][0]);
241 widthsp.
setSigma(2, 1, bunch_it->sig[2][1]);
242 widthsp.
setSigma(2, 2, bunch_it->sig[2][2]);
243 widthsp.
setSigma(2, 3, bunch_it->sig[2][3]);
244 widthsp.
setSigma(3, 0, bunch_it->sig[3][0]);
245 widthsp.
setSigma(3, 1, bunch_it->sig[3][1]);
246 widthsp.
setSigma(3, 2, bunch_it->sig[3][2]);
247 widthsp.
setSigma(3, 3, bunch_it->sig[3][3]);
255 bunch_it->sigfc[0][0],
256 bunch_it->sigfc[1][1],
257 bunch_it->sigfc[2][2],
258 bunch_it->sigfc[3][3]);
261 widthspfc.
setSigma(0, 0, bunch_it->sigfc[0][0]);
262 widthspfc.
setSigma(0, 1, bunch_it->sigfc[0][1]);
263 widthspfc.
setSigma(0, 2, bunch_it->sigfc[0][2]);
264 widthspfc.
setSigma(0, 3, bunch_it->sigfc[0][3]);
265 widthspfc.
setSigma(1, 0, bunch_it->sigfc[1][0]);
266 widthspfc.
setSigma(1, 1, bunch_it->sigfc[1][1]);
267 widthspfc.
setSigma(1, 2, bunch_it->sigfc[1][2]);
268 widthspfc.
setSigma(1, 3, bunch_it->sigfc[1][3]);
269 widthspfc.
setSigma(2, 0, bunch_it->sigfc[2][0]);
270 widthspfc.
setSigma(2, 1, bunch_it->sigfc[2][1]);
271 widthspfc.
setSigma(2, 2, bunch_it->sigfc[2][2]);
272 widthspfc.
setSigma(2, 3, bunch_it->sigfc[2][3]);
273 widthspfc.
setSigma(3, 0, bunch_it->sigfc[3][0]);
274 widthspfc.
setSigma(3, 1, bunch_it->sigfc[3][1]);
275 widthspfc.
setSigma(3, 2, bunch_it->sigfc[3][2]);
276 widthspfc.
setSigma(3, 3, bunch_it->sigfc[3][3]);
309 dephist->SetDrawOption(
"colz");
310 dephist->GetXaxis()->SetTitle(
"module");
311 dephist->GetYaxis()->SetTitle(
"sector");
321 std::stringstream tempstringout;
323 std::string name1 = tempstringout.str() +
"_pedplots_1d.png";
324 std::string name2 = tempstringout.str() +
"_pedplots_2d.png";
326 TStyle* theStyle =
new TStyle(
"style",
"null");
327 theStyle->SetPalette(1,
nullptr);
328 theStyle->SetCanvasDefH(1200);
329 theStyle->SetCanvasDefW(1600);
376 std::stringstream tempstringout;
378 runnum_string = tempstringout.str();
384 XMLfilename = runnum_string +
"-peds_ADC_complete.xml";
385 XMLtag =
"Castor_pedestals_" + runnum_string;
396 CASTORMeans = fs->
make<TH1F>(
"All Ped Means CASTOR",
"All Ped Means CASTOR", 100, 0, 9);
397 CASTORWidths = fs->
make<TH1F>(
"All Ped Widths CASTOR",
"All Ped Widths CASTOR", 100, 0, 3);
399 dephist = fs->
make<TH2F>(
"Pedestals (ADC)",
"All Castor", 14, 0., 14.5, 16, .5, 16.5);
406 std::vector<HcalGenericDetId> listEMap = myRefEMap->
allPrecisionId();
407 for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); ++it) {
409 if (mygenid.isHcalCastorDetId()) {
415 for (
int i = 0;
i != 4;
i++) {
418 for (
int j = 0;
j != 4;
j++) {
432 std::vector<NewPedBunch>::iterator bunch_it;
436 for (bunch_it =
Bunches.begin(); bunch_it !=
Bunches.end(); ++bunch_it)
437 if (bunch_it->detid.rawId() == digi.
id().
rawId())
439 bunch_it->usedflag =
true;
445 bunch_it->capfc[digi.
sample(ts).
capid()] += charge1;
449 if ((ts + 1 < digi.
size()) && (ts + 1 <
lastTS)) {
456 if ((ts + 2 < digi.
size()) && (ts + 2 <
lastTS)) {
463 if ((ts + 3 < digi.
size()) && (ts + 3 <
lastTS)) {
static const std::string kSharedResource
T getUntrackedParameter(std::string const &, T const &) const
void setSigma(int fCapId1, int fCapId2, float fSigma)
std::vector< NewPedBunch > Bunches
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
#define DEFINE_FWK_MODULE(type)
const HcalQIESample & sample(int i) const
access a sample
constexpr uint32_t rawId() const
get the raw id
std::vector< T >::const_iterator const_iterator
T * make(const Args &...args) const
make new ROOT object
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_cond_
std::string widthsfCfilename
~CastorPedestalsAnalysis() override
bool getData(T &iHolder) const
edm::InputTag castorDigiCollectionTag
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
std::string widthsADCfilename
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
constexpr int adc() const
get the ADC sample
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
std::vector< HcalGenericDetId > allPrecisionId() const
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
std::string pedsADCfilename
CastorPedestalsAnalysis(const edm::ParameterSet &ps)
bool addValues(const Item &myItem)
constexpr int capid() const
get the Capacitor id
std::string pedsfCfilename
const HcalCastorDetId & id() const
int size() const
total number of samples in the digi
edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcd > tok_map_