61 theFile =
new TFile(rootFileName.c_str(),
"RECREATE");
65 theFitter->setVerbosity(1);
68 theFitter->setFitSigma(sigmaFit);
85 cout <<
"[DTTTrigCalibration]Constructor called!" << endl;
93 cout <<
"[DTTTrigCalibration]Destructor called!" << endl;
112 cout <<
"[DTTTrigCalibration] #Event: " <<
event.id().event() << endl;
119 if(checkNoisyChannels) {
125 theSync->setES(eventSetup);
128 vector<DTChamberId> badChambers;
132 for (dtLayerIt = digis->begin();
133 dtLayerIt != digis->end();
138 const DTLayerId layerId = (*dtLayerIt).first;
141 bool badChamber=
false;
144 cout<<
"----------- Layer "<<layerId<<
" -------------"<<endl;
147 for(vector<DTChamberId>::const_iterator
chamber = badChambers.begin();
chamber != badChambers.end(); ++
chamber){
153 if(badChamber)
continue;
156 if((digiRange.second - digiRange.first) > maxDigiPerLayer){
158 cout<<
"Layer "<<layerId<<
"has too many digis ("<<(digiRange.second - digiRange.first)<<
")"<<endl;
159 badChambers.push_back(chId);
164 TH1F *hTBox = theHistoMap[slId];
165 if(hTBox ==
nullptr) {
168 hTBox =
new TH1F(getTBoxName(slId).c_str(),
"Time box (ns)",
int(0.25*32.0*maxTDCCounts/25.0), 0, maxTDCCounts);
170 cout <<
" New Time Box: " << hTBox->GetName() << endl;
171 theHistoMap[slId] = hTBox;
173 TH1F *hO = theOccupancyMap[layerId];
177 hO =
new TH1F(getOccupancyName(layerId).c_str(),
"Occupancy", 100, 0, 100);
179 cout <<
" New Time Box: " << hO->GetName() << endl;
180 theOccupancyMap[layerId] = hO;
185 digi != digiRange.second;
187 const DTWireId wireId(layerId, (*digi).wire());
190 if(checkNoisyChannels) {
191 bool isNoisy =
false;
192 bool isFEMasked =
false;
193 bool isTDCMasked =
false;
194 bool isTrigMask =
false;
197 statusMap->
cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
200 cout <<
"Wire: " << wireId <<
" is noisy, skipping!" << endl;
207 const DTLayer* layer =
nullptr;
209 offset = theSync->offset(layer, wireId, glPt);
211 hTBox->Fill((*digi).time()-
offset);
213 cout <<
" Filling Time Box: " << hTBox->GetName() << endl;
214 cout <<
" offset (ns): " << offset << endl;
215 cout <<
" time(ns): " << (*digi).time()-offset<< endl;
217 hO->Fill((*digi).wire());
225 cout <<
"[DTTTrigCalibration]Writing histos to file!" << endl;
229 for(map<DTSuperLayerId, TH1F*>::const_iterator slHisto = theHistoMap.begin();
230 slHisto != theHistoMap.end();
232 (*slHisto).second->Write();
234 for(map<DTLayerId, TH1F*>::const_iterator slHisto = theOccupancyMap.begin();
235 slHisto != theOccupancyMap.end();
237 (*slHisto).second->Write();
240 if(findTMeanAndSigma) {
245 for(map<DTSuperLayerId, TH1F*>::const_iterator slHisto = theHistoMap.begin();
246 slHisto != theHistoMap.end();
248 pair<double, double> meanAndSigma = theFitter->fitTimeBox((*slHisto).second);
249 tTrig->
set((*slHisto).first,
256 cout <<
" SL: " << (*slHisto).first
257 <<
" mean = " << meanAndSigma.first
258 <<
" sigma = " << meanAndSigma.second << endl;
269 cout <<
"[DTTTrigCalibration]Writing ttrig object to DB!" << endl;
273 string tTrigRecord =
"DTTtrigRcd";
286 stringstream theStream;
289 theStream >> histoName;
295 stringstream theStream;
298 theStream >> histoName;
304 static const double convToNs = 25./32.;
306 ttrig != tTrig->
end(); ++ttrig) {
307 cout <<
"Wh: " << (*ttrig).first.wheelId
308 <<
" St: " << (*ttrig).first.stationId
309 <<
" Sc: " << (*ttrig).first.sectorId
310 <<
" Sl: " << (*ttrig).first.slId
311 <<
" TTrig mean (ns): " << (*ttrig).second.tTrig * convToNs
312 <<
" TTrig sigma (ns): " << (*ttrig).second.tTrms * convToNs<< endl;
319 TH1F* tTrig_YB1_Se10 =
new TH1F(
"tTrig_YB1_Se10",
"tTrig YB1_Se10",15,1,16);
320 TH1F* tTrig_YB2_Se10 =
new TH1F(
"tTrig_YB2_Se10",
"tTrig YB2_Se10",15,1,16);
321 TH1F* tTrig_YB2_Se11 =
new TH1F(
"tTrig_YB2_Se11",
"tTrig YB2_Se11",12,1,13);
323 static const double convToNs = 25./32.;
325 ttrig != tTrig->
end(); ++ttrig) {
330 if ((*ttrig).second.tTrig * convToNs > 0 &&
331 (*ttrig).second.tTrig * convToNs < 32000 ) {
332 tTrigValue = (*ttrig).second.tTrig * convToNs;
333 tTrmsValue = (*ttrig).second.tTrms * convToNs;
338 stringstream binLabelStream;
339 if ((*ttrig).first.sectorId != 14) {
340 binx = ((*ttrig).first.stationId-1)*3 + (*ttrig).first.slId;
341 binLabelStream <<
"MB"<<(*ttrig).first.stationId<<
"_SL"<<(*ttrig).first.slId;
344 binx = 12 + (*ttrig).first.slId;
345 binLabelStream <<
"MB14_SL"<<(*ttrig).first.slId;
347 binLabelStream >> binLabel;
349 if ((*ttrig).first.wheelId == 2) {
350 if ((*ttrig).first.sectorId == 10 || (*ttrig).first.sectorId == 14) {
351 tTrig_YB2_Se10->Fill( binx,tTrigValue);
352 tTrig_YB2_Se10->SetBinError( binx, tTrmsValue);
353 tTrig_YB2_Se10->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
354 tTrig_YB2_Se10->GetYaxis()->SetTitle(
"ns");
357 tTrig_YB2_Se11->Fill( binx,tTrigValue);
358 tTrig_YB2_Se11->SetBinError( binx,tTrmsValue);
359 tTrig_YB2_Se11->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
360 tTrig_YB2_Se11->GetYaxis()->SetTitle(
"ns");
364 tTrig_YB1_Se10->Fill( binx,tTrigValue);
365 tTrig_YB1_Se10->SetBinError( binx,tTrmsValue);
366 tTrig_YB1_Se10->GetXaxis()->SetBinLabel(binx,binLabel.c_str());
367 tTrig_YB1_Se10->GetYaxis()->SetTitle(
"ns");
371 tTrig_YB1_Se10->Write();
372 tTrig_YB2_Se10->Write();
373 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.
int layer() const
Return the layer number.
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Fill the time boxes.
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.
~DTTTrigCalibration() override
Destructor.
void plotTTrig(const DTTtrig *tTrig) const
std::string getOccupancyName(const DTLayerId &slId) const
int superlayer() const
Return the superlayer number (deprecated method name)
std::vector< DTDigi >::const_iterator const_iterator
int cellStatus(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool &noiseFlag, bool &feMask, bool &tdcMask, bool &trigMask, bool &deadFlag, bool &nohvFlag) const
get content
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.
void endJob() override
Fit the time box rising edge and write the resulting ttrig to the DB.
static void writeToDB(std::string record, T *payload)
T get(const Candidate &c)