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::EDAnalyzer 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...
 
 ~DTNoiseComputation () override
 Destructor. More...
 
- 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
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
 
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::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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 35 of file DTNoiseComputation.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 43 of file DTNoiseComputation.cc.

References gather_cfg::cout, debug, edm::ParameterSet::getUntrackedParameter(), DTAnalyzerDetailed_cfi::rootFileName, and interactiveExample::theFile.

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

Destructor.

Definition at line 387 of file DTNoiseComputation.cc.

References interactiveExample::theFile.

387  {
388 
389  theFile->Close();
390  theNewFile->Close();
391 
392 }

Member Function Documentation

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

Definition at line 50 of file DTNoiseComputation.h.

50 {}
void DTNoiseComputation::beginJob ( void  )
inlineoverridevirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 46 of file DTNoiseComputation.h.

References GeneralSetup::setup().

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

Definition at line 66 of file DTNoiseComputation.cc.

References stringResolutionProvider_cfi::bin, DTSuperLayerId::chamberId(), KineDebug3::count(), gather_cfg::cout, debug, HcalObjRepresent::Fill(), edm::EventSetup::get(), DTChamberId::station(), relativeConstraints::station, DTLayerId::superlayerId(), interactiveExample::theFile, DTChamberId::wheel(), and makeMuonMisalignmentScenario::wheel.

