CMS 3D CMS Logo

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

#include <DTNoiseComputation.h>

Inheritance diagram for DTNoiseComputation:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 
void beginJob () override
 BeginJob. More...
 
void beginRun (const edm::Run &, const edm::EventSetup &setup) override
 
 DTNoiseComputation (const edm::ParameterSet &ps)
 Constructor. More...
 
void endJob () override
 Endjob. More...
 
void endRun (const edm::Run &, const edm::EventSetup &setup) override
 
 ~DTNoiseComputation () override
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 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 Member Functions

std::string getChamberName (const DTLayerId &lId) const
 Get the name of the chamber. More...
 
std::string getLayerName (const DTLayerId &lId) const
 Get the name of the layer. More...
 
int getMaxNumBins (const DTChamberId &chId) const
 
std::string getSuperLayerName (const DTSuperLayerId &slId) const
 Get the name of the superLayer. More...
 
double getYMaximum (const DTSuperLayerId &slId) const
 

Private Attributes

std::map< DTChamberId, TH1F * > AvNoiseIntegratedPerChamber
 
std::map< DTSuperLayerId, TH1F * > AvNoiseIntegratedPerSuperLayer
 
std::map< DTChamberId, TH1F * > AvNoisePerChamber
 
std::map< DTSuperLayerId, TH1F * > AvNoisePerSuperLayer
 
int counter
 
bool debug
 
edm::ESHandle< DTGeometrydtGeom
 
const edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomToken_
 
bool fastAnalysis
 
int MaxEvents
 
std::map< std::pair< int, int >, TH1F * > noisyC
 
std::map< std::pair< int, int >, TH1F * > someHowNoisyC
 
std::map< DTWireId, double > theAverageNoise
 
std::map< DTLayerId, std::vector< TH2F * > > theEvtMap
 
TFile * theFile
 
std::map< DTWireId, TH1F * > theHistoEvtDistancePerWire
 
TFile * theNewFile
 
std::map< DTWireId, double > theTimeConstant
 
std::map< DTLayerId, bool > toComputeNoiseAverage
 
std::map< DTWireId, bool > toDel
 

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 34 of file DTNoiseComputation.h.

Constructor & Destructor Documentation

◆ DTNoiseComputation()

DTNoiseComputation::DTNoiseComputation ( const edm::ParameterSet ps)

Constructor.

Definition at line 41 of file DTNoiseComputation.cc.

References gather_cfg::cout, debug, fastAnalysis, edm::ParameterSet::getUntrackedParameter(), MaxEvents, CSCSkim_cfi::rootFileName, theFile, and theNewFile.

42  cout << "[DTNoiseComputation]: Constructor" << endl;
43 
44  // Get the debug parameter for verbose output
45  debug = ps.getUntrackedParameter<bool>("debug");
46 
47  // The analysis type
48  fastAnalysis = ps.getUntrackedParameter<bool>("fastAnalysis", true);
49 
50  // The root file which contain the histos
51  string rootFileName = ps.getUntrackedParameter<string>("rootFileName");
52  theFile = new TFile(rootFileName.c_str(), "READ");
53 
54  // The new root file which contain the histos
55  string newRootFileName = ps.getUntrackedParameter<string>("newRootFileName");
56  theNewFile = new TFile(newRootFileName.c_str(), "RECREATE");
57 
58  // The maximum number of events to analyze
59  MaxEvents = ps.getUntrackedParameter<int>("MaxEvents");
60 }
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_

◆ ~DTNoiseComputation()

DTNoiseComputation::~DTNoiseComputation ( )
override

Destructor.

Definition at line 376 of file DTNoiseComputation.cc.

References theFile, and theNewFile.

376  {
377  theFile->Close();
378  theNewFile->Close();
379 }

Member Function Documentation

◆ analyze()

void DTNoiseComputation::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
inlineoverridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 47 of file DTNoiseComputation.h.

47 {}

◆ beginJob()

void DTNoiseComputation::beginJob ( )
inlineoverridevirtual

BeginJob.

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 43 of file DTNoiseComputation.h.

43 {}

◆ beginRun()

void DTNoiseComputation::beginRun ( const edm::Run ,
const edm::EventSetup setup 
)
override

Definition at line 62 of file DTNoiseComputation.cc.

