CMS 3D CMS Logo

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 &) override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 DTTPAnalyzer (const edm::ParameterSet &)
 
void endJob () override
 
 ~DTTPAnalyzer () 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 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 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_
 
std::unique_ptr< DTTTrigBaseSynctTrigSync_
 

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

Author
A. Vilela Pereira

Definition at line 20 of file DTTPAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 68 of file DTTPAnalyzer.cc.

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

68  :
69  subtractT0_(pset.getParameter<bool>("subtractT0")),
70  digiLabel_(pset.getParameter<edm::InputTag>("digiLabel")) {
71 
73  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
74  rootFile_->cd();
75 
76  if(subtractT0_)
77  tTrigSync_ = std::unique_ptr<DTTTrigBaseSync>{DTTTrigSyncFactory::get()->create(pset.getParameter<std::string>("tTrigMode"),
78  pset.getParameter<edm::ParameterSet>("tTrigModeConfig"))};
79 
80 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag digiLabel_
Definition: DTTPAnalyzer.cc:34
TFile * rootFile_
Definition: DTTPAnalyzer.cc:36
std::unique_ptr< DTTTrigBaseSync > tTrigSync_
Definition: DTTPAnalyzer.cc:39
T get(const Candidate &c)
Definition: component.h:55
DTTPAnalyzer::~DTTPAnalyzer ( )
override

Definition at line 82 of file DTTPAnalyzer.cc.

References rootFile_.

82  {
83  rootFile_->Close();
84 }
TFile * rootFile_
Definition: DTTPAnalyzer.cc:36

Member Function Documentation

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

Definition at line 98 of file DTTPAnalyzer.cc.

References digiLabel_, nDigisPerWire_, PFRecoTauDiscriminationByIsolation_cfi::offset, subtractT0_, sumW2PerWire_, sumWPerWire_, cscNeutronWriter_cfi::t0, and tTrigSync_.

98  {
99 
100  // Get the digis from the event
102  event.getByLabel(digiLabel_, digis);
103 
104  // Iterate through all digi collections ordered by LayerId
106  for (dtLayerIt = digis->begin();
107  dtLayerIt != digis->end();
108  ++dtLayerIt){
109  // Get the iterators over the digis associated with this LayerId
110  const DTDigiCollection::Range& digiRange = (*dtLayerIt).second;
111 
112  // Get the layerId
113  const DTLayerId layerId = (*dtLayerIt).first; //FIXME: check to be in the right sector
114 
115  // Loop over all digis in the given layer
116  for (DTDigiCollection::const_iterator digi = digiRange.first;
117  digi != digiRange.second;
118  ++digi) {
119  const DTWireId wireId( layerId, (*digi).wire() );
120 
121  double t0 = (*digi).countsTDC();
122 
123  //FIXME: Reject digis not coming from TP
124 
125  if(subtractT0_) {
126  const DTLayer* layer = nullptr; //fake
127  const GlobalPoint glPt; //fake
128  double offset = tTrigSync_->offset(layer, wireId, glPt);
129  t0 -= offset;
130  }
131 
132  if(nDigisPerWire_.find(wireId) == nDigisPerWire_.end()){
133  nDigisPerWire_[wireId] = 0;
134  sumWPerWire_[wireId] = 0.;
135  sumW2PerWire_[wireId] = 0.;
136  }
137 
138  ++nDigisPerWire_[wireId];
139  sumWPerWire_[wireId] += t0;
140  sumW2PerWire_[wireId] += t0*t0;
141  }
142 
143  }
144 }
edm::InputTag digiLabel_
Definition: DTTPAnalyzer.cc:34
std::map< DTWireId, double > sumWPerWire_
Definition: DTTPAnalyzer.cc:43
std::map< DTWireId, int > nDigisPerWire_
Definition: DTTPAnalyzer.cc:42
std::unique_ptr< DTTTrigBaseSync > tTrigSync_
Definition: DTTPAnalyzer.cc:39
std::map< DTWireId, double > sumW2PerWire_
Definition: DTTPAnalyzer.cc:44
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 
)
override

Definition at line 86 of file DTTPAnalyzer.cc.

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

86  {
87  // Get the t0 map from the DB
88  if(subtractT0_){
89  /*ESHandle<DTT0> t0;
90  setup.get<DTT0Rcd>().get(t0);
91  tZeroMap_ = &*t0;*/
92  tTrigSync_->setES(setup);
93  }
94  // Get the DT Geometry
95  setup.get<MuonGeometryRecord>().get(dtGeom_);
96 }
std::unique_ptr< DTTTrigBaseSync > tTrigSync_
Definition: DTTPAnalyzer.cc:39
T get() const
Definition: EventSetup.h:71
edm::ESHandle< DTGeometry > dtGeom_
Definition: DTTPAnalyzer.cc:38
void DTTPAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 146 of file DTTPAnalyzer.cc.

References DTTopology::channels(), dtGeom_, DTTopology::firstChannel(), getHistoName(), crabWrapper::key, DTGeometry::layer(), DTWireId::layerId(), SiStripPI::mean, nDigisPerWire_, SiStripPI::rms, rootFile_, DTLayer::specificTopology(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, sumW2PerWire_, sumWPerWire_, and DTWireId::wire().

Referenced by o2olib.O2ORunMgr::executeJob().

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

Definition at line 188 of file DTTPAnalyzer.cc.

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

Referenced by endJob().

188  {
189  std::string histoName;
190  std::stringstream theStream;
191  theStream << "Ch_" << lId.wheel() << "_" << lId.station() << "_" << lId.sector()
192  << "_SL" << lId.superlayer() << "_L" << lId.layer();
193  theStream >> histoName;
194  return histoName;
195 }
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
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

Member Data Documentation

edm::InputTag DTTPAnalyzer::digiLabel_
private

Definition at line 34 of file DTTPAnalyzer.cc.

Referenced by analyze().

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

Definition at line 38 of file DTTPAnalyzer.cc.

Referenced by beginRun(), and endJob().

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

Definition at line 42 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

TFile* DTTPAnalyzer::rootFile_
private

Definition at line 36 of file DTTPAnalyzer.cc.

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

bool DTTPAnalyzer::subtractT0_
private

Definition at line 33 of file DTTPAnalyzer.cc.

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

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

Definition at line 44 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

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

Definition at line 43 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

std::unique_ptr<DTTTrigBaseSync> DTTPAnalyzer::tTrigSync_
private

Definition at line 39 of file DTTPAnalyzer.cc.

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