CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CastorPedestalsAnalysis Class Reference

#include <CastorPedestalsAnalysis.h>

Inheritance diagram for CastorPedestalsAnalysis:
edm::EDAnalyzer 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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
 
TFile * theFile
 
edm::ESGetToken< CastorDbService, CastorDbRecordtok_cond_
 
edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcdtok_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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 71 of file CastorPedestalsAnalysis.h.

Constructor & Destructor Documentation

◆ CastorPedestalsAnalysis()

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

Definition at line 11 of file CastorPedestalsAnalysis.cc.

12  : castorDigiCollectionTag(ps.getParameter<edm::InputTag>("castorDigiCollectionTag")) {
13  hiSaveFlag = ps.getUntrackedParameter<bool>("hiSaveFlag", false);
14  dumpXML = ps.getUntrackedParameter<bool>("dumpXML", false);
15  verboseflag = ps.getUntrackedParameter<bool>("verbose", false);
16  firstTS = ps.getUntrackedParameter<int>("firstTS", 0);
17  lastTS = ps.getUntrackedParameter<int>("lastTS", 9);
18  firsttime = true;
19 
20  tok_cond_ = esConsumes<CastorDbService, CastorDbRecord>();
21  tok_map_ = esConsumes<CastorElectronicsMap, CastorElectronicsMapRcd>();
22 }

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

◆ ~CastorPedestalsAnalysis()

CastorPedestalsAnalysis::~CastorPedestalsAnalysis ( )
override

Definition at line 24 of file CastorPedestalsAnalysis.cc.

