CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CastorPedestalsAnalysis Class Reference
Inheritance diagram for CastorPedestalsAnalysis:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
 CastorPedestalsAnalysis (const edm::ParameterSet &ps)
 
 ~CastorPedestalsAnalysis () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::vector< NewPedBunchBunches
 
const edm::EDGetTokenT< CastorDigiCollectioncastorDigiCollectionToken_
 
TH1F * CASTORMeans
 
TH1F * CASTORWidths
 
TH2F * dephist
 
const bool dumpXML
 
bool firsttime
 
const int firstTS
 
const bool hiSaveFlag
 
const int lastTS
 
std::string pedsADCfilename
 
std::string pedsfCfilename
 
std::string ROOTfilename
 
int runnum
 
const edm::ESGetToken< CastorDbService, CastorDbRecordtok_cond_
 
const edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcdtok_map_
 
const bool verboseflag
 
std::string widthsADCfilename
 
std::string widthsfCfilename
 
std::string XMLfilename
 
std::string XMLtag
 
std::string ZSfilename
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 74 of file CastorPedestalsAnalysis.cc.

Constructor & Destructor Documentation

◆ CastorPedestalsAnalysis()

CastorPedestalsAnalysis::CastorPedestalsAnalysis ( const edm::ParameterSet ps)

Definition at line 113 of file CastorPedestalsAnalysis.cc.

References firsttime, and TFileService::kSharedResource.

115  consumes<CastorDigiCollection>(ps.getParameter<edm::InputTag>("castorDigiCollectionTag"))),
116  tok_cond_(esConsumes<CastorDbService, CastorDbRecord>()),
117  tok_map_(esConsumes<CastorElectronicsMap, CastorElectronicsMapRcd>()),
118  hiSaveFlag(ps.getUntrackedParameter<bool>("hiSaveFlag", false)),
119  dumpXML(ps.getUntrackedParameter<bool>("dumpXML", false)),
120  verboseflag(ps.getUntrackedParameter<bool>("verbose", false)),
121  firstTS(ps.getUntrackedParameter<int>("firstTS", 0)),
122  lastTS(ps.getUntrackedParameter<int>("lastTS", 9)) {
123  usesResource(TFileService::kSharedResource);
124 
125  firsttime = true;
126 }
const edm::ESGetToken< CastorDbService, CastorDbRecord > tok_cond_
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T getUntrackedParameter(std::string const &, T const &) const
const edm::EDGetTokenT< CastorDigiCollection > castorDigiCollectionToken_
const edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcd > tok_map_

◆ ~CastorPedestalsAnalysis()

CastorPedestalsAnalysis::~CastorPedestalsAnalysis ( )
override

Definition at line 128 of file CastorPedestalsAnalysis.cc.

References CastorCondObjectContainer< Item >::addValues(), Bunches, CASTORMeans, CASTORWidths, gather_cfg::cout, dephist, CastorDbASCIIIO::dumpObject(), dumpXML, mps_fire::i, B2GTnPMonitor_cfi::item, hfnoseParametersInitialization_cfi::name2, pedsADCfilename, pedsfCfilename, runnum, CastorPedestalWidth::setSigma(), AlCaHLTBitMon_QueryRunRegistry::string, verboseflag, widthsADCfilename, widthsfCfilename, and XMLfilename.