References AvNoiseIntegratedPerChamber, AvNoiseIntegratedPerSuperLayer, AvNoisePerChamber, AvNoisePerSuperLayer, newFWLiteAna::bin, DTSuperLayerId::chamberId(), DTGeometry::chambers(), submitPVResolutionJobs::count, gather_cfg::cout, debug, dtGeom, dtGeomToken_, HcalObjRepresent::Fill(), getChamberName(), getLayerName(), getMaxNumBins(), getSuperLayerName(), MaxEvents, noisyC, singleTopDQM_cfi::setup, someHowNoisyC, DTChamberId::station(), relativeConstraints::station, DTLayerId::superlayerId(), theAverageNoise, theEvtMap, theFile, cond::impl::to_string(), DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

62  {
63  // Get the DT Geometry
64  dtGeom = setup.getHandle(dtGeomToken_);
65 
66  static int count = 0;
67 
68  if (count == 0) {
69  string CheckHistoName;
70 
71  TH1F *hOccHisto;
72  TH1F *hAverageNoiseHisto;
73  TH1F *hAverageNoiseIntegratedHisto;
74  TH1F *hAverageNoiseHistoPerCh;
75  TH1F *hAverageNoiseIntegratedHistoPerCh;
76  TH2F *hEvtHisto;
77  string HistoName;
78  string Histo2Name;
79  string AverageNoiseName;
80  string AverageNoiseIntegratedName;
81  string AverageNoiseNamePerCh;
82  string AverageNoiseIntegratedNamePerCh;
83  TH1F *hnoisyC;
84  TH1F *hsomeHowNoisyC;
85 
86  // Loop over all the chambers
87  vector<const DTChamber *>::const_iterator ch_it = dtGeom->chambers().begin();
88  vector<const DTChamber *>::const_iterator ch_end = dtGeom->chambers().end();
89  // Loop over the SLs
90  for (; ch_it != ch_end; ++ch_it) {
91  DTChamberId ch = (*ch_it)->id();
92  vector<const DTSuperLayer *>::const_iterator sl_it = (*ch_it)->superLayers().begin();
93  vector<const DTSuperLayer *>::const_iterator sl_end = (*ch_it)->superLayers().end();
94  // Loop over the SLs
95  for (; sl_it != sl_end; ++sl_it) {
96  // DTSuperLayerId sl = (*sl_it)->id();
97  vector<const DTLayer *>::const_iterator l_it = (*sl_it)->layers().begin();
98  vector<const DTLayer *>::const_iterator l_end = (*sl_it)->layers().end();
99  // Loop over the Ls
100  for (; l_it != l_end; ++l_it) {
101  DTLayerId dtLId = (*l_it)->id();
102 
103  //check if the layer has digi
104  theFile->cd();
105  CheckHistoName = "DigiOccupancy_" + getLayerName(dtLId);
106  TH1F *hCheckHisto = (TH1F *)theFile->Get(CheckHistoName.c_str());
107  if (hCheckHisto) {
108  delete hCheckHisto;
109  string wheel = std::to_string(ch.wheel());
110  string station = std::to_string(ch.station());
111 
112  if (someHowNoisyC.find(make_pair(ch.wheel(), ch.station())) == someHowNoisyC.end()) {
113  TString histoName_someHowNoisy = "somehowNoisyCell_W" + wheel + "_St" + station;
114  hsomeHowNoisyC =
115  new TH1F(histoName_someHowNoisy, histoName_someHowNoisy, getMaxNumBins(ch), 1, getMaxNumBins(ch) + 1);
116  someHowNoisyC[make_pair(ch.wheel(), ch.station())] = hsomeHowNoisyC;
117  }
118 
119  if (noisyC.find(make_pair(ch.wheel(), ch.station())) == noisyC.end()) {
120  TString histoName_noisy = "noisyCell_W" + wheel + "_St" + station;
121  hnoisyC = new TH1F(histoName_noisy, histoName_noisy, getMaxNumBins(ch), 1, getMaxNumBins(ch) + 1);
122  noisyC[make_pair(ch.wheel(), ch.station())] = hnoisyC;
123  }
124 
125  //to fill a map with the average noise per wire and fill new noise histo
126  if (AvNoisePerSuperLayer.find(dtLId.superlayerId()) == AvNoisePerSuperLayer.end()) {
127  AverageNoiseName = "AverageNoise_" + getSuperLayerName(dtLId.superlayerId());
128  hAverageNoiseHisto = new TH1F(AverageNoiseName.c_str(), AverageNoiseName.c_str(), 200, 0, 10000);
129  AverageNoiseIntegratedName = "AverageNoiseIntegrated_" + getSuperLayerName(dtLId.superlayerId());
130  hAverageNoiseIntegratedHisto =
131  new TH1F(AverageNoiseIntegratedName.c_str(), AverageNoiseIntegratedName.c_str(), 200, 0, 10000);
132  AvNoisePerSuperLayer[dtLId.superlayerId()] = hAverageNoiseHisto;
133  AvNoiseIntegratedPerSuperLayer[dtLId.superlayerId()] = hAverageNoiseIntegratedHisto;
134  if (debug) {
135  cout << " New Average Noise Histo per SuperLayer : " << hAverageNoiseHisto->GetName() << endl;
136  cout << " New Average Noise Integrated Histo per SuperLayer : " << hAverageNoiseHisto->GetName()
137  << endl;
138  }
139  }
140  if (AvNoisePerChamber.find(dtLId.superlayerId().chamberId()) == AvNoisePerChamber.end()) {
141  AverageNoiseNamePerCh = "AverageNoise_" + getChamberName(dtLId);
142  hAverageNoiseHistoPerCh =
143  new TH1F(AverageNoiseNamePerCh.c_str(), AverageNoiseNamePerCh.c_str(), 200, 0, 10000);
144  AverageNoiseIntegratedNamePerCh = "AverageNoiseIntegrated_" + getChamberName(dtLId);
145  hAverageNoiseIntegratedHistoPerCh = new TH1F(
146  AverageNoiseIntegratedNamePerCh.c_str(), AverageNoiseIntegratedNamePerCh.c_str(), 200, 0, 10000);
147  AvNoisePerChamber[dtLId.superlayerId().chamberId()] = hAverageNoiseHistoPerCh;
148  AvNoiseIntegratedPerChamber[dtLId.superlayerId().chamberId()] = hAverageNoiseIntegratedHistoPerCh;
149  if (debug)
150  cout << " New Average Noise Histo per chamber : " << hAverageNoiseHistoPerCh->GetName() << endl;
151  }
152 
153  HistoName = "DigiOccupancy_" + getLayerName(dtLId);
154  theFile->cd();
155  hOccHisto = (TH1F *)theFile->Get(HistoName.c_str());
156  int numBin = hOccHisto->GetXaxis()->GetNbins();
157  for (int bin = 1; bin <= numBin; bin++) {
158  DTWireId wireID(dtLId, bin);
159  theAverageNoise[wireID] = hOccHisto->GetBinContent(bin);
160  if (theAverageNoise[wireID] != 0) {
161  AvNoisePerSuperLayer[dtLId.superlayerId()]->Fill(theAverageNoise[wireID]);
162  AvNoisePerChamber[dtLId.superlayerId().chamberId()]->Fill(theAverageNoise[wireID]);
163  }
164  }
165 
166  //to compute the average noise per layer (excluding the noisy cells)
167  double numCell = 0;
168  double AvNoise = 0;
169  HistoName = "DigiOccupancy_" + getLayerName(dtLId);
170  theFile->cd();
171  hOccHisto = (TH1F *)theFile->Get(HistoName.c_str());
172  numBin = hOccHisto->GetXaxis()->GetNbins();
173  for (int bin = 1; bin <= numBin; bin++) {
174  DTWireId wireID(dtLId, bin);
175  theAverageNoise[wireID] = hOccHisto->GetBinContent(bin);
176  if (hOccHisto->GetBinContent(bin) < 100) {
177  numCell++;
178  AvNoise += hOccHisto->GetBinContent(bin);
179  }
180  if (hOccHisto->GetBinContent(bin) > 100 && hOccHisto->GetBinContent(bin) < 500) {
181  someHowNoisyC[make_pair(ch.wheel(), ch.station())]->Fill(bin);
182  cout << "filling somehow noisy cell" << endl;
183  }
184  if (hOccHisto->GetBinContent(bin) > 500) {
185  noisyC[make_pair(ch.wheel(), ch.station())]->Fill(bin);
186  cout << "filling noisy cell" << endl;
187  }
188  }
189  AvNoise = AvNoise / numCell;
190  cout << "theAverageNoise for layer " << getLayerName(dtLId) << " is : " << AvNoise << endl;
191 
192  // book the digi event plots every 1000 events
193  int updates = MaxEvents / 1000;
194  for (int evt = 0; evt < updates; evt++) {
195  Histo2Name = "DigiPerWirePerEvent_" + getLayerName(dtLId) + "_" + std::to_string(evt);
196  theFile->cd();
197  hEvtHisto = (TH2F *)theFile->Get(Histo2Name.c_str());
198  if (hEvtHisto) {
199  if (debug)
200  cout << " New Histo with the number of events per evt per wire: " << hEvtHisto->GetName() << endl;
201  theEvtMap[dtLId].push_back(hEvtHisto);
202  }
203  }
204 
205  } // done if the layer has digi
206  } // loop over layers
207  } // loop over superlayers
208  } // loop over chambers
209 
210  count++;
211  }
212 }
int station() const
Return the station number.
Definition: DTChamberId.h:42
edm::ESHandle< DTGeometry > dtGeom
std::string to_string(const V &value)
Definition: OMSAccess.h:71
std::map< DTLayerId, std::vector< TH2F * > > theEvtMap
int getMaxNumBins(const DTChamberId &chId) const
DTChamberId chamberId() const
Return the corresponding ChamberId.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::string getLayerName(const DTLayerId &lId) const
Get the name of the layer.
std::map< std::pair< int, int >, TH1F * > noisyC
std::map< DTWireId, double > theAverageNoise
std::map< DTChamberId, TH1F * > AvNoisePerChamber
std::map< DTSuperLayerId, TH1F * > AvNoiseIntegratedPerSuperLayer
std::string HistoName
std::map< std::pair< int, int >, TH1F * > someHowNoisyC
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
std::map< DTSuperLayerId, TH1F * > AvNoisePerSuperLayer
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
std::string getChamberName(const DTLayerId &lId) const
Get the name of the chamber.
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
std::string getSuperLayerName(const DTSuperLayerId &slId) const
Get the name of the superLayer.
std::map< DTChamberId, TH1F * > AvNoiseIntegratedPerChamber

