CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTTPAnalyzer Class Reference
Inheritance diagram for DTTPAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 
void beginRun (const edm::Run &, const edm::EventSetup &)
 
 DTTPAnalyzer (const edm::ParameterSet &)
 
void endJob ()
 
virtual ~DTTPAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

std::string getHistoName (const DTLayerId &)
 

Private Attributes

edm::InputTag digiLabel_
 
edm::ESHandle< DTGeometrydtGeom_
 
std::map< DTWireId, int > nDigisPerWire_
 
TFile * rootFile_
 
bool subtractT0_
 
std::map< DTWireId, double > sumW2PerWire_
 
std::map< DTWireId, double > sumWPerWire_
 
DTTTrigBaseSynctTrigSync_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 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

Date:
2011/02/10 20:38:59
Revision:
1.1
Author
A. Vilela Pereira

Definition at line 22 of file DTTPAnalyzer.cc.

Constructor & Destructor Documentation

DTTPAnalyzer::DTTPAnalyzer ( const edm::ParameterSet pset)

Definition at line 70 of file DTTPAnalyzer.cc.

References reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), rootFile_, dtT0Analyzer_cfg::rootFileName, AlCaHLTBitMon_QueryRunRegistry::string, subtractT0_, and tTrigSync_.

70  :
71  subtractT0_(pset.getParameter<bool>("subtractT0")),
72  digiLabel_(pset.getParameter<edm::InputTag>("digiLabel")),
73  tTrigSync_(0) {
74 
76  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
77  rootFile_->cd();
78 
79  if(subtractT0_)
80  tTrigSync_ = DTTTrigSyncFactory::get()->create(pset.getParameter<std::string>("tTrigMode"),
81  pset.getParameter<edm::ParameterSet>("tTrigModeConfig"));
82 
83 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag digiLabel_
Definition: DTTPAnalyzer.cc:36
DTTTrigBaseSync * tTrigSync_
Definition: DTTPAnalyzer.cc:41
TFile * rootFile_
Definition: DTTPAnalyzer.cc:38
T get(const Candidate &c)
Definition: component.h:56
DTTPAnalyzer::~DTTPAnalyzer ( )
virtual

Definition at line 85 of file DTTPAnalyzer.cc.

References rootFile_.

85  {
86  rootFile_->Close();
87 }
TFile * rootFile_
Definition: DTTPAnalyzer.cc:38

Member Function Documentation

void DTTPAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 101 of file DTTPAnalyzer.cc.

References digiLabel_, nDigisPerWire_, DTTTrigBaseSync::offset(), evf::evtn::offset(), subtractT0_, sumW2PerWire_, sumWPerWire_, and tTrigSync_.

101  {
102 
103  // Get the digis from the event
105  event.getByLabel(digiLabel_, digis);
106 
107  // Iterate through all digi collections ordered by LayerId
109  for (dtLayerIt = digis->begin();
110  dtLayerIt != digis->end();
111  ++dtLayerIt){
112  // Get the iterators over the digis associated with this LayerId
113  const DTDigiCollection::Range& digiRange = (*dtLayerIt).second;
114 
115  // Get the layerId
116  const DTLayerId layerId = (*dtLayerIt).first; //FIXME: check to be in the right sector
117 
118  // Loop over all digis in the given layer
119  for (DTDigiCollection::const_iterator digi = digiRange.first;
120  digi != digiRange.second;
121  digi++) {
122  const DTWireId wireId( layerId, (*digi).wire() );
123 
124  double t0 = (*digi).countsTDC();
125 
126  //FIXME: Reject digis not coming from TP
127 
128  if(subtractT0_) {
129  const DTLayer* layer = 0; //fake
130  const GlobalPoint glPt; //fake
131  double offset = tTrigSync_->offset(layer, wireId, glPt);
132  t0 -= offset;
133  }
134 
135  if(nDigisPerWire_.find(wireId) == nDigisPerWire_.end()){
136  nDigisPerWire_[wireId] = 0;
137  sumWPerWire_[wireId] = 0.;
138  sumW2PerWire_[wireId] = 0.;
139  }
140 
141  ++nDigisPerWire_[wireId];
142  sumWPerWire_[wireId] += t0;
143  sumW2PerWire_[wireId] += t0*t0;
144  }
145 
146  }
147 }
edm::InputTag digiLabel_
Definition: DTTPAnalyzer.cc:36
std::map< DTWireId, double > sumWPerWire_
Definition: DTTPAnalyzer.cc:45
double offset(const DTLayer *layer, const DTWireId &wireId, const GlobalPoint &globalPos)
std::map< DTWireId, int > nDigisPerWire_
Definition: DTTPAnalyzer.cc:44
DTTTrigBaseSync * tTrigSync_
Definition: DTTPAnalyzer.cc:41
unsigned int offset(bool)
std::map< DTWireId, double > sumW2PerWire_
Definition: DTTPAnalyzer.cc:46
std::vector< DigiType >::const_iterator const_iterator
std::pair< const_iterator, const_iterator > Range
void DTTPAnalyzer::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 89 of file DTTPAnalyzer.cc.

References dtGeom_, edm::EventSetup::get(), DTTTrigBaseSync::setES(), subtractT0_, and tTrigSync_.

89  {
90  // Get the t0 map from the DB
91  if(subtractT0_){
92  /*ESHandle<DTT0> t0;
93  setup.get<DTT0Rcd>().get(t0);
94  tZeroMap_ = &*t0;*/
95  tTrigSync_->setES(setup);
96  }
97  // Get the DT Geometry
98  setup.get<MuonGeometryRecord>().get(dtGeom_);
99 }
DTTTrigBaseSync * tTrigSync_
Definition: DTTPAnalyzer.cc:41
virtual void setES(const edm::EventSetup &setup)=0
Pass the Event Setup to the synchronization module at each event.
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< DTGeometry > dtGeom_
Definition: DTTPAnalyzer.cc:40
void DTTPAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 149 of file DTTPAnalyzer.cc.

References dtGeom_, getHistoName(), combine::key, DTWireId::layerId(), timingPdfMaker::mean, nDigisPerWire_, plotscripts::rms(), rootFile_, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, sumW2PerWire_, sumWPerWire_, and DTWireId::wire().

149  {
150  rootFile_->cd();
151  std::map<DTLayerId, TH1F*> meanHistoMap;
152  std::map<DTLayerId, TH1F*> sigmaHistoMap;
153  for(std::map<DTWireId, int>::const_iterator wireIdIt = nDigisPerWire_.begin();
154  wireIdIt != nDigisPerWire_.end(); ++wireIdIt){
155  DTWireId wireId((*wireIdIt).first);
156 
157  int nDigis = nDigisPerWire_[wireId];
158  double sumW = sumWPerWire_[wireId];
159  double sumW2 = sumW2PerWire_[wireId];
160 
161  double mean = sumW/nDigis;
162  double rms = sumW2/nDigis - mean*mean;
163  rms = sqrt(rms);
164 
165  DTLayerId layerId = wireId.layerId();
166  if(meanHistoMap.find(layerId) == meanHistoMap.end()) {
167  std::string histoName = getHistoName(layerId);
168  const int firstChannel = dtGeom_->layer(layerId)->specificTopology().firstChannel();
169  const int nWires = dtGeom_->layer(layerId)->specificTopology().channels();
170  TH1F* meanHistoTP = new TH1F((histoName + "_tpMean").c_str(),"mean from test pulses by channel",
171  nWires,firstChannel,(firstChannel + nWires));
172  TH1F* sigmaHistoTP = new TH1F((histoName + "_tpSigma").c_str(),"sigma from test pulses by channel",
173  nWires,firstChannel,(firstChannel + nWires));
174  meanHistoMap[layerId] = meanHistoTP;
175  sigmaHistoMap[layerId] = sigmaHistoTP;
176  }
177  // Fill the histograms
178  int nBin = meanHistoMap[layerId]->GetXaxis()->FindFixBin(wireId.wire());
179  meanHistoMap[layerId]->SetBinContent(nBin,mean);
180  sigmaHistoMap[layerId]->SetBinContent(nBin,rms);
181  }
182 
183  for(std::map<DTLayerId, TH1F*>::const_iterator key = meanHistoMap.begin();
184  key != meanHistoMap.end(); ++key){
185  meanHistoMap[(*key).first]->Write();
186  sigmaHistoMap[(*key).first]->Write();
187  }
188 
189 }
std::map< DTWireId, double > sumWPerWire_
Definition: DTTPAnalyzer.cc:45
std::map< DTWireId, int > nDigisPerWire_
Definition: DTTPAnalyzer.cc:44
TFile * rootFile_
Definition: DTTPAnalyzer.cc:38
std::string getHistoName(const DTLayerId &)
T sqrt(T t)
Definition: SSEVec.h:48
std::map< DTWireId, double > sumW2PerWire_
Definition: DTTPAnalyzer.cc:46
list key
Definition: combine.py:13
edm::ESHandle< DTGeometry > dtGeom_
Definition: DTTPAnalyzer.cc:40
std::string DTTPAnalyzer::getHistoName ( const DTLayerId lId)
private

Definition at line 191 of file DTTPAnalyzer.cc.

References DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), AlCaHLTBitMon_QueryRunRegistry::string, DTSuperLayerId::superlayer(), and DTChamberId::wheel().

