CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::vector< NewPedBunchBunches
 
edm::InputTag castorDigiCollectionTag
 
TH1F * CASTORMeans
 
TH1F * CASTORWidths
 
TH2F * dephist
 
bool dumpXML
 
bool firsttime
 
int firstTS
 
bool hiSaveFlag
 
int lastTS
 
std::string pedsADCfilename
 
std::string pedsfCfilename
 
std::string ROOTfilename
 
int runnum
 
edm::ESGetToken
< CastorDbService,
CastorDbRecord
tok_cond_
 
edm::ESGetToken
< CastorElectronicsMap,
CastorElectronicsMapRcd
tok_map_
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 ( const edm::ParameterSet ps)

Definition at line 116 of file CastorPedestalsAnalysis.cc.

References dumpXML, firsttime, firstTS, edm::ParameterSet::getUntrackedParameter(), hiSaveFlag, TFileService::kSharedResource, lastTS, tok_cond_, tok_map_, and verboseflag.

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

Definition at line 131 of file CastorPedestalsAnalysis.cc.

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

131  {
132  CastorPedestals* rawPedsItem = new CastorPedestals(true);
133  CastorPedestalWidths* rawWidthsItem = new CastorPedestalWidths(true);
134  CastorPedestals* rawPedsItemfc = new CastorPedestals(false);
135  CastorPedestalWidths* rawWidthsItemfc = new CastorPedestalWidths(false);
136 
137  //Calculate pedestal constants
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) {
142  if (verboseflag)
143  std::cout << "Analyzing channel sector= " << bunch_it->detid.sector()
144  << " module = " << bunch_it->detid.module() << std::endl;
145  //pedestal constant is the mean
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];
154  //widths are the covariance matrix--assumed symmetric
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]);
171 
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]);
204 
205  for (int i = 0; i != 3; i++) {
206  CASTORMeans->Fill(bunch_it->cap[i]);
207  CASTORWidths->Fill(bunch_it->sig[i][i]);
208  }
209 
210  //if(bunch_it->detid.subdet() == 1){
211 
212  int fillphi = bunch_it->detid.sector();
213  //if (bunch_it->detid.depth()==4) fillphi++;
214 
215  // dephist[bunch_it->detid.module()-1]->Fill(bunch_it->detid.ieta(),fillphi,
216  // (bunch_it->cap[0]+bunch_it->cap[1]+bunch_it->cap[2]+bunch_it->cap[3])/4);
217  dephist->Fill(bunch_it->detid.module(),
218  fillphi,
219  (bunch_it->cap[0] + bunch_it->cap[1] + bunch_it->cap[2] + bunch_it->cap[3]) / 4);
220 
221  const CastorPedestal item(bunch_it->detid,
222  bunch_it->cap[0],
223  bunch_it->cap[1],
224  bunch_it->cap[2],
225  bunch_it->cap[3],
226  bunch_it->sig[0][0],
227  bunch_it->sig[1][1],
228  bunch_it->sig[2][2],
229  bunch_it->sig[3][3]);
230  rawPedsItem->addValues(item);
231  CastorPedestalWidth widthsp(bunch_it->detid);
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]);
248  rawWidthsItem->addValues(widthsp);
249 
250  const CastorPedestal itemfc(bunch_it->detid,
251  bunch_it->capfc[0],
252  bunch_it->capfc[1],
253  bunch_it->capfc[2],
254  bunch_it->capfc[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]);
259  rawPedsItemfc->addValues(itemfc);
260  CastorPedestalWidth widthspfc(bunch_it->detid);
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]);
277  rawWidthsItemfc->addValues(widthspfc);
278  }
279  }
280 
281  // dump the resulting list of pedestals into a file
282  std::ofstream outStream1(pedsADCfilename.c_str());
283  CastorDbASCIIIO::dumpObject(outStream1, (*rawPedsItem));
284  std::ofstream outStream2(widthsADCfilename.c_str());
285  CastorDbASCIIIO::dumpObject(outStream2, (*rawWidthsItem));
286 
287  std::ofstream outStream3(pedsfCfilename.c_str());
288  CastorDbASCIIIO::dumpObject(outStream3, (*rawPedsItemfc));
289  std::ofstream outStream4(widthsfCfilename.c_str());
290  CastorDbASCIIIO::dumpObject(outStream4, (*rawWidthsItemfc));
291 
292  if (dumpXML) {
293  std::ofstream outStream5(XMLfilename.c_str());
294  // CastorCondXML::dumpObject (outStream5, runnum, runnum, runnum, XMLtag, 1, (*rawPedsItem), (*rawWidthsItem));
295  }
296 
297  /*
298  if (hiSaveFlag) {
299  theFile->Write();
300  } else {
301  theFile->cd();
302  theFile->cd("CASTOR");
303  CASTORMeans->Write();
304  CASTORWidths->Write();
305  }
306  theFile->cd();
307  dephist->Write();
308  */
309  dephist->SetDrawOption("colz");
310  dephist->GetXaxis()->SetTitle("module");
311  dephist->GetYaxis()->SetTitle("sector");
312 
313  //for (int n=0; n!= 4; n++)
314  //{
315  //dephist[n]->Write();
316  //dephist[n]->SetDrawOption("colz");
317  //dephist[n]->GetXaxis()->SetTitle("i#eta");
318  //dephist[n]->GetYaxis()->SetTitle("i#phi");
319  //}
320 
321  std::stringstream tempstringout;
322  tempstringout << runnum;
323  std::string name1 = tempstringout.str() + "_pedplots_1d.png";
324  std::string name2 = tempstringout.str() + "_pedplots_2d.png";
325 
326  TStyle* theStyle = new TStyle("style", "null");
327  theStyle->SetPalette(1, nullptr);
328  theStyle->SetCanvasDefH(1200); //Height of canvas
329  theStyle->SetCanvasDefW(1600); //Width of canvas
330 
331  gStyle = theStyle;
332  /*
333  TCanvas * c1 = new TCanvas("c1","graph",1);
334  c1->Divide(2,2);
335  c1->cd(1);
336  CASTORMeans->Draw();
337  c1->SaveAs(name1.c_str());
338 
339  theStyle->SetOptStat("n");
340  gStyle = theStyle;
341 
342  TCanvas * c2 = new TCanvas("c2","graph",1);
343  // c2->Divide(2,2);
344  c2->cd(1);
345  dephist->Draw();
346  dephist->SetDrawOption("colz");
347  //c2->cd(2);
348  //dephist[1]->Draw();
349  //dephist[1]->SetDrawOption("colz");
350  //c2->cd(3);
351  //dephist[2]->Draw();
352  //dephist[2]->SetDrawOption("colz");
353  //c2->cd(4);
354  //dephist[3]->Draw();
355  //dephist[3]->SetDrawOption("colz");
356  c2->SaveAs(name2.c_str());
357 */
358  /*
359  std::cout << "Writing ROOT file... ";
360  theFile->Close();
361  std::cout << "ROOT file closed.\n";
362  */
363 }
std::vector< NewPedBunch > Bunches
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
bool addValues(const Item &myItem)
tuple cout
Definition: gather_cfg.py:144

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 366 of file CastorPedestalsAnalysis.cc.

