62 theFile =
new TFile(rootFileName.c_str(),
"RECREATE");
66 theFitter->setVerbosity(1);
69 theFitter->setFitSigma(sigmaFit);
86 cout <<
"[DTTTrigCalibration]Constructor called!" << endl;
94 cout <<
"[DTTTrigCalibration]Destructor called!" << endl;
113 cout <<
"[DTTTrigCalibration] #Event: " <<
event.id().event() << endl;
126 theSync->setES(eventSetup);
129 vector<DTChamberId> badChambers;
133 for (dtLayerIt = digis->begin();
134 dtLayerIt != digis->end();
139 const DTLayerId layerId = (*dtLayerIt).first;
142 bool badChamber=
false;
145 cout<<
"----------- Layer "<<layerId<<
" -------------"<<endl;
148 for(vector<DTChamberId>::const_iterator
chamber = badChambers.begin();
chamber != badChambers.end();
chamber++){
154 if(badChamber)
continue;
157 if((digiRange.second - digiRange.first) > maxDigiPerLayer){
159 cout<<
"Layer "<<layerId<<
"has too many digis ("<<(digiRange.second - digiRange.first)<<
")"<<endl;
160 badChambers.push_back(chId);
165 TH1F *hTBox = theHistoMap[slId];
169 hTBox =
new TH1F(getTBoxName(slId).c_str(),
"Time box (ns)",
int(0.25*32.0*maxTDCCounts/25.0), 0, maxTDCCounts);
171 cout <<
" New Time Box: " << hTBox->GetName() << endl;
172 theHistoMap[slId] = hTBox;
174 TH1F *hO = theOccupancyMap[layerId];
178 hO =
new TH1F(getOccupancyName(layerId).c_str(),
"Occupancy", 100, 0, 100);
180 cout <<
" New Time Box: " << hO->GetName() << endl;
181 theOccupancyMap[layerId] = hO;
186 digi != digiRange.second;
188 const DTWireId wireId(layerId, (*digi).wire());
192 bool isNoisy =
false;
193 bool isFEMasked =
false;
194 bool isTDCMasked =
false;
195 bool isTrigMask =
false;
198 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
201 cout <<
"Wire: " << wireId <<
" is noisy, skipping!" << endl;
210 offset = theSync->offset(layer, wireId, glPt);
212 hTBox->Fill((*digi).time()-
offset);
214 cout <<
" Filling Time Box: " << hTBox->GetName() << endl;
215 cout <<
" offset (ns): " << offset << endl;
216 cout <<
" time(ns): " << (*digi).time()-offset<< endl;
218 hO->Fill((*digi).wire());
226 cout <<
"[DTTTrigCalibration]Writing histos to file!" << endl;
230 for(map<DTSuperLayerId, TH1F*>::const_iterator slHisto = theHistoMap.begin();
231 slHisto != theHistoMap.end();
233 (*slHisto).second->Write();
235 for(map<DTLayerId, TH1F*>::const_iterator slHisto = theOccupancyMap.begin();
236 slHisto != theOccupancyMap.end();
238 (*slHisto).second->Write();
241 if(findTMeanAndSigma) {
246 for(map<DTSuperLayerId, TH1F*>::const_iterator slHisto = theHistoMap.begin();
247 slHisto != theHistoMap.end();
249 pair<double, double> meanAndSigma = theFitter->fitTimeBox((*slHisto).second);
250 tTrig->
set((*slHisto).first,
257 cout <<
" SL: " << (*slHisto).first
258 <<
" mean = " << meanAndSigma.first
259 <<
" sigma = " << meanAndSigma.second << endl;
270 cout <<
"[DTTTrigCalibration]Writing ttrig object to DB!" << endl;
274 string tTrigRecord =
"DTTtrigRcd";
287 stringstream theStream;
290 theStream >> histoName;
296 stringstream theStream;
299 theStream >> histoName;
305 static const double convToNs = 25./32.;
307 ttrig != tTrig->
end(); ttrig++) {
308 cout <<
"Wh: " << (*ttrig).first.wheelId
309 <<
" St: " << (*ttrig).first.stationId
310 <<
" Sc: " << (*ttrig).first.sectorId
311 <<
" Sl: " << (*ttrig).first.slId
312 <<
" TTrig mean (ns): " << (*ttrig).second.tTrig * convToNs
313 <<
" TTrig sigma (ns): " << (*ttrig).second.tTrms * convToNs<< endl;
320 TH1F* tTrig_YB1_Se10 =
new TH1F(
"tTrig_YB1_Se10",
"tTrig YB1_Se10",15,1,16);
321 TH1F* tTrig_YB2_Se10 =
new TH1F(
"tTrig_YB2_Se10",
"tTrig YB2_Se10",15,1,16);
322 TH1F* tTrig_YB2_Se11 =
new TH1F(
"tTrig_YB2_Se11",
"tTrig YB2_Se11",12,1,13);
324 static const double convToNs = 25./32.;
326 ttrig != tTrig->
end(); ttrig++) {
331 if ((*ttrig).second.tTrig * convToNs > 0 &&
332 (*ttrig).second.tTrig * convToNs < 32000 ) {
333 tTrigValue = (*ttrig).second.tTrig * convToNs;
334 tTrmsValue = (*ttrig).second.tTrms * convToNs;
339 stringstream binLabelStream;
340 if ((*ttrig).first.sectorId != 14) {
341 binx = ((*ttrig).first.stationId-1)*3 + (*ttrig).first.slId;
342 binLabelStream <<
"MB"<<(*ttrig).first.stationId<<
"_SL"<<(*ttrig).first.slId;
345 binx = 12 + (*ttrig).first.slId;
346 binLabelStream <<
"MB14_SL"<<(*ttrig).first.slId;
348 binLabelStream >> binLabel;
350 if ((*ttrig).first.wheelId == 2) {
351 if ((*ttrig).first.sectorId == 10 || (*ttrig).first.sectorId == 14) {
352 tTrig_YB2_Se10->Fill( binx,tTrigValue);
353 tTrig_YB2_Se10->SetBinError( binx, tTrmsValue);
354 tTrig_YB2_Se10->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
355 tTrig_YB2_Se10->GetYaxis()->SetTitle(
"ns");
358 tTrig_YB2_Se11->Fill( binx,tTrigValue);
359 tTrig_YB2_Se11->SetBinError( binx,tTrmsValue);
360 tTrig_YB2_Se11->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
361 tTrig_YB2_Se11->GetYaxis()->SetTitle(
"ns");
365 tTrig_YB1_Se10->Fill( binx,tTrigValue);
366 tTrig_YB1_Se10->SetBinError( binx,tTrmsValue);
367 tTrig_YB1_Se10->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
368 tTrig_YB1_Se10->GetYaxis()->SetTitle(
"ns");
372 tTrig_YB1_Se10->Write();
373 tTrig_YB2_Se10->Write();
374 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.
unsigned int offset(bool)
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< DigiType >::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)