24  {
25  CastorPedestals* rawPedsItem = new CastorPedestals(true);
26  CastorPedestalWidths* rawWidthsItem = new CastorPedestalWidths(true);
27  CastorPedestals* rawPedsItemfc = new CastorPedestals(false);
28  CastorPedestalWidths* rawWidthsItemfc = new CastorPedestalWidths(false);
29 
30  //Calculate pedestal constants
31  std::cout << "Calculating Pedestal constants...\n";
32  std::vector<NewPedBunch>::iterator bunch_it;
33  for (bunch_it = Bunches.begin(); bunch_it != Bunches.end(); ++bunch_it) {
34  if (bunch_it->usedflag) {
35  if (verboseflag)
36  std::cout << "Analyzing channel sector= " << bunch_it->detid.sector()
37  << " module = " << bunch_it->detid.module() << std::endl;
38  //pedestal constant is the mean
39  bunch_it->cap[0] /= bunch_it->num[0][0];
40  bunch_it->cap[1] /= bunch_it->num[1][1];
41  bunch_it->cap[2] /= bunch_it->num[2][2];
42  bunch_it->cap[3] /= bunch_it->num[3][3];
43  bunch_it->capfc[0] /= bunch_it->num[0][0];
44  bunch_it->capfc[1] /= bunch_it->num[1][1];
45  bunch_it->capfc[2] /= bunch_it->num[2][2];
46  bunch_it->capfc[3] /= bunch_it->num[3][3];
47  //widths are the covariance matrix--assumed symmetric
48  bunch_it->sig[0][0] = (bunch_it->prod[0][0] / bunch_it->num[0][0]) - (bunch_it->cap[0] * bunch_it->cap[0]);
49  bunch_it->sig[0][1] = (bunch_it->prod[0][1] / bunch_it->num[0][1]) - (bunch_it->cap[0] * bunch_it->cap[1]);
50  bunch_it->sig[0][2] = (bunch_it->prod[0][2] / bunch_it->num[0][2]) - (bunch_it->cap[0] * bunch_it->cap[2]);
51  bunch_it->sig[0][3] = (bunch_it->prod[0][3] / bunch_it->num[0][3]) - (bunch_it->cap[0] * bunch_it->cap[3]);
52  bunch_it->sig[1][0] = (bunch_it->prod[1][0] / bunch_it->num[1][0]) - (bunch_it->cap[1] * bunch_it->cap[0]);
53  bunch_it->sig[1][1] = (bunch_it->prod[1][1] / bunch_it->num[1][1]) - (bunch_it->cap[1] * bunch_it->cap[1]);
54  bunch_it->sig[1][2] = (bunch_it->prod[1][2] / bunch_it->num[1][2]) - (bunch_it->cap[1] * bunch_it->cap[2]);
55  bunch_it->sig[1][3] = (bunch_it->prod[1][3] / bunch_it->num[1][3]) - (bunch_it->cap[1] * bunch_it->cap[3]);
56  bunch_it->sig[2][0] = (bunch_it->prod[2][0] / bunch_it->num[2][0]) - (bunch_it->cap[2] * bunch_it->cap[0]);
57  bunch_it->sig[2][1] = (bunch_it->prod[2][1] / bunch_it->num[2][1]) - (bunch_it->cap[2] * bunch_it->cap[1]);
58  bunch_it->sig[2][2] = (bunch_it->prod[2][2] / bunch_it->num[2][2]) - (bunch_it->cap[2] * bunch_it->cap[2]);
59  bunch_it->sig[2][3] = (bunch_it->prod[2][3] / bunch_it->num[2][3]) - (bunch_it->cap[2] * bunch_it->cap[3]);
60  bunch_it->sig[3][0] = (bunch_it->prod[3][0] / bunch_it->num[3][0]) - (bunch_it->cap[3] * bunch_it->cap[0]);
61  bunch_it->sig[3][1] = (bunch_it->prod[3][1] / bunch_it->num[3][1]) - (bunch_it->cap[3] * bunch_it->cap[1]);
62  bunch_it->sig[3][2] = (bunch_it->prod[3][2] / bunch_it->num[3][2]) - (bunch_it->cap[3] * bunch_it->cap[2]);
63  bunch_it->sig[3][3] = (bunch_it->prod[3][3] / bunch_it->num[3][3]) - (bunch_it->cap[3] * bunch_it->cap[3]);
64 
65  bunch_it->sigfc[0][0] =
66  (bunch_it->prodfc[0][0] / bunch_it->num[0][0]) - (bunch_it->capfc[0] * bunch_it->capfc[0]);
67  bunch_it->sigfc[0][1] =
68  (bunch_it->prodfc[0][1] / bunch_it->num[0][1]) - (bunch_it->capfc[0] * bunch_it->capfc[1]);
69  bunch_it->sigfc[0][2] =
70  (bunch_it->prodfc[0][2] / bunch_it->num[0][2]) - (bunch_it->capfc[0] * bunch_it->capfc[2]);
71  bunch_it->sigfc[0][3] =
72  (bunch_it->prodfc[0][3] / bunch_it->num[0][3]) - (bunch_it->capfc[0] * bunch_it->capfc[3]);
73  bunch_it->sigfc[1][0] =
74  (bunch_it->prodfc[1][0] / bunch_it->num[1][0]) - (bunch_it->capfc[1] * bunch_it->capfc[0]);
75  bunch_it->sigfc[1][1] =
76  (bunch_it->prodfc[1][1] / bunch_it->num[1][1]) - (bunch_it->capfc[1] * bunch_it->capfc[1]);
77  bunch_it->sigfc[1][2] =
78  (bunch_it->prodfc[1][2] / bunch_it->num[1][2]) - (bunch_it->capfc[1] * bunch_it->capfc[2]);
79  bunch_it->sigfc[1][3] =
80  (bunch_it->prodfc[1][3] / bunch_it->num[1][3]) - (bunch_it->capfc[1] * bunch_it->capfc[3]);
81  bunch_it->sigfc[2][0] =
82  (bunch_it->prodfc[2][0] / bunch_it->num[2][0]) - (bunch_it->capfc[2] * bunch_it->capfc[0]);
83  bunch_it->sigfc[2][1] =
84  (bunch_it->prodfc[2][1] / bunch_it->num[2][1]) - (bunch_it->capfc[2] * bunch_it->capfc[1]);
85  bunch_it->sigfc[2][2] =
86  (bunch_it->prodfc[2][2] / bunch_it->num[2][2]) - (bunch_it->capfc[2] * bunch_it->capfc[2]);
87  bunch_it->sigfc[2][3] =
88  (bunch_it->prodfc[2][3] / bunch_it->num[2][3]) - (bunch_it->capfc[2] * bunch_it->capfc[3]);
89  bunch_it->sigfc[3][0] =
90  (bunch_it->prodfc[3][0] / bunch_it->num[3][0]) - (bunch_it->capfc[3] * bunch_it->capfc[0]);
91  bunch_it->sigfc[3][1] =
92  (bunch_it->prodfc[3][1] / bunch_it->num[3][1]) - (bunch_it->capfc[3] * bunch_it->capfc[1]);
93  bunch_it->sigfc[3][2] =
94  (bunch_it->prodfc[3][2] / bunch_it->num[3][2]) - (bunch_it->capfc[3] * bunch_it->capfc[2]);
95  bunch_it->sigfc[3][3] =
96  (bunch_it->prodfc[3][3] / bunch_it->num[3][3]) - (bunch_it->capfc[3] * bunch_it->capfc[3]);
97 
98  for (int i = 0; i != 3; i++) {
99  CASTORMeans->Fill(bunch_it->cap[i]);
100  CASTORWidths->Fill(bunch_it->sig[i][i]);
101  }
102 
103  //if(bunch_it->detid.subdet() == 1){
104 
105  int fillphi = bunch_it->detid.sector();
106  //if (bunch_it->detid.depth()==4) fillphi++;
107 
108  // dephist[bunch_it->detid.module()-1]->Fill(bunch_it->detid.ieta(),fillphi,
109  // (bunch_it->cap[0]+bunch_it->cap[1]+bunch_it->cap[2]+bunch_it->cap[3])/4);
110  dephist->Fill(bunch_it->detid.module(),
111  fillphi,
112  (bunch_it->cap[0] + bunch_it->cap[1] + bunch_it->cap[2] + bunch_it->cap[3]) / 4);
113 
114  const CastorPedestal item(bunch_it->detid,
115  bunch_it->cap[0],
116  bunch_it->cap[1],
117  bunch_it->cap[2],
118  bunch_it->cap[3],
119  bunch_it->sig[0][0],
120  bunch_it->sig[1][1],
121  bunch_it->sig[2][2],
122  bunch_it->sig[3][3]);
123  rawPedsItem->addValues(item);
124  CastorPedestalWidth widthsp(bunch_it->detid);
125  widthsp.setSigma(0, 0, bunch_it->sig[0][0]);
126  widthsp.setSigma(0, 1, bunch_it->sig[0][1]);
127  widthsp.setSigma(0, 2, bunch_it->sig[0][2]);
128  widthsp.setSigma(0, 3, bunch_it->sig[0][3]);
129  widthsp.setSigma(1, 0, bunch_it->sig[1][0]);
130  widthsp.setSigma(1, 1, bunch_it->sig[1][1]);
131  widthsp.setSigma(1, 2, bunch_it->sig[1][2]);
132  widthsp.setSigma(1, 3, bunch_it->sig[1][3]);
133  widthsp.setSigma(2, 0, bunch_it->sig[2][0]);
134  widthsp.setSigma(2, 1, bunch_it->sig[2][1]);
135  widthsp.setSigma(2, 2, bunch_it->sig[2][2]);
136  widthsp.setSigma(2, 3, bunch_it->sig[2][3]);
137  widthsp.setSigma(3, 0, bunch_it->sig[3][0]);
138  widthsp.setSigma(3, 1, bunch_it->sig[3][1]);
139  widthsp.setSigma(3, 2, bunch_it->sig[3][2]);
140  widthsp.setSigma(3, 3, bunch_it->sig[3][3]);
141  rawWidthsItem->addValues(widthsp);
142 
143  const CastorPedestal itemfc(bunch_it->detid,
144  bunch_it->capfc[0],
145  bunch_it->capfc[1],
146  bunch_it->capfc[2],
147  bunch_it->capfc[3],
148  bunch_it->sigfc[0][0],
149  bunch_it->sigfc[1][1],
150  bunch_it->sigfc[2][2],
151  bunch_it->sigfc[3][3]);
152  rawPedsItemfc->addValues(itemfc);
153  CastorPedestalWidth widthspfc(bunch_it->detid);
154  widthspfc.setSigma(0, 0, bunch_it->sigfc[0][0]);
155  widthspfc.setSigma(0, 1, bunch_it->sigfc[0][1]);
156  widthspfc.setSigma(0, 2, bunch_it->sigfc[0][2]);
157  widthspfc.setSigma(0, 3, bunch_it->sigfc[0][3]);
158  widthspfc.setSigma(1, 0, bunch_it->sigfc[1][0]);
159  widthspfc.setSigma(1, 1, bunch_it->sigfc[1][1]);
160  widthspfc.setSigma(1, 2, bunch_it->sigfc[1][2]);
161  widthspfc.setSigma(1, 3, bunch_it->sigfc[1][3]);
162  widthspfc.setSigma(2, 0, bunch_it->sigfc[2][0]);
163  widthspfc.setSigma(2, 1, bunch_it->sigfc[2][1]);
164  widthspfc.setSigma(2, 2, bunch_it->sigfc[2][2]);
165  widthspfc.setSigma(2, 3, bunch_it->sigfc[2][3]);
166  widthspfc.setSigma(3, 0, bunch_it->sigfc[3][0]);
167  widthspfc.setSigma(3, 1, bunch_it->sigfc[3][1]);
168  widthspfc.setSigma(3, 2, bunch_it->sigfc[3][2]);
169  widthspfc.setSigma(3, 3, bunch_it->sigfc[3][3]);
170  rawWidthsItemfc->addValues(widthspfc);
171  }
172  }
173 
174  // dump the resulting list of pedestals into a file
175  std::ofstream outStream1(pedsADCfilename.c_str());
176  CastorDbASCIIIO::dumpObject(outStream1, (*rawPedsItem));
177  std::ofstream outStream2(widthsADCfilename.c_str());
178  CastorDbASCIIIO::dumpObject(outStream2, (*rawWidthsItem));
179 
180  std::ofstream outStream3(pedsfCfilename.c_str());
181  CastorDbASCIIIO::dumpObject(outStream3, (*rawPedsItemfc));
182  std::ofstream outStream4(widthsfCfilename.c_str());
183  CastorDbASCIIIO::dumpObject(outStream4, (*rawWidthsItemfc));
184 
185  if (dumpXML) {
186  std::ofstream outStream5(XMLfilename.c_str());
187  // CastorCondXML::dumpObject (outStream5, runnum, runnum, runnum, XMLtag, 1, (*rawPedsItem), (*rawWidthsItem));
188  }
189 
190  if (hiSaveFlag) {
191  theFile->Write();
192  } else {
193  theFile->cd();
194  theFile->cd("CASTOR");
195  CASTORMeans->Write();
196  CASTORWidths->Write();
197  }
198  theFile->cd();
199  dephist->Write();
200  dephist->SetDrawOption("colz");
201  dephist->GetXaxis()->SetTitle("module");
202  dephist->GetYaxis()->SetTitle("sector");
203 
204  //for (int n=0; n!= 4; n++)
205  //{
206  //dephist[n]->Write();
207  //dephist[n]->SetDrawOption("colz");
208  //dephist[n]->GetXaxis()->SetTitle("i#eta");
209  //dephist[n]->GetYaxis()->SetTitle("i#phi");
210  //}
211 
212  std::stringstream tempstringout;
213  tempstringout << runnum;
214  std::string name1 = tempstringout.str() + "_pedplots_1d.png";
215  std::string name2 = tempstringout.str() + "_pedplots_2d.png";
216 
217  TStyle* theStyle = new TStyle("style", "null");
218  theStyle->SetPalette(1, nullptr);
219  theStyle->SetCanvasDefH(1200); //Height of canvas
220  theStyle->SetCanvasDefW(1600); //Width of canvas
221 
222  gStyle = theStyle;
223  /*
224  TCanvas * c1 = new TCanvas("c1","graph",1);
225  c1->Divide(2,2);
226  c1->cd(1);
227  CASTORMeans->Draw();
228  c1->SaveAs(name1.c_str());
229 
230  theStyle->SetOptStat("n");
231  gStyle = theStyle;
232 
233  TCanvas * c2 = new TCanvas("c2","graph",1);
234  // c2->Divide(2,2);
235  c2->cd(1);
236  dephist->Draw();
237  dephist->SetDrawOption("colz");
238  //c2->cd(2);
239  //dephist[1]->Draw();
240  //dephist[1]->SetDrawOption("colz");
241  //c2->cd(3);
242  //dephist[2]->Draw();
243  //dephist[2]->SetDrawOption("colz");
244  //c2->cd(4);
245  //dephist[3]->Draw();
246  //dephist[3]->SetDrawOption("colz");
247  c2->SaveAs(name2.c_str());
248 */
249  std::cout << "Writing ROOT file... ";
250  theFile->Close();
251  std::cout << "ROOT file closed.\n";
252 }

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

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 255 of file CastorPedestalsAnalysis.cc.