References a, HcalQIESample::adc(), CastorElectronicsMap::allPrecisionId(), Bunches, NewPedBunch::cap, NewPedBunch::capfc, HcalQIESample::capid(), digitizers_cfi::castor, castorDigiCollectionTag, CASTORMeans, CASTORWidths, CastorQIECoder::charge(), submitPVValidationJobs::conditions, dephist, NewPedBunch::detid, firsttime, firstTS, compareTotals::fs, edm::Event::getByLabel(), edm::EventSetup::getData(), mps_fire::i, CastorDataFrame::id(), edm::EventBase::id(), dqmiolumiharvest::j, lastTS, TFileService::make(), TFileService::mkdir(), NewPedBunch::num, pedsADCfilename, pedsfCfilename, NewPedBunch::prod, NewPedBunch::prodfc, DetId::rawId(), ROOTfilename, edm::EventID::run(), runnum, CastorDataFrame::sample(), NewPedBunch::sig, NewPedBunch::sigfc, CastorDataFrame::size(), AlCaHLTBitMon_QueryRunRegistry::string, tok_cond_, tok_map_, NewPedBunch::usedflag, widthsADCfilename, widthsfCfilename, XMLfilename, and XMLtag.

366  {
368  e.getByLabel(castorDigiCollectionTag, castor);
369 
370  auto conditions = &iSetup.getData(tok_cond_);
371  const CastorQIEShape* shape = conditions->getCastorShape();
372 
373  if (firsttime) {
374  runnum = e.id().run();
375  std::string runnum_string;
376  std::stringstream tempstringout;
377  tempstringout << runnum;
378  runnum_string = tempstringout.str();
379  ROOTfilename = runnum_string + "-peds_ADC.root";
380  pedsADCfilename = runnum_string + "-peds_ADC.txt";
381  pedsfCfilename = runnum_string + "-peds_fC.txt";
382  widthsADCfilename = runnum_string + "-widths_ADC.txt";
383  widthsfCfilename = runnum_string + "-widths_fC.txt";
384  XMLfilename = runnum_string + "-peds_ADC_complete.xml";
385  XMLtag = "Castor_pedestals_" + runnum_string;
386 
388  fs->mkdir("CASTOR");
389  /*
390  theFile = new TFile(ROOTfilename.c_str(), "RECREATE");
391  theFile->cd();
392  // Create sub-directories
393  theFile->mkdir("CASTOR");
394  theFile->cd();
395  */
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);
398 
399  dephist = fs->make<TH2F>("Pedestals (ADC)", "All Castor", 14, 0., 14.5, 16, .5, 16.5);
400  // dephist[0] = fs->make<TH2F>("Pedestals (ADC)","Depth 1",89, -44, 44, 72, .5, 72.5);
401  // dephist[1] = fs->make<TH2F>("Pedestals (ADC)","Depth 2",89, -44, 44, 72, .5, 72.5);
402  // dephist[2] = fs->make<TH2F>("Pedestals (ADC)","Depth 3",89, -44, 44, 72, .5, 72.5);
403  // dephist[3] = fs->make<TH2F>("Pedestals (ADC)","Depth 4",89, -44, 44, 72, .5, 72.5);
404 
405  const CastorElectronicsMap* myRefEMap = &iSetup.getData(tok_map_);
406  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
407  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); ++it) {
408  HcalGenericDetId mygenid(it->rawId());
409  if (mygenid.isHcalCastorDetId()) {
410  NewPedBunch a;
411  HcalCastorDetId chanid(mygenid.rawId());
412  a.detid = chanid;
413  a.usedflag = false;
414  std::string type = "CASTOR";
415  for (int i = 0; i != 4; i++) {
416  a.cap[i] = 0;
417  a.capfc[i] = 0;
418  for (int j = 0; j != 4; j++) {
419  a.sig[i][j] = 0;
420  a.sigfc[i][j] = 0;
421  a.prod[i][j] = 0;
422  a.prodfc[i][j] = 0;
423  a.num[i][j] = 0;
424  }
425  }
426  Bunches.push_back(a);
427  }
428  }
429  firsttime = false;
430  }
431 
432  std::vector<NewPedBunch>::iterator bunch_it;
433 
434  for (CastorDigiCollection::const_iterator j = castor->begin(); j != castor->end(); ++j) {
435  const CastorDataFrame digi = (const CastorDataFrame)(*j);
436  for (bunch_it = Bunches.begin(); bunch_it != Bunches.end(); ++bunch_it)
437  if (bunch_it->detid.rawId() == digi.id().rawId())
438  break;
439  bunch_it->usedflag = true;
440  for (int ts = firstTS; ts != lastTS + 1; ts++) {
441  const CastorQIECoder* coder = conditions->getCastorCoder(digi.id().rawId());
442  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts).capid()] += 1;
443  bunch_it->cap[digi.sample(ts).capid()] += digi.sample(ts).adc();
444  double charge1 = coder->charge(*shape, digi.sample(ts).adc(), digi.sample(ts).capid());
445  bunch_it->capfc[digi.sample(ts).capid()] += charge1;
446  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts).capid()] +=
447  (digi.sample(ts).adc() * digi.sample(ts).adc());
448  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts).capid()] += charge1 * charge1;
449  if ((ts + 1 < digi.size()) && (ts + 1 < lastTS)) {
450  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] +=
451  digi.sample(ts).adc() * digi.sample(ts + 1).adc();
452  double charge2 = coder->charge(*shape, digi.sample(ts + 1).adc(), digi.sample(ts + 1).capid());
453  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] += charge1 * charge2;
454  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] += 1;
455  }
456  if ((ts + 2 < digi.size()) && (ts + 2 < lastTS)) {
457  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] +=
458  digi.sample(ts).adc() * digi.sample(ts + 2).adc();
459  double charge2 = coder->charge(*shape, digi.sample(ts + 2).adc(), digi.sample(ts + 2).capid());
460  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] += charge1 * charge2;
461  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] += 1;
462  }
463  if ((ts + 3 < digi.size()) && (ts + 3 < lastTS)) {
464  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] +=
465  digi.sample(ts).adc() * digi.sample(ts + 3).adc();
466  double charge2 = coder->charge(*shape, digi.sample(ts + 3).adc(), digi.sample(ts + 3).capid());
467  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] += charge1 * charge2;
468  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] += 1;
469  }
470  }
471  }
472 
473  //this is the last brace
474 }
std::vector< NewPedBunch > Bunches
const HcalQIESample & sample(int i) const
access a sample
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< T >::const_iterator const_iterator
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_cond_
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43
HcalCastorDetId detid
std::vector< HcalGenericDetId > allPrecisionId() const
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
double a
Definition: hdecay.h:119
const HcalCastorDetId & id() const
int size() const
total number of samples in the digi
edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcd > tok_map_