128  {
129  CastorPedestals* rawPedsItem = new CastorPedestals(true);
130  CastorPedestalWidths* rawWidthsItem = new CastorPedestalWidths(true);
131  CastorPedestals* rawPedsItemfc = new CastorPedestals(false);
132  CastorPedestalWidths* rawWidthsItemfc = new CastorPedestalWidths(false);
133 
134  //Calculate pedestal constants
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) {
139  if (verboseflag)
140  std::cout << "Analyzing channel sector= " << bunch_it->detid.sector()
141  << " module = " << bunch_it->detid.module() << std::endl;
142  //pedestal constant is the mean
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];
151  //widths are the covariance matrix--assumed symmetric
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]);
168 
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]);
201 
202  for (int i = 0; i != 3; i++) {
203  CASTORMeans->Fill(bunch_it->cap[i]);
204  CASTORWidths->Fill(bunch_it->sig[i][i]);
205  }
206 
207  //if(bunch_it->detid.subdet() == 1){
208 
209  int fillphi = bunch_it->detid.sector();
210  //if (bunch_it->detid.depth()==4) fillphi++;
211 
212  // dephist[bunch_it->detid.module()-1]->Fill(bunch_it->detid.ieta(),fillphi,
213  // (bunch_it->cap[0]+bunch_it->cap[1]+bunch_it->cap[2]+bunch_it->cap[3])/4);
214  dephist->Fill(bunch_it->detid.module(),
215  fillphi,
216  (bunch_it->cap[0] + bunch_it->cap[1] + bunch_it->cap[2] + bunch_it->cap[3]) / 4);
217 
218  const CastorPedestal item(bunch_it->detid,
219  bunch_it->cap[0],
220  bunch_it->cap[1],
221  bunch_it->cap[2],
222  bunch_it->cap[3],
223  bunch_it->sig[0][0],
224  bunch_it->sig[1][1],
225  bunch_it->sig[2][2],
226  bunch_it->sig[3][3]);
227  rawPedsItem->addValues(item);
228  CastorPedestalWidth widthsp(bunch_it->detid);
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]);
245  rawWidthsItem->addValues(widthsp);
246 
247  const CastorPedestal itemfc(bunch_it->detid,
248  bunch_it->capfc[0],
249  bunch_it->capfc[1],
250  bunch_it->capfc[2],
251  bunch_it->capfc[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]);
256  rawPedsItemfc->addValues(itemfc);
257  CastorPedestalWidth widthspfc(bunch_it->detid);
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]);
274  rawWidthsItemfc->addValues(widthspfc);
275  }
276  }
277 
278  // dump the resulting list of pedestals into a file
279  std::ofstream outStream1(pedsADCfilename.c_str());
280  CastorDbASCIIIO::dumpObject(outStream1, (*rawPedsItem));
281  std::ofstream outStream2(widthsADCfilename.c_str());
282  CastorDbASCIIIO::dumpObject(outStream2, (*rawWidthsItem));
283 
284  std::ofstream outStream3(pedsfCfilename.c_str());
285  CastorDbASCIIIO::dumpObject(outStream3, (*rawPedsItemfc));
286  std::ofstream outStream4(widthsfCfilename.c_str());
287  CastorDbASCIIIO::dumpObject(outStream4, (*rawWidthsItemfc));
288 
289  if (dumpXML) {
290  std::ofstream outStream5(XMLfilename.c_str());
291  // CastorCondXML::dumpObject (outStream5, runnum, runnum, runnum, XMLtag, 1, (*rawPedsItem), (*rawWidthsItem));
292  }
293 
294  dephist->SetDrawOption("colz");
295  dephist->GetXaxis()->SetTitle("module");
296  dephist->GetYaxis()->SetTitle("sector");
297 
298  std::stringstream tempstringout;
299  tempstringout << runnum;
300  std::string name1 = tempstringout.str() + "_pedplots_1d.png";
301  std::string name2 = tempstringout.str() + "_pedplots_2d.png";
302 
303  TStyle* theStyle = new TStyle("style", "null");
304  theStyle->SetPalette(1, nullptr);
305  theStyle->SetCanvasDefH(1200); //Height of canvas
306  theStyle->SetCanvasDefW(1600); //Width of canvas
307 
308  gStyle = theStyle;
309  /*
310  TCanvas * c1 = new TCanvas("c1","graph",1);
311  c1->Divide(2,2);
312  c1->cd(1);
313  CASTORMeans->Draw();
314  c1->SaveAs(name1.c_str());
315 
316  theStyle->SetOptStat("n");
317  gStyle = theStyle;
318 
319  TCanvas * c2 = new TCanvas("c2","graph",1);
320  // c2->Divide(2,2);
321  c2->cd(1);
322  dephist->Draw();
323  dephist->SetDrawOption("colz");
324  //c2->cd(2);
325  //dephist[1]->Draw();
326  //dephist[1]->SetDrawOption("colz");
327  //c2->cd(3);
328  //dephist[2]->Draw();
329  //dephist[2]->SetDrawOption("colz");
330  //c2->cd(4);
331  //dephist[3]->Draw();
332  //dephist[3]->SetDrawOption("colz");
333  c2->SaveAs(name2.c_str());
334 */
335  /*
336  std::cout << "Writing ROOT file... ";
337  theFile->Close();
338  std::cout << "ROOT file closed.\n";
339  */
340 }
std::vector< NewPedBunch > Bunches
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
bool addValues(const Item &myItem)

Member Function Documentation

◆ analyze()

void CastorPedestalsAnalysis::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 343 of file CastorPedestalsAnalysis.cc.