255  {
257  e.getByLabel(castorDigiCollectionTag, castor);
258 
259  auto conditions = &iSetup.getData(tok_cond_);
260  const CastorQIEShape* shape = conditions->getCastorShape();
261 
262  if (firsttime) {
263  runnum = e.id().run();
264  std::string runnum_string;
265  std::stringstream tempstringout;
266  tempstringout << runnum;
267  runnum_string = tempstringout.str();
268  ROOTfilename = runnum_string + "-peds_ADC.root";
269  pedsADCfilename = runnum_string + "-peds_ADC.txt";
270  pedsfCfilename = runnum_string + "-peds_fC.txt";
271  widthsADCfilename = runnum_string + "-widths_ADC.txt";
272  widthsfCfilename = runnum_string + "-widths_fC.txt";
273  XMLfilename = runnum_string + "-peds_ADC_complete.xml";
274  XMLtag = "Castor_pedestals_" + runnum_string;
275 
276  theFile = new TFile(ROOTfilename.c_str(), "RECREATE");
277  theFile->cd();
278  // Create sub-directories
279  theFile->mkdir("CASTOR");
280  theFile->cd();
281 
282  CASTORMeans = new TH1F("All Ped Means CASTOR", "All Ped Means CASTOR", 100, 0, 9);
283  CASTORWidths = new TH1F("All Ped Widths CASTOR", "All Ped Widths CASTOR", 100, 0, 3);
284 
285  dephist = new TH2F("Pedestals (ADC)", "All Castor", 14, 0., 14.5, 16, .5, 16.5);
286  // dephist[0] = new TH2F("Pedestals (ADC)","Depth 1",89, -44, 44, 72, .5, 72.5);
287  // dephist[1] = new TH2F("Pedestals (ADC)","Depth 2",89, -44, 44, 72, .5, 72.5);
288  // dephist[2] = new TH2F("Pedestals (ADC)","Depth 3",89, -44, 44, 72, .5, 72.5);
289  // dephist[3] = new TH2F("Pedestals (ADC)","Depth 4",89, -44, 44, 72, .5, 72.5);
290 
291  const CastorElectronicsMap* myRefEMap = &iSetup.getData(tok_map_);
292  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
293  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); ++it) {
294  HcalGenericDetId mygenid(it->rawId());
295  if (mygenid.isHcalCastorDetId()) {
296  NewPedBunch a;
297  HcalCastorDetId chanid(mygenid.rawId());
298  a.detid = chanid;
299  a.usedflag = false;
300  std::string type = "CASTOR";
301  for (int i = 0; i != 4; i++) {
302  a.cap[i] = 0;
303  a.capfc[i] = 0;
304  for (int j = 0; j != 4; j++) {
305  a.sig[i][j] = 0;
306  a.sigfc[i][j] = 0;
307  a.prod[i][j] = 0;
308  a.prodfc[i][j] = 0;
309  a.num[i][j] = 0;
310  }
311  }
312  Bunches.push_back(a);
313  }
314  }
315  firsttime = false;
316  }
317 
318  std::vector<NewPedBunch>::iterator bunch_it;
319 
320  for (CastorDigiCollection::const_iterator j = castor->begin(); j != castor->end(); ++j) {
321  const CastorDataFrame digi = (const CastorDataFrame)(*j);
322  for (bunch_it = Bunches.begin(); bunch_it != Bunches.end(); ++bunch_it)
323  if (bunch_it->detid.rawId() == digi.id().rawId())
324  break;
325  bunch_it->usedflag = true;
326  for (int ts = firstTS; ts != lastTS + 1; ts++) {
327  const CastorQIECoder* coder = conditions->getCastorCoder(digi.id().rawId());
328  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts).capid()] += 1;
329  bunch_it->cap[digi.sample(ts).capid()] += digi.sample(ts).adc();
330  double charge1 = coder->charge(*shape, digi.sample(ts).adc(), digi.sample(ts).capid());
331  bunch_it->capfc[digi.sample(ts).capid()] += charge1;
332  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts).capid()] +=
333  (digi.sample(ts).adc() * digi.sample(ts).adc());
334  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts).capid()] += charge1 * charge1;
335  if ((ts + 1 < digi.size()) && (ts + 1 < lastTS)) {
336  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] +=
337  digi.sample(ts).adc() * digi.sample(ts + 1).adc();
338  double charge2 = coder->charge(*shape, digi.sample(ts + 1).adc(), digi.sample(ts + 1).capid());
339  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] += charge1 * charge2;
340  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 1).capid()] += 1;
341  }
342  if ((ts + 2 < digi.size()) && (ts + 2 < lastTS)) {
343  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] +=
344  digi.sample(ts).adc() * digi.sample(ts + 2).adc();
345  double charge2 = coder->charge(*shape, digi.sample(ts + 2).adc(), digi.sample(ts + 2).capid());
346  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] += charge1 * charge2;
347  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 2).capid()] += 1;
348  }
349  if ((ts + 3 < digi.size()) && (ts + 3 < lastTS)) {
350  bunch_it->prod[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] +=
351  digi.sample(ts).adc() * digi.sample(ts + 3).adc();
352  double charge2 = coder->charge(*shape, digi.sample(ts + 3).adc(), digi.sample(ts + 3).capid());
353  bunch_it->prodfc[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] += charge1 * charge2;
354  bunch_it->num[digi.sample(ts).capid()][digi.sample(ts + 3).capid()] += 1;
355  }
356  }
357  }
358 
359  //this is the last brace
360 }

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

