CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DTAlbertoBenvenutiTask Class Reference

#include <DTAlbertoBenvenutiTask.h>

Inheritance diagram for DTAlbertoBenvenutiTask:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 DTAlbertoBenvenutiTask (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTAlbertoBenvenutiTask ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze. More...
 
void beginJob ()
 BeginJob. More...
 
void beginRun (const edm::Run &, const edm::EventSetup &)
 
void bookHistos (const DTWireId dtWire)
 Book the ME. More...
 
void endJob ()
 Endjob. More...
 
- 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)
 

Private Attributes

bool debug
 
edm::EDGetTokenT
< DTDigiCollection
DTUnpackerToken_
 
float kFactor
 
int maxTDCHits
 
edm::ESHandle< DTGeometrymuonGeom
 
int nevents
 
std::string outputFile
 
edm::ParameterSet parameters
 
edm::ESHandle< DTT0t0Map
 
std::map< DTWireId, TH1F * > TBMap
 
int tMax
 no needs to be precise. Value from PSets will always be used More...
 
float tTrig
 tTrig from the DB More...
 
edm::ESHandle< DTTtrigtTrigMap
 
float tTrigRMS
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 36 of file DTAlbertoBenvenutiTask.h.

Constructor & Destructor Documentation

DTAlbertoBenvenutiTask::DTAlbertoBenvenutiTask ( const edm::ParameterSet ps)

Constructor.

Definition at line 47 of file DTAlbertoBenvenutiTask.cc.

References gather_cfg::cout, debug, edm::ParameterSet::getUntrackedParameter(), download_sqlite_cfg::outputFile, Parameters::parameters, and AlCaHLTBitMon_QueryRunRegistry::string.