References a, HcalQIESample::adc(), CastorElectronicsMap::allPrecisionId(), Bunches, HcalQIESample::capid(), castorDigitizer_cfi::castor, castorDigiCollectionToken_, CASTORMeans, CASTORWidths, CastorQIECoder::charge(), submitPVValidationJobs::conditions, dephist, MillePedeFileConverter_cfg::e, firsttime, firstTS, compareTotals::fs, edm::EventSetup::getData(), mps_fire::i, CastorDataFrame::id(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, lastTS, pedsADCfilename, pedsfCfilename, DetId::rawId(), ROOTfilename, runnum, CastorDataFrame::sample(), l1trig_cff::shape, CastorDataFrame::size(), AlCaHLTBitMon_QueryRunRegistry::string, tok_cond_, tok_map_, widthsADCfilename, widthsfCfilename, XMLfilename, and XMLtag.

343  {
345 
346  auto conditions = &iSetup.getData(tok_cond_);
347  const CastorQIEShape* shape = conditions->getCastorShape();
348 
349  if (firsttime) {
350  runnum = e.id().run();
351  std::string runnum_string;
352  std::stringstream tempstringout;
353  tempstringout << runnum;
354  runnum_string = tempstringout.str();
355  ROOTfilename = runnum_string + "-peds_ADC.root";
356  pedsADCfilename = runnum_string + "-peds_ADC.txt";
357  pedsfCfilename = runnum_string + "-peds_fC.txt";
358  widthsADCfilename = runnum_string + "-widths_ADC.txt";
359  widthsfCfilename = runnum_string + "-widths_fC.txt";
360  XMLfilename = runnum_string + "-peds_ADC_complete.xml";
361  XMLtag = "Castor_pedestals_" + runnum_string;
362 
364  fs->mkdir("CASTOR");
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);
367 
368  dephist = fs->make<TH2F>("Pedestals (ADC)", "All Castor", 14, 0., 14.5, 16, .5, 16.5);
369 
370  const CastorElectronicsMap* myRefEMap = &iSetup.getData(tok_map_);
371  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
372  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); ++it) {
373  HcalGenericDetId mygenid(it->rawId());
374  if (mygenid.isHcalCastorDetId()) {
375  NewPedBunch a;
376  HcalCastorDetId chanid(mygenid.rawId());
377  a.detid = chanid;
378  a.usedflag = false;
379  std::string type = "CASTOR";
380  for (int i = 0; i != 4; i++) {
381  a.cap[i] = 0;
382  a.capfc[i] = 0;
383  for (int j = 0; j != 4; j++) {
384  a.sig[i][j] = 0;
385  a.sigfc[i][j] = 0;
386  a.prod[i][j] = 0;
387  a.prodfc[i][j] = 0;
388  a.num[i][j] = 0;
389  }
390  }
391  Bunches.push_back(a);
392  }
393  }
394  firsttime = false;
395  }
396 
397  std::vector<NewPedBunch>::iterator bunch_it;
398 
399  for (CastorDigiCollection::const_iterator j = castor->begin(); j != castor->end(); ++j) {
400  const CastorDataFrame digi = (const CastorDataFrame)(*j);
401  for (bunch_it = Bunches.begin(); bunch_it != Bunches.end(); ++bunch_it)
402  if (bunch_it->detid.rawId() == digi.id().rawId())
403  break;
404  bunch_it->usedflag = true;
405  for (int ts = firstTS; ts != lastTS + 1; ts++) {
406  const CastorQIECoder* coder = conditions->getCastorCoder(digi.id().rawId());
407  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts).capid()] += 1;
408  bunch_it->cap[digi.sample(ts).capid()] += digi.sample(ts).adc();
409  double charge1 = coder->charge(*shape, digi.sample(ts).adc(), digi.sample(ts).capid());
410  bunch_it->capfc[digi.sample(ts).capid()] += charge1;
411  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts).capid()] +=
412  (digi.sample(ts).adc() * digi.sample(ts).adc());
413  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts).capid()] += charge1 * charge1;
414  if ((ts + 1 < digi.size()) && (ts + 1 < lastTS)) {
415  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] +=
416  digi.sample(ts).adc() * digi.sample(ts + 1).adc();
417  double charge2 = coder->charge(*shape, digi.sample(ts + 1).adc(), digi.sample(ts + 1).capid());
418  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] += charge1 * charge2;
419  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] += 1;
420  }
421  if ((ts + 2 < digi.size()) && (ts + 2 < lastTS)) {
422  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] +=
423  digi.sample(ts).adc() * digi.sample(ts + 2).adc();
424  double charge2 = coder->charge(*shape, digi.sample(ts + 2).adc(), digi.sample(ts + 2).capid());
425  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] += charge1 * charge2;
426  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] += 1;
427  }
428  if ((ts + 3 < digi.size()) && (ts + 3 < lastTS)) {
429  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] +=
430  digi.sample(ts).adc() * digi.sample(ts + 3).adc();
431  double charge2 = coder->charge(*shape, digi.sample(ts + 3).adc(), digi.sample(ts + 3).capid());
432  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] += charge1 * charge2;
433  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] += 1;
434  }
435  }
436  }
437 
438  //this is the last brace
439 }
const edm::ESGetToken< CastorDbService, CastorDbRecord > tok_cond_
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
std::vector< NewPedBunch > Bunches
const HcalQIESample & sample(int i) const
access a sample
std::vector< T >::const_iterator const_iterator
int size() const
total number of samples in the digi
const HcalCastorDetId & id() const
std::vector< HcalGenericDetId > allPrecisionId() const
const edm::EDGetTokenT< CastorDigiCollection > castorDigiCollectionToken_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcd > tok_map_
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43
double a
Definition: hdecay.h:121