◆ endJob()

void DTNoiseComputation::endJob ( void  )
overridevirtual

Endjob.

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 214 of file DTNoiseComputation.cc.

References AvNoiseIntegratedPerChamber, AvNoiseIntegratedPerSuperLayer, AvNoisePerChamber, AvNoisePerSuperLayer, newFWLiteAna::bin, alignmentValidation::c1, DTGeometry::chambers(), gather_cfg::cout, dtGeom, fastAnalysis, getLayerName(), getSuperLayerName(), getYMaximum(), timingPdfMaker::histo, mps_fire::i, createfilelist::int, DTLayerId::layer(), genParticles_cff::map, cms::cuda::allocator::maxBin, noisyC, pfMETCorrectionType0_cfi::par0, pfMETCorrectionType0_cfi::par1, someHowNoisyC, theAverageNoise, theEvtMap, theFile, theHistoEvtDistancePerWire, theNewFile, theTimeConstant, cond::impl::to_string(), and toDel.

Referenced by o2olib.O2ORunMgr::executeJob().

214  {
215  cout << "[DTNoiseComputation] endjob called!" << endl;
216  TH1F *hEvtDistance = nullptr;
217  TF1 *ExpoFit = new TF1("ExpoFit", "expo", 0.5, 1000.5);
218  ExpoFit->SetMarkerColor(); //just silence gcc complaining about unused vars
219  TProfile *theNoiseHisto = new TProfile("theNoiseHisto", "Time Constant versus Average Noise", 100000, 0, 100000);
220 
221  //compute the time constant
222  for (map<DTLayerId, vector<TH2F *> >::const_iterator lHisto = theEvtMap.begin(); lHisto != theEvtMap.end();
223  ++lHisto) {
224  for (int bin = 1; bin < (*lHisto).second[0]->GetYaxis()->GetNbins(); bin++) {
225  int distanceEvt = 1;
226  DTWireId wire((*lHisto).first, bin);
227  for (int i = 0; i < int((*lHisto).second.size()); i++) {
228  for (int evt = 1; evt <= (*lHisto).second[i]->GetXaxis()->GetNbins(); evt++) {
229  if ((*lHisto).second[i]->GetBinContent(evt, bin) == 0)
230  distanceEvt++;
231  else {
232  if (toDel.find(wire) == toDel.end()) {
233  toDel[wire] = false;
234  string Histo = "EvtDistancePerWire_" + getLayerName((*lHisto).first) + "_" + std::to_string(bin);
235  hEvtDistance = new TH1F(Histo.c_str(), Histo.c_str(), 50000, 0.5, 50000.5);
236  }
237  hEvtDistance->Fill(distanceEvt);
238  distanceEvt = 1;
239  }
240  }
241  }
242  if (toDel.find(wire) != toDel.end()) {
243  theHistoEvtDistancePerWire[wire] = hEvtDistance;
244  theNewFile->cd();
245  theHistoEvtDistancePerWire[wire]->Fit("ExpoFit", "R");
246  TF1 *funct = theHistoEvtDistancePerWire[wire]->GetFunction("ExpoFit");
247  double par0 = funct->GetParameter(0);
248  double par1 = funct->GetParameter(1);
249  cout << "par0: " << par0 << " par1: " << par1 << endl;
250  double chi2rid = funct->GetChisquare() / funct->GetNDF();
251  if (chi2rid > 10)
252  theTimeConstant[wire] = 1;
253  else
254  theTimeConstant[wire] = par1;
255  toDel[wire] = true;
256  theHistoEvtDistancePerWire[wire]->Write();
257  delete hEvtDistance;
258  }
259  }
260  }
261 
262  if (!fastAnalysis) {
263  //fill the histo with the time constant as a function of the average noise
264  for (map<DTWireId, double>::const_iterator AvNoise = theAverageNoise.begin(); AvNoise != theAverageNoise.end();
265  ++AvNoise) {
266  DTWireId wire = (*AvNoise).first;
267  theNoiseHisto->Fill((*AvNoise).second, theTimeConstant[wire]);
268  cout << "Layer: " << getLayerName(wire.layerId()) << " wire: " << wire.wire() << endl;
269  cout << "The Average noise: " << (*AvNoise).second << endl;
270  cout << "The time constant: " << theTimeConstant[wire] << endl;
271  }
272  theNewFile->cd();
273  theNoiseHisto->Write();
274  }
275 
276  // histos with the integrated noise per layer
277  int numBin;
278  double integratedNoise, bin, halfBin, maxBin;
279  for (map<DTSuperLayerId, TH1F *>::const_iterator AvNoiseHisto = AvNoisePerSuperLayer.begin();
280  AvNoiseHisto != AvNoisePerSuperLayer.end();
281  ++AvNoiseHisto) {
282  integratedNoise = 0;
283  numBin = (*AvNoiseHisto).second->GetXaxis()->GetNbins();
284  maxBin = (*AvNoiseHisto).second->GetXaxis()->GetXmax();
285  bin = double(maxBin / numBin);
286  halfBin = double(bin / 2);
287  theNewFile->cd();
288  (*AvNoiseHisto).second->Write();
289  for (int i = 1; i < numBin; i++) {
290  integratedNoise += (*AvNoiseHisto).second->GetBinContent(i);
291  AvNoiseIntegratedPerSuperLayer[(*AvNoiseHisto).first]->Fill(halfBin, integratedNoise);
292  halfBin += bin;
293  }
294  theNewFile->cd();
295  AvNoiseIntegratedPerSuperLayer[(*AvNoiseHisto).first]->Write();
296  }
297  // histos with the integrated noise per chamber
298  for (map<DTChamberId, TH1F *>::const_iterator AvNoiseHisto = AvNoisePerChamber.begin();
299  AvNoiseHisto != AvNoisePerChamber.end();
300  ++AvNoiseHisto) {
301  integratedNoise = 0;
302  numBin = (*AvNoiseHisto).second->GetXaxis()->GetNbins();
303  maxBin = (*AvNoiseHisto).second->GetXaxis()->GetXmax();
304  bin = maxBin / numBin;
305  halfBin = bin / 2;
306  theNewFile->cd();
307  (*AvNoiseHisto).second->Write();
308  for (int i = 1; i < numBin; i++) {
309  integratedNoise += (*AvNoiseHisto).second->GetBinContent(i);
310  AvNoiseIntegratedPerChamber[(*AvNoiseHisto).first]->Fill(halfBin, integratedNoise);
311  halfBin += bin;
312  }
313  theNewFile->cd();
314  AvNoiseIntegratedPerChamber[(*AvNoiseHisto).first]->Write();
315  }
316 
317  //overimpose the average noise histo
318  bool histo = false;
319  vector<const DTChamber *>::const_iterator chamber_it = dtGeom->chambers().begin();
320  vector<const DTChamber *>::const_iterator chamber_end = dtGeom->chambers().end();
321  // Loop over the chambers
322  for (; chamber_it != chamber_end; ++chamber_it) {
323  vector<const DTSuperLayer *>::const_iterator sl_it = (*chamber_it)->superLayers().begin();
324  vector<const DTSuperLayer *>::const_iterator sl_end = (*chamber_it)->superLayers().end();
325  // Loop over the SLs
326  for (; sl_it != sl_end; ++sl_it) {
327  DTSuperLayerId sl = (*sl_it)->id();
328  vector<const DTLayer *>::const_iterator l_it = (*sl_it)->layers().begin();
329  vector<const DTLayer *>::const_iterator l_end = (*sl_it)->layers().end();
330 
331  string canvasName = "c" + getSuperLayerName(sl);
332  TCanvas c1(canvasName.c_str(), canvasName.c_str(), 600, 780);
333  TLegend *leg = new TLegend(0.5, 0.6, 0.7, 0.8);
334  for (; l_it != l_end; ++l_it) {
335  DTLayerId layerId = (*l_it)->id();
336  string HistoName = "DigiOccupancy_" + getLayerName(layerId);
337  theFile->cd();
338  TH1F *hOccHisto = (TH1F *)theFile->Get(HistoName.c_str());
339  if (hOccHisto) {
340  string TitleHisto = "AverageNoise_" + getSuperLayerName(sl);
341  cout << "TitleHisto : " << TitleHisto << endl;
342  hOccHisto->SetTitle(TitleHisto.c_str());
343  string legendHisto = "layer " + std::to_string(layerId.layer());
344  leg->AddEntry(hOccHisto, legendHisto.c_str(), "L");
345  hOccHisto->SetMaximum(getYMaximum(sl));
346  histo = true;
347  if (layerId.layer() == 1)
348  hOccHisto->Draw();
349  else
350  hOccHisto->Draw("same");
351  hOccHisto->SetLineColor(layerId.layer());
352  }
353  }
354  if (histo) {
355  leg->Draw("same");
356  theNewFile->cd();
357  c1.Write();
358  }
359  }
360  histo = false;
361  }
362 
363  //write on file the noisy plots
364  for (map<pair<int, int>, TH1F *>::const_iterator nCell = noisyC.begin(); nCell != noisyC.end(); ++nCell) {
365  theNewFile->cd();
366  (*nCell).second->Write();
367  }
368  for (map<pair<int, int>, TH1F *>::const_iterator somehownCell = someHowNoisyC.begin();
369  somehownCell != someHowNoisyC.end();
370  ++somehownCell) {
371  theNewFile->cd();
372  (*somehownCell).second->Write();
373  }
374 }
Definition: Abs.h:5
constexpr unsigned int maxBin
edm::ESHandle< DTGeometry > dtGeom
std::string to_string(const V &value)
Definition: OMSAccess.h:71
std::map< DTLayerId, std::vector< TH2F * > > theEvtMap
std::map< DTWireId, TH1F * > theHistoEvtDistancePerWire
std::map< DTWireId, bool > toDel
std::string getLayerName(const DTLayerId &lId) const
Get the name of the layer.
std::map< std::pair< int, int >, TH1F * > noisyC
std::map< DTWireId, double > theAverageNoise
std::map< DTChamberId, TH1F * > AvNoisePerChamber
std::map< DTSuperLayerId, TH1F * > AvNoiseIntegratedPerSuperLayer
std::string HistoName
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
std::map< std::pair< int, int >, TH1F * > someHowNoisyC
std::map< DTSuperLayerId, TH1F * > AvNoisePerSuperLayer
std::map< DTWireId, double > theTimeConstant
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
std::string getSuperLayerName(const DTSuperLayerId &slId) const
Get the name of the superLayer.
std::map< DTChamberId, TH1F * > AvNoiseIntegratedPerChamber
double getYMaximum(const DTSuperLayerId &slId) const