Member Data Documentation

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

Definition at line 85 of file CastorPedestalsAnalysis.cc.

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

edm::InputTag CastorPedestalsAnalysis::castorDigiCollectionTag
private

Definition at line 113 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

TH1F* CastorPedestalsAnalysis::CASTORMeans
private

Definition at line 105 of file CastorPedestalsAnalysis.cc.

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

TH1F* CastorPedestalsAnalysis::CASTORWidths
private

Definition at line 106 of file CastorPedestalsAnalysis.cc.

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

TH2F* CastorPedestalsAnalysis::dephist
private

Definition at line 109 of file CastorPedestalsAnalysis.cc.

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

bool CastorPedestalsAnalysis::dumpXML
private

Definition at line 88 of file CastorPedestalsAnalysis.cc.

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

bool CastorPedestalsAnalysis::firsttime
private

Definition at line 111 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and CastorPedestalsAnalysis().

int CastorPedestalsAnalysis::firstTS
private

Definition at line 91 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and CastorPedestalsAnalysis().

bool CastorPedestalsAnalysis::hiSaveFlag
private

Definition at line 87 of file CastorPedestalsAnalysis.cc.

Referenced by CastorPedestalsAnalysis().

int CastorPedestalsAnalysis::lastTS
private

Definition at line 92 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and CastorPedestalsAnalysis().