Member Data Documentation

◆ Bunches

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

Definition at line 82 of file CastorPedestalsAnalysis.h.

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

◆ castorDigiCollectionTag

edm::InputTag CastorPedestalsAnalysis::castorDigiCollectionTag
private

Definition at line 111 of file CastorPedestalsAnalysis.h.

Referenced by analyze().

◆ CASTORMeans

TH1F* CastorPedestalsAnalysis::CASTORMeans
private

Definition at line 102 of file CastorPedestalsAnalysis.h.

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

◆ CASTORWidths

TH1F* CastorPedestalsAnalysis::CASTORWidths
private

Definition at line 103 of file CastorPedestalsAnalysis.h.

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

◆ dephist

TH2F* CastorPedestalsAnalysis::dephist
private

Definition at line 106 of file CastorPedestalsAnalysis.h.

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

◆ dumpXML

bool CastorPedestalsAnalysis::dumpXML
private

Definition at line 85 of file CastorPedestalsAnalysis.h.

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

◆ firsttime

bool CastorPedestalsAnalysis::firsttime
private

Definition at line 109 of file CastorPedestalsAnalysis.h.

Referenced by analyze(), and CastorPedestalsAnalysis().

◆ firstTS

int CastorPedestalsAnalysis::firstTS
private

Definition at line 88 of file CastorPedestalsAnalysis.h.