◆ endRun()

void DTNoiseComputation::endRun ( const edm::Run ,
const edm::EventSetup setup 
)
inlineoverride

Definition at line 49 of file DTNoiseComputation.h.

49 {};

◆ getChamberName()

string DTNoiseComputation::getChamberName ( const DTLayerId lId) const
private

Get the name of the chamber.

Definition at line 400 of file DTNoiseComputation.cc.

References DTSuperLayerId::chamberId(), DTChamberId::sector(), DTChamberId::station(), DTLayerId::superlayerId(), cond::impl::to_string(), and DTChamberId::wheel().

Referenced by beginRun().

400  {
401  const DTSuperLayerId dtSLId = lId.superlayerId();
402  const DTChamberId dtChId = dtSLId.chamberId();
403  string chamberName = "W" + std::to_string(dtChId.wheel()) + "_St" + std::to_string(dtChId.station()) + "_Sec" +
404  std::to_string(dtChId.sector());
405 
406  return chamberName;
407 }
int station() const
Return the station number.
Definition: DTChamberId.h:42
std::string to_string(const V &value)
Definition: OMSAccess.h:71
DTChamberId chamberId() const
Return the corresponding ChamberId.
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45

◆ getLayerName()

string DTNoiseComputation::getLayerName ( const DTLayerId lId) const
private