Referenced by endJob().

191  {
192  std::string histoName;
193  std::stringstream theStream;
194  theStream << "Ch_" << lId.wheel() << "_" << lId.station() << "_" << lId.sector()
195  << "_SL" << lId.superlayer() << "_L" << lId.layer();
196  theStream >> histoName;
197  return histoName;
198 }
int layer() const
Return the layer number.
Definition: DTLayerId.h:55
int superlayer() const
Return the superlayer number (deprecated method name)
int sector() const
Definition: DTChamberId.h:63
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47

Member Data Documentation

edm::InputTag DTTPAnalyzer::digiLabel_
private

Definition at line 36 of file DTTPAnalyzer.cc.

Referenced by analyze().

edm::ESHandle<DTGeometry> DTTPAnalyzer::dtGeom_
private

Definition at line 40 of file DTTPAnalyzer.cc.

Referenced by beginRun(), and endJob().

std::map<DTWireId, int> DTTPAnalyzer::nDigisPerWire_
private

Definition at line 44 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

TFile* DTTPAnalyzer::rootFile_
private

Definition at line 38 of file DTTPAnalyzer.cc.

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

bool DTTPAnalyzer::subtractT0_
private

Definition at line 35 of file DTTPAnalyzer.cc.

Referenced by analyze(), beginRun(), and DTTPAnalyzer().

std::map<DTWireId, double> DTTPAnalyzer::sumW2PerWire_
private

Definition at line 46 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

std::map<DTWireId, double> DTTPAnalyzer::sumWPerWire_
private

Definition at line 45 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

DTTTrigBaseSync* DTTPAnalyzer::tTrigSync_
private

Definition at line 41 of file DTTPAnalyzer.cc.

Referenced by analyze(), beginRun(), and DTTPAnalyzer().