Referenced by analyze(), and CastorPedestalsAnalysis().

◆ hiSaveFlag

bool CastorPedestalsAnalysis::hiSaveFlag
private

Definition at line 84 of file CastorPedestalsAnalysis.h.

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

◆ lastTS

int CastorPedestalsAnalysis::lastTS
private

Definition at line 89 of file CastorPedestalsAnalysis.h.

Referenced by analyze(), and CastorPedestalsAnalysis().

◆ pedsADCfilename

std::string CastorPedestalsAnalysis::pedsADCfilename
private

Definition at line 91 of file CastorPedestalsAnalysis.h.

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

◆ pedsfCfilename

std::string CastorPedestalsAnalysis::pedsfCfilename
private

Definition at line 92 of file CastorPedestalsAnalysis.h.

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

◆ ROOTfilename

std::string CastorPedestalsAnalysis::ROOTfilename
private

Definition at line 90 of file CastorPedestalsAnalysis.h.

Referenced by analyze().

◆ runnum

int CastorPedestalsAnalysis::runnum
private

Definition at line 87 of file CastorPedestalsAnalysis.h.

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

◆ theFile

TFile* CastorPedestalsAnalysis::theFile
private

Definition at line 108 of file CastorPedestalsAnalysis.h.

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

◆ tok_cond_

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