Get the name of the layer.

Definition at line 381 of file DTNoiseComputation.cc.

References DTSuperLayerId::chamberId(), DTLayerId::layer(), phase1PixelTopology::layerName, DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), DTLayerId::superlayerId(), cond::impl::to_string(), and DTChamberId::wheel().

Referenced by beginRun(), endJob(), getMaxNumBins(), and getYMaximum().

381  {
382  const DTSuperLayerId dtSLId = lId.superlayerId();
383  const DTChamberId dtChId = dtSLId.chamberId();
384  string layerName = "W" + std::to_string(dtChId.wheel()) + "_St" + std::to_string(dtChId.station()) + "_Sec" +
385  std::to_string(dtChId.sector()) + "_SL" + std::to_string(dtSLId.superlayer()) + "_L" +
386  std::to_string(lId.layer());
387 
388  return layerName;
389 }
int station() const
Return the station number.
Definition: DTChamberId.h:42
constexpr char const * layerName[numberOfLayers]
std::string to_string(const V &value)
Definition: OMSAccess.h:71
DTChamberId chamberId() const
Return the corresponding ChamberId.
int superlayer() const
Return the superlayer number (deprecated method name)
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45

◆ getMaxNumBins()

int DTNoiseComputation::getMaxNumBins ( const DTChamberId chId) const
private