47  {
48 
49  debug = ps.getUntrackedParameter<bool>("debug", false);
50  if(debug)
51  cout<<"[DTAlbertoBenvenutiTask]: Constructor"<<endl;
52 
53  outputFile = ps.getUntrackedParameter<string>("outputFile", "DTDigiSources.root");
54  maxTDCHits = ps.getUntrackedParameter<int>("maxTDCHits",1000);
55 
56  // tMax (not yet from the DB)
57  tMax = parameters.getParameter<int>("defaultTmax");
58 
59  parameters = ps;
60 
61  //set Token(-s)
62  DTUnpackerToken_ = consumes<DTDigiCollection>(std::string("dtunpacker"));
63 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< DTDigiCollection > DTUnpackerToken_
int tMax
no needs to be precise. Value from PSets will always be used
tuple cout
Definition: gather_cfg.py:121
DTAlbertoBenvenutiTask::~DTAlbertoBenvenutiTask ( )
virtual

Destructor.

Definition at line 66 of file DTAlbertoBenvenutiTask.cc.

References gather_cfg::cout, debug, and cmsHarvester::nevents.

66  {
67 
68  if(debug)
69  cout << "DTAlbertoBenvenutiTask: analyzed " << nevents << " events" << endl;
70 
71 }
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

void DTAlbertoBenvenutiTask::analyze ( const edm::Event e,
const edm::EventSetup c 
)
protectedvirtual

Analyze.

Implements edm::EDAnalyzer.

Definition at line 231 of file DTAlbertoBenvenutiTask.cc.

References bookHistos(), DTTimeUnits::counts, debug, edm::EventSetup::get(), edm::Event::getByToken(), cmsHarvester::nevents, Parameters::parameters, edm::second(), and crabStatusFromReport::statusMap.

231  {
232 
233  nevents++;
234  if (nevents%1000 == 0 && debug) {}
235 
237  e.getByToken(DTUnpackerToken_, dtdigis);
238 
239  bool checkNoisyChannels = parameters.getUntrackedParameter<bool>("checkNoisyChannels",false);
241  if(checkNoisyChannels) {
242  // Get the map of noisy channels
243  c.get<DTStatusFlagRcd>().get(statusMap);
244  }
245 
246  int tdcCount = 0;
248  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
249  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
250  digiIt!=((*dtLayerId_It).second).second; ++digiIt){
251  tdcCount++;
252  }
253  }
254 
255  bool isSyncNoisy = false;
256  if (tdcCount > maxTDCHits) isSyncNoisy = true;
257 
258  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
259  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
260  digiIt!=((*dtLayerId_It).second).second; ++digiIt){
261 
262  bool isNoisy = false;
263  bool isFEMasked = false;
264  bool isTDCMasked = false;
265  bool isTrigMask = false;
266  bool isDead = false;
267  bool isNohv = false;
268  const DTWireId wireId(((*dtLayerId_It).first), (*digiIt).wire());
269  if(checkNoisyChannels) {
270  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
271  }
272 
273  // for clearness..
274 // const DTSuperLayerId dtSLId = ((*dtLayerId_It).first).superlayerId();
275 // uint32_t indexSL = dtSLId.rawId();
276 // const DTChamberId dtChId = dtSLId.chamberId();
277 // uint32_t indexCh = dtChId.rawId();
278 // int layer_number=((*dtLayerId_It).first).layer();
279 // int superlayer_number=dtSLId.superlayer();
280 // const DTLayerId dtLId = (*dtLayerId_It).first;
281 // uint32_t indexL = dtLId.rawId();
282 
283  float t0; float t0RMS;
284  int tdcTime = (*digiIt).countsTDC();
285 
286  if (parameters.getParameter<bool>("performPerWireT0Calibration")) {
287  const DTWireId dtWireId(((*dtLayerId_It).first), (*digiIt).wire());
288  t0Map->get(dtWireId, t0, t0RMS, DTTimeUnits::counts) ;
289  tdcTime += int(round(t0));
290  }
291 
292  // avoid to fill TB with noise
293  if ((!isNoisy ) && (!isSyncNoisy)) {
294  // TimeBoxes per wire
295  if (TBMap.find(wireId) == TBMap.end()){
296  bookHistos(wireId);
297  TBMap[wireId]->Fill(tdcTime);
298  }
299  else
300  TBMap[wireId]->Fill(tdcTime);
301  }
302  }
303  }
304 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< DTDigiCollection > DTUnpackerToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
U second(std::pair< T, U > const &p)
edm::ESHandle< DTT0 > t0Map
const T & get() const
Definition: EventSetup.h:55
std::vector< DTDigi >::const_iterator const_iterator
std::map< DTWireId, TH1F * > TBMap
void bookHistos(const DTWireId dtWire)
Book the ME.
void DTAlbertoBenvenutiTask::beginJob ( void  )
protectedvirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 131 of file DTAlbertoBenvenutiTask.cc.

References gather_cfg::cout, debug, and cmsHarvester::nevents.