67 {
68  // Get the DT Geometry
69  setup.get<MuonGeometryRecord>().get(dtGeom);
70 
71  static int count = 0;
72 
73  if(count == 0){
74  string CheckHistoName;
75 
76  TH1F *hOccHisto;
77  TH1F *hAverageNoiseHisto;
78  TH1F *hAverageNoiseIntegratedHisto;
79  TH1F *hAverageNoiseHistoPerCh;
80  TH1F *hAverageNoiseIntegratedHistoPerCh;
81  TH2F *hEvtHisto;
82  string HistoName;
83  string Histo2Name;
84  string AverageNoiseName;
85  string AverageNoiseIntegratedName;
86  string AverageNoiseNamePerCh;
87  string AverageNoiseIntegratedNamePerCh;
88  TH1F *hnoisyC;
89  TH1F *hsomeHowNoisyC;
90 
91  // Loop over all the chambers
92  vector<const DTChamber*>::const_iterator ch_it = dtGeom->chambers().begin();
93  vector<const DTChamber*>::const_iterator ch_end = dtGeom->chambers().end();
94  // Loop over the SLs
95  for (; ch_it != ch_end; ++ch_it) {
96  DTChamberId ch = (*ch_it)->id();
97  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
98  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
99  // Loop over the SLs
100  for(; sl_it != sl_end; ++sl_it) {
101  // DTSuperLayerId sl = (*sl_it)->id();
102  vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
103  vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
104  // Loop over the Ls
105  for(; l_it != l_end; ++l_it) {
106  DTLayerId dtLId = (*l_it)->id();
107 
108  //check if the layer has digi
109  theFile->cd();
110  CheckHistoName = "DigiOccupancy_" + getLayerName(dtLId);
111  TH1F *hCheckHisto = (TH1F *) theFile->Get(CheckHistoName.c_str());
112  if(hCheckHisto){
113  delete hCheckHisto;
114  string wheel = std::to_string(ch.wheel());
115  string station = std::to_string(ch.station());
116 
117  if(someHowNoisyC.find(make_pair(ch.wheel(),ch.station())) == someHowNoisyC.end()) {
118  TString histoName_someHowNoisy = "somehowNoisyCell_W"+wheel+"_St"+station;
119  hsomeHowNoisyC = new TH1F(histoName_someHowNoisy,histoName_someHowNoisy,getMaxNumBins(ch),1,getMaxNumBins(ch)+1);
120  someHowNoisyC[make_pair(ch.wheel(),ch.station())]=hsomeHowNoisyC;
121  }
122 
123  if(noisyC.find(make_pair(ch.wheel(),ch.station())) == noisyC.end()) {
124  TString histoName_noisy = "noisyCell_W"+wheel+"_St"+station;
125  hnoisyC = new TH1F(histoName_noisy,histoName_noisy,getMaxNumBins(ch),1,getMaxNumBins(ch)+1);
126  noisyC[make_pair(ch.wheel(),ch.station())]=hnoisyC;
127  }
128 
129  //to fill a map with the average noise per wire and fill new noise histo
130  if(AvNoisePerSuperLayer.find(dtLId.superlayerId()) == AvNoisePerSuperLayer.end()) {
131  AverageNoiseName = "AverageNoise_" + getSuperLayerName(dtLId.superlayerId());
132  hAverageNoiseHisto = new TH1F(AverageNoiseName.c_str(), AverageNoiseName.c_str(), 200, 0, 10000);
133  AverageNoiseIntegratedName = "AverageNoiseIntegrated_" + getSuperLayerName(dtLId.superlayerId());
134  hAverageNoiseIntegratedHisto = new TH1F(AverageNoiseIntegratedName.c_str(), AverageNoiseIntegratedName.c_str(), 200, 0, 10000);
135  AvNoisePerSuperLayer[dtLId.superlayerId()] = hAverageNoiseHisto;
136  AvNoiseIntegratedPerSuperLayer[dtLId.superlayerId()] = hAverageNoiseIntegratedHisto;
137  if(debug){
138  cout << " New Average Noise Histo per SuperLayer : " << hAverageNoiseHisto->GetName() << endl;
139  cout << " New Average Noise Integrated Histo per SuperLayer : " << hAverageNoiseHisto->GetName() << endl;
140  }
141  }
142  if(AvNoisePerChamber.find(dtLId.superlayerId().chamberId()) == AvNoisePerChamber.end()) {
143  AverageNoiseNamePerCh = "AverageNoise_" + getChamberName(dtLId);
144  hAverageNoiseHistoPerCh = new TH1F(AverageNoiseNamePerCh.c_str(), AverageNoiseNamePerCh.c_str(), 200, 0, 10000);
145  AverageNoiseIntegratedNamePerCh = "AverageNoiseIntegrated_" + getChamberName(dtLId);
146  hAverageNoiseIntegratedHistoPerCh = new TH1F(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 
193  // book the digi event plots every 1000 events
194  int updates = MaxEvents/1000;
195  for(int evt=0; evt<updates; evt++){
196  Histo2Name = "DigiPerWirePerEvent_" + getLayerName(dtLId) + "_" + std::to_string(evt);
197  theFile->cd();
198  hEvtHisto = (TH2F *) theFile->Get(Histo2Name.c_str());
199  if(hEvtHisto){
200  if(debug)
201  cout << " New Histo with the number of events per evt per wire: " << hEvtHisto->GetName() << endl;
202  theEvtMap[dtLId].push_back(hEvtHisto);
203  }
204  }
205 
206  }// done if the layer has digi
207  }// loop over layers
208  }// loop over superlayers
209  }// loop over chambers
210 
211  count++;
212  }
213 
214 }
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:102
int getMaxNumBins(const DTChamberId &chId) const
std::map< std::pair< int, int >, TH1F * > someHowNoisyC
DTChamberId chamberId() const
Return the corresponding ChamberId.
edm::ESHandle< DTGeometry > dtGeom
std::map< DTLayerId, std::vector< TH2F * > > theEvtMap
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
std::string getChamberName(const DTLayerId &lId) const
Get the name of the chamber.
std::map< std::pair< int, int >, TH1F * > noisyC
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
bin
set the eta bin as selection string.
std::map< DTChamberId, TH1F * > AvNoisePerChamber
std::map< DTSuperLayerId, TH1F * > AvNoiseIntegratedPerSuperLayer
std::string HistoName
std::string getLayerName(const DTLayerId &lId) const
Get the name of the layer.
std::map< DTSuperLayerId, TH1F * > AvNoisePerSuperLayer
std::string getSuperLayerName(const DTSuperLayerId &slId) const
Get the name of the superLayer.
T get() const
Definition: EventSetup.h:71
std::map< DTWireId, double > theAverageNoise
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
std::map< DTChamberId, TH1F * > AvNoiseIntegratedPerChamber
void DTNoiseComputation::endJob ( void  )
overridevirtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 216 of file DTNoiseComputation.cc.

References stringResolutionProvider_cfi::bin, alignmentValidation::c1, gather_cfg::cout, trackerHits::histo, mps_fire::i, createfilelist::int, DTLayerId::layer(), create_public_lumi_plots::leg, genParticles_cff::map, RecoTauPiZeroBuilderPlugins_cfi::par0, RecoTauPiZeroBuilderPlugins_cfi::par1, and interactiveExample::theFile.

Referenced by o2olib.O2ORunMgr::executeJob().

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

Get the name of the chamber.

Definition at line 424 of file DTNoiseComputation.cc.

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

424  {
425 
426  const DTSuperLayerId dtSLId = lId.superlayerId();
427  const DTChamberId dtChId = dtSLId.chamberId();
428  string chamberName =
429  "W" + std::to_string(dtChId.wheel())
430  + "_St" + std::to_string(dtChId.station())
431  + "_Sec" + std::to_string(dtChId.sector());
432 
433  return chamberName;
434 }
DTChamberId chamberId() const
Return the corresponding ChamberId.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
string DTNoiseComputation::getLayerName ( const DTLayerId lId) const
private

Get the name of the layer.

Definition at line 395 of file DTNoiseComputation.cc.

References DTSuperLayerId::chamberId(), DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), DTLayerId::superlayerId(), and DTChamberId::wheel().

395  {
396 
397  const DTSuperLayerId dtSLId = lId.superlayerId();
398  const DTChamberId dtChId = dtSLId.chamberId();
399  string layerName =
400  "W" + std::to_string(dtChId.wheel())
401  + "_St" + std::to_string(dtChId.station())
402  + "_Sec" + std::to_string(dtChId.sector())
403  + "_SL" + std::to_string(dtSLId.superlayer())
404  + "_L" + std::to_string(lId.layer());
405 
406  return layerName;
407 }
DTChamberId chamberId() const
Return the corresponding ChamberId.
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
int DTNoiseComputation::getMaxNumBins ( const DTChamberId chId) const
private

Definition at line 437 of file DTNoiseComputation.cc.

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

437  {
438 
439  int maximum=0;
440 
441  for(int SL=1; SL<=3; SL++){
442  if(!(chId.station()==4 && SL==2)){
443  for (int L=1; L<=4; L++){
444  DTLayerId layerId = DTLayerId(chId, SL, L);
445  string HistoName = "DigiOccupancy_" + getLayerName(layerId);
446  theFile->cd();
447  TH1F *hOccHisto = (TH1F *) theFile->Get(HistoName.c_str());
448  if(hOccHisto){
449  if (hOccHisto->GetXaxis()->GetXmax()>maximum)
450  maximum = hOccHisto->GetXaxis()->GetNbins();
451  }
452  }
453  }
454  }
455  return maximum;
456 }
std::string HistoName
std::string getLayerName(const DTLayerId &lId) const
Get the name of the layer.
int station() const
Return the station number.
Definition: DTChamberId.h:51
string DTNoiseComputation::getSuperLayerName ( const DTSuperLayerId slId) const
private

Get the name of the superLayer.

Definition at line 410 of file DTNoiseComputation.cc.

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

410  {
411 
412  const DTChamberId dtChId = dtSLId.chamberId();
413 
414  string superLayerName =
415  "W" + std::to_string(dtChId.wheel())
416  + "_St" + std::to_string(dtChId.station())
417  + "_Sec" + std::to_string(dtChId.sector())
418  + "_SL" + std::to_string(dtSLId.superlayer());
419 
420  return superLayerName;
421 }
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
double DTNoiseComputation::getYMaximum ( const DTSuperLayerId slId) const
private

Definition at line 459 of file DTNoiseComputation.cc.

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

459  {
460 
461  double maximum=0;
462  double dummy = pow(10.,10.);
463 
464  for (int L=1; L<=4; L++){
465  DTLayerId layerId = DTLayerId(slId, L);
466  string HistoName = "DigiOccupancy_" + getLayerName(layerId);
467  theFile->cd();
468  TH1F *hOccHisto = (TH1F *) theFile->Get(HistoName.c_str());
469  if(hOccHisto){
470  if (hOccHisto->GetMaximum(dummy)>maximum)
471  maximum = hOccHisto->GetMaximum(dummy);
472  }
473  }
474  return maximum;
475 }
std::string HistoName
std::string getLayerName(const DTLayerId &lId) const
Get the name of the layer.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

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

Definition at line 105 of file DTNoiseComputation.h.

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

Definition at line 111 of file DTNoiseComputation.h.

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

Definition at line 102 of file DTNoiseComputation.h.

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

Definition at line 108 of file DTNoiseComputation.h.

int DTNoiseComputation::counter
private

Definition at line 61 of file DTNoiseComputation.h.

Referenced by counter.Counters::__getitem__().

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

Definition at line 66 of file DTNoiseComputation.h.

bool DTNoiseComputation::fastAnalysis
private

Definition at line 63 of file DTNoiseComputation.h.

int DTNoiseComputation::MaxEvents
private

Definition at line 62 of file DTNoiseComputation.h.

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

Definition at line 120 of file DTNoiseComputation.h.

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

Definition at line 123 of file DTNoiseComputation.h.

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

Definition at line 78 of file DTNoiseComputation.h.

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

Definition at line 81 of file DTNoiseComputation.h.

TFile* DTNoiseComputation::theFile
private

Definition at line 69 of file DTNoiseComputation.h.

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

Definition at line 84 of file DTNoiseComputation.h.

TFile* DTNoiseComputation::theNewFile
private

Definition at line 72 of file DTNoiseComputation.h.

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

Definition at line 90 of file DTNoiseComputation.h.

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

Definition at line 75 of file DTNoiseComputation.h.

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

Definition at line 87 of file DTNoiseComputation.h.