Definition at line 409 of file DTNoiseComputation.cc.

References getLayerName(), dttmaxenums::L, DTChamberId::station(), and theFile.

Referenced by beginRun().

409  {
410  int maximum = 0;
411 
412  for (int SL = 1; SL <= 3; SL++) {
413  if (!(chId.station() == 4 && SL == 2)) {
414  for (int L = 1; L <= 4; L++) {
415  DTLayerId layerId = DTLayerId(chId, SL, L);
416  string HistoName = "DigiOccupancy_" + getLayerName(layerId);
417  theFile->cd();
418  TH1F *hOccHisto = (TH1F *)theFile->Get(HistoName.c_str());
419  if (hOccHisto) {
420  if (hOccHisto->GetXaxis()->GetXmax() > maximum)
421  maximum = hOccHisto->GetXaxis()->GetNbins();
422  }
423  }
424  }
425  }
426  return maximum;
427 }
int station() const
Return the station number.
Definition: DTChamberId.h:42
std::string getLayerName(const DTLayerId &lId) const
Get the name of the layer.
std::string HistoName

◆ getSuperLayerName()

string DTNoiseComputation::getSuperLayerName ( const DTSuperLayerId slId) const
private

Get the name of the superLayer.

Definition at line 391 of file DTNoiseComputation.cc.