Member Data Documentation

◆ Bunches

std::vector<NewPedBunch> CastorPedestalsAnalysis::Bunches
private

Definition at line 85 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ castorDigiCollectionToken_

const edm::EDGetTokenT<CastorDigiCollection> CastorPedestalsAnalysis::castorDigiCollectionToken_
private

Definition at line 86 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

◆ CASTORMeans

TH1F* CastorPedestalsAnalysis::CASTORMeans
private

Definition at line 106 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ CASTORWidths

TH1F* CastorPedestalsAnalysis::CASTORWidths
private

Definition at line 107 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ dephist

TH2F* CastorPedestalsAnalysis::dephist
private

Definition at line 110 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ dumpXML

const bool CastorPedestalsAnalysis::dumpXML
private

Definition at line 91 of file CastorPedestalsAnalysis.cc.

Referenced by ~CastorPedestalsAnalysis().

◆ firsttime

bool CastorPedestalsAnalysis::firsttime
private

Definition at line 95 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and CastorPedestalsAnalysis().

◆ firstTS

const int CastorPedestalsAnalysis::firstTS
private

Definition at line 93 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

◆ hiSaveFlag

const bool CastorPedestalsAnalysis::hiSaveFlag
private

Definition at line 90 of file CastorPedestalsAnalysis.cc.

◆ lastTS

const int CastorPedestalsAnalysis::lastTS
private

Definition at line 94 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

◆ pedsADCfilename

std::string CastorPedestalsAnalysis::pedsADCfilename
private

Definition at line 98 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ pedsfCfilename

std::string CastorPedestalsAnalysis::pedsfCfilename
private

Definition at line 99 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ ROOTfilename

std::string CastorPedestalsAnalysis::ROOTfilename
private

Definition at line 97 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

◆ runnum

int CastorPedestalsAnalysis::runnum
private

Definition at line 96 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ tok_cond_

const edm::ESGetToken<CastorDbService, CastorDbRecord> CastorPedestalsAnalysis::tok_cond_
private

Definition at line 87 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

◆ tok_map_

const edm::ESGetToken<CastorElectronicsMap, CastorElectronicsMapRcd> CastorPedestalsAnalysis::tok_map_
private

Definition at line 88 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

◆ verboseflag

const bool CastorPedestalsAnalysis::verboseflag
private

Definition at line 92 of file CastorPedestalsAnalysis.cc.

Referenced by ~CastorPedestalsAnalysis().

◆ widthsADCfilename

std::string CastorPedestalsAnalysis::widthsADCfilename
private

Definition at line 100 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ widthsfCfilename

std::string CastorPedestalsAnalysis::widthsfCfilename
private

Definition at line 101 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ XMLfilename

std::string CastorPedestalsAnalysis::XMLfilename
private

Definition at line 102 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and ~CastorPedestalsAnalysis().

◆ XMLtag

std::string CastorPedestalsAnalysis::XMLtag
private

Definition at line 103 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

◆ ZSfilename

std::string CastorPedestalsAnalysis::ZSfilename
private

Definition at line 104 of file CastorPedestalsAnalysis.cc.