std::string CastorPedestalsAnalysis::pedsADCfilename
private

Definition at line 94 of file CastorPedestalsAnalysis.cc.

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

std::string CastorPedestalsAnalysis::pedsfCfilename
private

Definition at line 95 of file CastorPedestalsAnalysis.cc.

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

std::string CastorPedestalsAnalysis::ROOTfilename
private

Definition at line 93 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

int CastorPedestalsAnalysis::runnum
private

Definition at line 90 of file CastorPedestalsAnalysis.cc.

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

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

Definition at line 102 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and CastorPedestalsAnalysis().

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

Definition at line 103 of file CastorPedestalsAnalysis.cc.

Referenced by analyze(), and CastorPedestalsAnalysis().

bool CastorPedestalsAnalysis::verboseflag
private

Definition at line 89 of file CastorPedestalsAnalysis.cc.

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

std::string CastorPedestalsAnalysis::widthsADCfilename
private

Definition at line 96 of file CastorPedestalsAnalysis.cc.

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

std::string CastorPedestalsAnalysis::widthsfCfilename
private

Definition at line 97 of file CastorPedestalsAnalysis.cc.

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

std::string CastorPedestalsAnalysis::XMLfilename
private

Definition at line 98 of file CastorPedestalsAnalysis.cc.

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

std::string CastorPedestalsAnalysis::XMLtag
private

Definition at line 99 of file CastorPedestalsAnalysis.cc.

Referenced by analyze().

std::string CastorPedestalsAnalysis::ZSfilename
private

Definition at line 100 of file CastorPedestalsAnalysis.cc.