References DTSuperLayerId::chamberId(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), cond::impl::to_string(), and DTChamberId::wheel().

Referenced by beginRun(), and endJob().

391  {
392  const DTChamberId dtChId = dtSLId.chamberId();
393 
394  string superLayerName = "W" + std::to_string(dtChId.wheel()) + "_St" + std::to_string(dtChId.station()) + "_Sec" +
395  std::to_string(dtChId.sector()) + "_SL" + std::to_string(dtSLId.superlayer());
396 
397  return superLayerName;
398 }
int station() const
Return the station number.
Definition: DTChamberId.h:42
std::string to_string(const V &value)
Definition: OMSAccess.h:71
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
int sector() const
Definition: DTChamberId.h:49

◆ getYMaximum()

double DTNoiseComputation::getYMaximum ( const DTSuperLayerId slId) const
private

Definition at line 429 of file DTNoiseComputation.cc.

References getLayerName(), dttmaxenums::L, funct::pow(), and theFile.

Referenced by endJob().

429  {
430  double maximum = 0;
431  double dummy = pow(10., 10.);
432 
433  for (int L = 1; L <= 4; L++) {
434  DTLayerId layerId = DTLayerId(slId, L);
435  string HistoName = "DigiOccupancy_" + getLayerName(layerId);
436  theFile->cd();
437  TH1F *hOccHisto = (TH1F *)theFile->Get(HistoName.c_str());
438  if (hOccHisto) {
439  if (hOccHisto->GetMaximum(dummy) > maximum)
440  maximum = hOccHisto->GetMaximum(dummy);
441  }
442  }
443  return maximum;
444 }
std::string getLayerName(const DTLayerId &lId) const
Get the name of the layer.
std::string HistoName
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