Definition at line 99 of file CastorPedestalsAnalysis.h.

Referenced by analyze(), and CastorPedestalsAnalysis().

◆ tok_map_

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

Definition at line 100 of file CastorPedestalsAnalysis.h.

Referenced by analyze(), and CastorPedestalsAnalysis().

◆ verboseflag

bool CastorPedestalsAnalysis::verboseflag
private

Definition at line 86 of file CastorPedestalsAnalysis.h.

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

◆ widthsADCfilename

std::string CastorPedestalsAnalysis::widthsADCfilename
private

Definition at line 93 of file CastorPedestalsAnalysis.h.

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

◆ widthsfCfilename

std::string CastorPedestalsAnalysis::widthsfCfilename
private

Definition at line 94 of file CastorPedestalsAnalysis.h.

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

◆ XMLfilename

std::string CastorPedestalsAnalysis::XMLfilename
private

Definition at line 95 of file CastorPedestalsAnalysis.h.

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

◆ XMLtag

std::string CastorPedestalsAnalysis::XMLtag
private

Definition at line 96 of file CastorPedestalsAnalysis.h.

Referenced by analyze().

◆ ZSfilename

std::string CastorPedestalsAnalysis::ZSfilename
private

Definition at line 97 of file CastorPedestalsAnalysis.h.