131  {
132 
133  if(debug)
134  cout<<"[DTAlbertoBenvenutiTask]: BeginJob"<<endl;
135 
136  nevents = 0;
137 
138 }
tuple cout
Definition: gather_cfg.py:121
void DTAlbertoBenvenutiTask::beginRun ( const edm::Run ,
const edm::EventSetup context 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 142 of file DTAlbertoBenvenutiTask.cc.

References edm::EventSetup::get(), and Parameters::parameters.

142  {
143 
144  // Get the geometry
145  context.get<MuonGeometryRecord>().get(muonGeom);
146 
147  // tTrig
148  if (parameters.getUntrackedParameter<bool>("readDB", true))
149  context.get<DTTtrigRcd>().get(tTrigMap);
150 
151  // t0s
152  if (parameters.getParameter<bool>("performPerWireT0Calibration"))
153  context.get<DTT0Rcd>().get(t0Map);
154 
155 }
edm::ESHandle< DTGeometry > muonGeom
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ESHandle< DTT0 > t0Map
edm::ESHandle< DTTtrig > tTrigMap
const T & get() const
Definition: EventSetup.h:55
Definition: DTT0Rcd.h:9
void DTAlbertoBenvenutiTask::bookHistos ( const DTWireId  dtWire)
protected

Book the ME.

Definition at line 158 of file DTAlbertoBenvenutiTask.cc.

References DTSuperLayerId::chamberId(), DTTimeUnits::counts, gather_cfg::cout, debug, hltbtagharvestinganalyzer_cfi::histoName, DTLayerId::layer(), DTWireId::layerId(), Parameters::parameters, DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, DTSuperLayerId::superlayer(), DTLayerId::superlayerId(), and DTChamberId::wheel().

158  {
159 
160  if (debug) cout<<"[DTAlbertoBenvenutiTask]: booking"<<endl;
161 
162  stringstream wheel; wheel << dtWire.layerId().superlayerId().chamberId().wheel();
163  stringstream station; station << dtWire.layerId().superlayerId().chamberId().station();
164  stringstream sector; sector << dtWire.layerId().superlayerId().chamberId().sector();
165 
166  // Loop over all the chambers
167  vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
168  vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
169  // Loop over the SLs
170  for (; ch_it != ch_end; ++ch_it) {
171  DTChamberId ch = (*ch_it)->id();
172  if(ch == dtWire.layerId().superlayerId().chamberId()){
173  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
174  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
175  // Loop over the SLs
176  for(; sl_it != sl_end; ++sl_it) {
177  DTSuperLayerId sl = (*sl_it)->id();
178  stringstream superLayer; superLayer << sl.superlayer();
179  vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
180  vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
181  // Loop over the Ls
182  for(; l_it != l_end; ++l_it) {
183  DTLayerId layerId = (*l_it)->id();
184  stringstream layer; layer << layerId.layer();
185  const int firstWire = muonGeom->layer(layerId)->specificTopology().firstChannel();
186  const int lastWire = muonGeom->layer(layerId)->specificTopology().lastChannel();
187  // Loop overt the wires
188  for(int wr=firstWire; wr -lastWire <= 0; wr++) {
189 
190  stringstream wire; wire << wr;
191  DTWireId wrId(layerId, wr);
192 
193  string histoTag = "TimeBox";
194  string histoName = histoTag
195  + "_W" + wheel.str()
196  + "_St" + station.str()
197  + "_Sec" + sector.str()
198  + "_SL" + superLayer.str()
199  + "_L" + layer.str()
200  + "_wire" + wire.str();
201 
202  if (debug) cout<<"[DTAlbertoBenvenutiTask]: histoName "<<histoName<<endl;
203 
204  if ( parameters.getUntrackedParameter<bool>("readDB", false) )
205  // ttrig and rms are TDC counts
206  tTrigMap->get(dtWire.layerId().superlayerId(), tTrig, tTrigRMS, kFactor,
208  else tTrig = parameters.getParameter<int>("defaultTtrig");
209 
210  string histoTitle = histoName + " (TDC Counts)";
211  int timeBoxGranularity = parameters.getUntrackedParameter<int>("timeBoxGranularity",4);
212 
213  if (!parameters.getUntrackedParameter<bool>("readDB", true)) {
214  int maxTDCCounts = 6400 * parameters.getUntrackedParameter<int>("tdcRescale", 1);
215  TH1F *TB = new TH1F(histoName.c_str(),histoTitle.c_str(), maxTDCCounts/timeBoxGranularity, 0, maxTDCCounts);
216  TBMap[wrId] = TB;
217  }
218  else {
219  TH1F *TB = new TH1F(histoName.c_str(),histoTitle.c_str(), 2*tMax/timeBoxGranularity, tTrig-tMax, tTrig+2*tMax);
220  TBMap[wrId] = TB;
221  }
222 
223  } // loopover wires
224  } // loop over Ls
225  } // loop over SLs
226  } // if is the right chamber to book
227  } // loop over chambers
228 }
edm::ESHandle< DTGeometry > muonGeom
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
float tTrig
tTrig from the DB
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)
edm::ESHandle< DTTtrig > tTrigMap
int tMax
no needs to be precise. Value from PSets will always be used
std::map< DTWireId, TH1F * > TBMap
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:62
int sector() const
Definition: DTChamberId.h:61
tuple cout
Definition: gather_cfg.py:121
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void DTAlbertoBenvenutiTask::endJob ( void  )
protectedvirtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 74 of file DTAlbertoBenvenutiTask.cc.

References alignmentValidation::c1, counter, gather_cfg::cout, debug, convertXMLtoSQLite_cfg::fileName, python.multivaluedict::map(), and relativeConstraints::station.

74  {
75 
76  if(debug)
77  cout<<"[DTAlbertoBenvenutiTask] endjob called!"<<endl;
78 
79  map< DTChamberId, vector<TH1F*> > TBMap_perChamber;
80 
81  for(map<DTWireId, TH1F* >::const_iterator wHisto = TBMap.begin();
82  wHisto != TBMap.end();
83  wHisto++) {
84  DTChamberId chId = (*wHisto).first.layerId().superlayerId().chamberId();
85  TBMap_perChamber[chId].push_back((*wHisto).second);
86  }
87 
88 
89  for(map<DTChamberId, vector<TH1F*> >::const_iterator Histo = TBMap_perChamber.begin();
90  Histo != TBMap_perChamber.end();
91  Histo++) {
92  stringstream station; station << (*Histo).first.station();
93  stringstream sector; sector << (*Histo).first.sector();
94  stringstream wheel; wheel << (*Histo).first.wheel();
95 
96  string fileTag = "TimeBoxes";
97  string fileName = fileTag
98  + "_W" + wheel.str()
99  + "_Sec" + sector.str()
100  + "_St" + station.str()
101  + ".ps";
102 
103  TPostScript psFile(fileName.c_str(),111);
104  psFile.Range(20,26);
105  int counter = 0;
106  TCanvas c1("c1","",600,780);
107  c1.Divide(4,4);
108  psFile.NewPage();
109 
110  cout<<"[DTAlbertoBenvenutiTask] filling the file: "<<fileName<<endl;
111  for(vector<TH1F*>::const_iterator tbHisto = (*Histo).second.begin();
112  tbHisto != (*Histo).second.end();
113  tbHisto++) {
114  counter++;
115  c1.cd(counter);
116  (*tbHisto)->Draw();
117  if(counter%16 == 0 && counter>=16){
118  c1.Update();
119  psFile.NewPage();
120  c1.Clear();
121  c1.Divide(4,4);
122  counter=0;
123  }
124  } // loop over TB histos (divided per chamber)
125 
126  } //loop over the chambers
127 
128 }
std::map< DTWireId, TH1F * > TBMap
static std::atomic< unsigned int > counter
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

bool DTAlbertoBenvenutiTask::debug
private
edm::EDGetTokenT<DTDigiCollection> DTAlbertoBenvenutiTask::DTUnpackerToken_
private

Definition at line 88 of file DTAlbertoBenvenutiTask.h.

float DTAlbertoBenvenutiTask::kFactor
private

Definition at line 74 of file DTAlbertoBenvenutiTask.h.

int DTAlbertoBenvenutiTask::maxTDCHits
private

Definition at line 69 of file DTAlbertoBenvenutiTask.h.

edm::ESHandle<DTGeometry> DTAlbertoBenvenutiTask::muonGeom
private

Definition at line 78 of file DTAlbertoBenvenutiTask.h.

int DTAlbertoBenvenutiTask::nevents
private

Definition at line 65 of file DTAlbertoBenvenutiTask.h.

std::string DTAlbertoBenvenutiTask::outputFile
private

Definition at line 83 of file DTAlbertoBenvenutiTask.h.

edm::ParameterSet DTAlbertoBenvenutiTask::parameters
private
edm::ESHandle<DTT0> DTAlbertoBenvenutiTask::t0Map
private

Definition at line 81 of file DTAlbertoBenvenutiTask.h.

std::map<DTWireId, TH1F*> DTAlbertoBenvenutiTask::TBMap
private

Definition at line 85 of file DTAlbertoBenvenutiTask.h.

int DTAlbertoBenvenutiTask::tMax
private

no needs to be precise. Value from PSets will always be used

Definition at line 68 of file DTAlbertoBenvenutiTask.h.

float DTAlbertoBenvenutiTask::tTrig
private

tTrig from the DB

Definition at line 72 of file DTAlbertoBenvenutiTask.h.

edm::ESHandle<DTTtrig> DTAlbertoBenvenutiTask::tTrigMap
private

Definition at line 80 of file DTAlbertoBenvenutiTask.h.

float DTAlbertoBenvenutiTask::tTrigRMS
private

Definition at line 73 of file DTAlbertoBenvenutiTask.h.