◆ AvNoiseIntegratedPerChamber

std::map<DTChamberId, TH1F*> DTNoiseComputation::AvNoiseIntegratedPerChamber
private

Definition at line 102 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ AvNoiseIntegratedPerSuperLayer

std::map<DTSuperLayerId, TH1F*> DTNoiseComputation::AvNoiseIntegratedPerSuperLayer
private

Definition at line 108 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ AvNoisePerChamber

std::map<DTChamberId, TH1F*> DTNoiseComputation::AvNoisePerChamber
private

Definition at line 99 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ AvNoisePerSuperLayer

std::map<DTSuperLayerId, TH1F*> DTNoiseComputation::AvNoisePerSuperLayer
private

Definition at line 105 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ counter

int DTNoiseComputation::counter
private

Definition at line 57 of file DTNoiseComputation.h.

Referenced by counter.Counters::__getitem__().

◆ debug

bool DTNoiseComputation::debug
private

◆ dtGeom

edm::ESHandle<DTGeometry> DTNoiseComputation::dtGeom
private

Definition at line 62 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ dtGeomToken_

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTNoiseComputation::dtGeomToken_
private

Definition at line 63 of file DTNoiseComputation.h.

Referenced by beginRun().

◆ fastAnalysis

bool DTNoiseComputation::fastAnalysis
private

Definition at line 59 of file DTNoiseComputation.h.

Referenced by DTNoiseComputation(), and endJob().

◆ MaxEvents

int DTNoiseComputation::MaxEvents
private

Definition at line 58 of file DTNoiseComputation.h.

Referenced by beginRun(), and DTNoiseComputation().

◆ noisyC

std::map<std::pair<int, int>, TH1F*> DTNoiseComputation::noisyC
private

Definition at line 117 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ someHowNoisyC

std::map<std::pair<int, int>, TH1F*> DTNoiseComputation::someHowNoisyC
private

Definition at line 120 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ theAverageNoise

std::map<DTWireId, double> DTNoiseComputation::theAverageNoise
private

Definition at line 75 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ theEvtMap

std::map<DTLayerId, std::vector<TH2F*> > DTNoiseComputation::theEvtMap
private

Definition at line 78 of file DTNoiseComputation.h.

Referenced by beginRun(), and endJob().

◆ theFile

TFile* DTNoiseComputation::theFile
private

◆ theHistoEvtDistancePerWire

std::map<DTWireId, TH1F*> DTNoiseComputation::theHistoEvtDistancePerWire
private

Definition at line 81 of file DTNoiseComputation.h.

Referenced by endJob().

◆ theNewFile

TFile* DTNoiseComputation::theNewFile
private

Definition at line 69 of file DTNoiseComputation.h.

Referenced by DTNoiseComputation(), endJob(), and ~DTNoiseComputation().

◆ theTimeConstant

std::map<DTWireId, double> DTNoiseComputation::theTimeConstant
private

Definition at line 87 of file DTNoiseComputation.h.

Referenced by endJob().

◆ toComputeNoiseAverage

std::map<DTLayerId, bool> DTNoiseComputation::toComputeNoiseAverage
private

Definition at line 72 of file DTNoiseComputation.h.

◆ toDel

std::map<DTWireId, bool> DTNoiseComputation::toDel
private

Definition at line 84 of file DTNoiseComputation.h.

Referenced by endJob().