CastorPedestalsAnalysis::Bunches
std::vector< NewPedBunch > Bunches
Definition: CastorPedestalsAnalysis.h:82
CastorPedestalsAnalysis::runnum
int runnum
Definition: CastorPedestalsAnalysis.h:87
CastorPedestalsAnalysis::hiSaveFlag
bool hiSaveFlag
Definition: CastorPedestalsAnalysis.h:84
CastorPedestalsAnalysis::dumpXML
bool dumpXML
Definition: CastorPedestalsAnalysis.h:85
mps_fire.i
i
Definition: mps_fire.py:428
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HcalGenericDetId
Definition: HcalGenericDetId.h:15
CastorPedestalsAnalysis::firsttime
bool firsttime
Definition: CastorPedestalsAnalysis.h:109
CastorPedestalsAnalysis::tok_cond_
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_cond_
Definition: CastorPedestalsAnalysis.h:99
CastorPedestalsAnalysis::dephist
TH2F * dephist
Definition: CastorPedestalsAnalysis.h:106
HcalQIESample::adc
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43
CastorPedestalsAnalysis::XMLtag
std::string XMLtag
Definition: CastorPedestalsAnalysis.h:96
gather_cfg.cout
cout
Definition: gather_cfg.py:144
CastorPedestalsAnalysis::widthsfCfilename
std::string widthsfCfilename
Definition: CastorPedestalsAnalysis.h:94
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
CastorDataFrame::id
const HcalCastorDetId & id() const
Definition: CastorDataFrame.h:22
CastorPedestal
Definition: CastorPedestal.h:16
CastorPedestalWidth
Definition: CastorPedestalWidth.h:16
edm::Handle
Definition: AssociativeIterator.h:50
CastorPedestalsAnalysis::CASTORMeans
TH1F * CASTORMeans
Definition: CastorPedestalsAnalysis.h:102
CastorPedestalsAnalysis::lastTS
int lastTS
Definition: CastorPedestalsAnalysis.h:89
CastorPedestalsAnalysis::castorDigiCollectionTag
edm::InputTag castorDigiCollectionTag
Definition: CastorPedestalsAnalysis.h:111
CastorPedestalsAnalysis::ROOTfilename
std::string ROOTfilename
Definition: CastorPedestalsAnalysis.h:90
CastorPedestals
Definition: CastorPedestals.h:18
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalCastorDetId
Definition: HcalCastorDetId.h:23
CastorDataFrame::sample
const HcalQIESample & sample(int i) const
access a sample
Definition: CastorDataFrame.h:39
CastorDataFrame
Definition: CastorDataFrame.h:15
CastorDbASCIIIO::dumpObject
bool dumpObject(std::ostream &fOutput, const CastorPedestals &fObject)
Definition: CastorDbASCIIIO.cc:323
CastorDataFrame::size
int size() const
total number of samples in the digi
Definition: CastorDataFrame.h:26
a
double a
Definition: hdecay.h:119
CastorQIECoder::charge
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: CastorQIECoder.cc:17
CastorPedestalsAnalysis::XMLfilename
std::string XMLfilename
Definition: CastorPedestalsAnalysis.h:95
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
CastorPedestalsAnalysis::verboseflag
bool verboseflag
Definition: CastorPedestalsAnalysis.h:86
CastorCondObjectContainer::addValues
bool addValues(const Item &myItem)
Definition: CastorCondObjectContainer.h:98
CastorPedestalsAnalysis::widthsADCfilename
std::string widthsADCfilename
Definition: CastorPedestalsAnalysis.h:93
HcalQIESample::capid
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
CastorPedestalsAnalysis::CASTORWidths
TH1F * CASTORWidths
Definition: CastorPedestalsAnalysis.h:103
CastorPedestalsAnalysis::pedsfCfilename
std::string pedsfCfilename
Definition: CastorPedestalsAnalysis.h:92
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CastorPedestalsAnalysis::pedsADCfilename
std::string pedsADCfilename
Definition: CastorPedestalsAnalysis.h:91
CastorPedestalsAnalysis::theFile
TFile * theFile
Definition: CastorPedestalsAnalysis.h:108
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CastorPedestalWidths
Definition: CastorPedestalWidths.h:18
CastorQIECoder
Definition: CastorQIECoder.h:21
CastorElectronicsMap
Definition: CastorElectronicsMap.h:30
CastorPedestalsAnalysis::firstTS
int firstTS
Definition: CastorPedestalsAnalysis.h:88
NewPedBunch
Definition: CastorPedestalsAnalysis.h:59
CastorPedestalsAnalysis::tok_map_
edm::ESGetToken< CastorElectronicsMap, CastorElectronicsMapRcd > tok_map_
Definition: CastorPedestalsAnalysis.h:100
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CastorElectronicsMap::allPrecisionId
std::vector< HcalGenericDetId > allPrecisionId() const
Definition: CastorElectronicsMap.cc:178
hfnoseParametersInitialization_cfi.name2
name2
Definition: hfnoseParametersInitialization_cfi.py:8
edm::InputTag
Definition: InputTag.h:15
CastorQIEShape
Definition: CastorQIEShape.h:14
castorDigitizer_cfi.castor
castor
Definition: castorDigitizer_cfi.py:9
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37