60 theFile =
new TFile(rootFileName.c_str(),
"RECREATE");
64 theFitter->setVerbosity(1);
67 theFitter->setFitSigma(sigmaFit);
84 cout <<
"[DTTTrigCalibration]Constructor called!" << endl;
92 cout <<
"[DTTTrigCalibration]Destructor called!" << endl;
111 cout <<
"[DTTTrigCalibration] #Event: " <<
event.id().event() << endl;
118 if(checkNoisyChannels) {
124 theSync->setES(eventSetup);
127 vector<DTChamberId> badChambers;
131 for (dtLayerIt = digis->begin();
132 dtLayerIt != digis->end();
137 const DTLayerId layerId = (*dtLayerIt).first;
140 bool badChamber=
false;
143 cout<<
"----------- Layer "<<layerId<<
" -------------"<<endl;
146 for(vector<DTChamberId>::const_iterator
chamber = badChambers.begin();
chamber != badChambers.end();
chamber++){
152 if(badChamber)
continue;
155 if((digiRange.second - digiRange.first) > maxDigiPerLayer){
157 cout<<
"Layer "<<layerId<<
"has too many digis ("<<(digiRange.second - digiRange.first)<<
")"<<endl;
158 badChambers.push_back(chId);
163 TH1F *hTBox = theHistoMap[slId];
167 hTBox =
new TH1F(getTBoxName(slId).c_str(),
"Time box (ns)",
int(0.25*32.0*maxTDCCounts/25.0), 0, maxTDCCounts);
169 cout <<
" New Time Box: " << hTBox->GetName() << endl;
170 theHistoMap[slId] = hTBox;
172 TH1F *hO = theOccupancyMap[layerId];
176 hO =
new TH1F(getOccupancyName(layerId).c_str(),
"Occupancy", 100, 0, 100);
178 cout <<
" New Time Box: " << hO->GetName() << endl;
179 theOccupancyMap[layerId] = hO;
184 digi != digiRange.second;
186 const DTWireId wireId(layerId, (*digi).wire());
189 if(checkNoisyChannels) {
190 bool isNoisy =
false;
191 bool isFEMasked =
false;
192 bool isTDCMasked =
false;
193 bool isTrigMask =
false;
196 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
199 cout <<
"Wire: " << wireId <<
" is noisy, skipping!" << endl;
208 offset = theSync->offset(layer, wireId, glPt);
210 hTBox->Fill((*digi).time()-
offset);
212 cout <<
" Filling Time Box: " << hTBox->GetName() << endl;
213 cout <<
" offset (ns): " << offset << endl;
214 cout <<
" time(ns): " << (*digi).time()-offset<< endl;
216 hO->Fill((*digi).wire());
224 cout <<
"[DTTTrigCalibration]Writing histos to file!" << endl;
228 for(map<DTSuperLayerId, TH1F*>::const_iterator slHisto = theHistoMap.begin();
229 slHisto != theHistoMap.end();
231 (*slHisto).second->Write();
233 for(map<DTLayerId, TH1F*>::const_iterator slHisto = theOccupancyMap.begin();
234 slHisto != theOccupancyMap.end();
236 (*slHisto).second->Write();
239 if(findTMeanAndSigma) {
244 for(map<DTSuperLayerId, TH1F*>::const_iterator slHisto = theHistoMap.begin();
245 slHisto != theHistoMap.end();
247 pair<double, double> meanAndSigma = theFitter->fitTimeBox((*slHisto).second);
248 tTrig->
set((*slHisto).first,
255 cout <<
" SL: " << (*slHisto).first
256 <<
" mean = " << meanAndSigma.first
257 <<
" sigma = " << meanAndSigma.second << endl;
268 cout <<
"[DTTTrigCalibration]Writing ttrig object to DB!" << endl;
272 string tTrigRecord =
"DTTtrigRcd";
285 stringstream theStream;
294 stringstream theStream;
303 static const double convToNs = 25./32.;
305 ttrig != tTrig->
end(); ttrig++) {
306 cout <<
"Wh: " << (*ttrig).first.wheelId
307 <<
" St: " << (*ttrig).first.stationId
308 <<
" Sc: " << (*ttrig).first.sectorId
309 <<
" Sl: " << (*ttrig).first.slId
310 <<
" TTrig mean (ns): " << (*ttrig).second.tTrig * convToNs
311 <<
" TTrig sigma (ns): " << (*ttrig).second.tTrms * convToNs<< endl;
318 TH1F* tTrig_YB1_Se10 =
new TH1F(
"tTrig_YB1_Se10",
"tTrig YB1_Se10",15,1,16);
319 TH1F* tTrig_YB2_Se10 =
new TH1F(
"tTrig_YB2_Se10",
"tTrig YB2_Se10",15,1,16);
320 TH1F* tTrig_YB2_Se11 =
new TH1F(
"tTrig_YB2_Se11",
"tTrig YB2_Se11",12,1,13);
322 static const double convToNs = 25./32.;
324 ttrig != tTrig->
end(); ttrig++) {
329 if ((*ttrig).second.tTrig * convToNs > 0 &&
330 (*ttrig).second.tTrig * convToNs < 32000 ) {
331 tTrigValue = (*ttrig).second.tTrig * convToNs;
332 tTrmsValue = (*ttrig).second.tTrms * convToNs;
337 stringstream binLabelStream;
338 if ((*ttrig).first.sectorId != 14) {
339 binx = ((*ttrig).first.stationId-1)*3 + (*ttrig).first.slId;
340 binLabelStream <<
"MB"<<(*ttrig).first.stationId<<
"_SL"<<(*ttrig).first.slId;
343 binx = 12 + (*ttrig).first.slId;
344 binLabelStream <<
"MB14_SL"<<(*ttrig).first.slId;
346 binLabelStream >> binLabel;
348 if ((*ttrig).first.wheelId == 2) {
349 if ((*ttrig).first.sectorId == 10 || (*ttrig).first.sectorId == 14) {
350 tTrig_YB2_Se10->Fill( binx,tTrigValue);
351 tTrig_YB2_Se10->SetBinError( binx, tTrmsValue);
352 tTrig_YB2_Se10->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
353 tTrig_YB2_Se10->GetYaxis()->SetTitle(
"ns");
356 tTrig_YB2_Se11->Fill( binx,tTrigValue);
357 tTrig_YB2_Se11->SetBinError( binx,tTrmsValue);
358 tTrig_YB2_Se11->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
359 tTrig_YB2_Se11->GetYaxis()->SetTitle(
"ns");
363 tTrig_YB1_Se10->Fill( binx,tTrigValue);
364 tTrig_YB1_Se10->SetBinError( binx,tTrmsValue);
365 tTrig_YB1_Se10->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
366 tTrig_YB1_Se10->GetYaxis()->SetTitle(
"ns");
370 tTrig_YB1_Se10->Write();
371 tTrig_YB2_Se10->Write();
372 tTrig_YB2_Se11->Write();
DTTTrigCalibration(const edm::ParameterSet &pset)
Constructor.
T getUntrackedParameter(std::string const &, T const &) const
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
DTChamberId chamberId() const
Return the corresponding ChamberId.
virtual ~DTTTrigCalibration()
Destructor.
int layer() const
Return the layer number.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
std::string getTBoxName(const DTSuperLayerId &slId) const
std::vector< std::pair< DTTtrigId, DTTtrigData > >::const_iterator const_iterator
Access methods to data.
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
Fill the time boxes.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void plotTTrig(const DTTtrig *tTrig) const
std::string getOccupancyName(const DTLayerId &slId) const
void endJob()
Fit the time box rising edge and write the resulting ttrig to the DB.
int superlayer() const
Return the superlayer number (deprecated method name)
const DTChamber * chamber() const
std::vector< DTDigi >::const_iterator const_iterator
const_iterator begin() const
std::pair< const_iterator, const_iterator > Range
int station() const
Return the station number.
void dumpTTrigMap(const DTTtrig *tTrig) const
const_iterator end() const
int wheel() const
Return the wheel number.
static void writeToDB(std::string record, T *payload)
T get(const Candidate &c)