40 #include "TPostScript.h"
51 cout<<
"[DTAlbertoBenvenutiTask]: Constructor"<<endl;
57 tMax =
parameters.getParameter<
int>(
"defaultTmax");
62 DTUnpackerToken_ = consumes<DTDigiCollection>(
std::string(
"dtunpacker"));
69 cout <<
"DTAlbertoBenvenutiTask: analyzed " <<
nevents <<
" events" << endl;
77 cout<<
"[DTAlbertoBenvenutiTask] endjob called!"<<endl;
79 map< DTChamberId, vector<TH1F*> > TBMap_perChamber;
81 for(map<DTWireId, TH1F* >::const_iterator wHisto = TBMap.begin();
82 wHisto != TBMap.end();
84 DTChamberId chId = (*wHisto).first.layerId().superlayerId().chamberId();
85 TBMap_perChamber[chId].push_back((*wHisto).second);
89 for(
map<
DTChamberId, vector<TH1F*> >::const_iterator Histo = TBMap_perChamber.begin();
90 Histo != TBMap_perChamber.end();
92 stringstream
station; station << (*Histo).first.station();
93 stringstream sector; sector << (*Histo).first.sector();
94 stringstream wheel; wheel << (*Histo).first.wheel();
96 string fileTag =
"TimeBoxes";
99 +
"_Sec" + sector.str()
100 +
"_St" + station.str()
103 TPostScript psFile(fileName.c_str(),111);
106 TCanvas
c1(
"c1",
"",600,780);
110 cout<<
"[DTAlbertoBenvenutiTask] filling the file: "<<fileName<<endl;
111 for(vector<TH1F*>::const_iterator tbHisto = (*Histo).second.begin();
112 tbHisto != (*Histo).second.end();
117 if(counter%16 == 0 && counter>=16){
134 cout<<
"[DTAlbertoBenvenutiTask]: BeginJob"<<endl;
148 if (
parameters.getUntrackedParameter<
bool>(
"readDB",
true))
152 if (
parameters.getParameter<
bool>(
"performPerWireT0Calibration"))
160 if (
debug)
cout<<
"[DTAlbertoBenvenutiTask]: booking"<<endl;
167 vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
168 vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
170 for (; ch_it != ch_end; ++ch_it) {
173 vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
174 vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
176 for(; sl_it != sl_end; ++sl_it) {
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();
182 for(; l_it != l_end; ++l_it) {
184 stringstream layer; layer << layerId.
layer();
185 const int firstWire = muonGeom->layer(layerId)->specificTopology().firstChannel();
186 const int lastWire = muonGeom->layer(layerId)->specificTopology().lastChannel();
188 for(
int wr=firstWire; wr -lastWire <= 0; wr++) {
190 stringstream wire; wire << wr;
193 string histoTag =
"TimeBox";
194 string histoName = histoTag
196 +
"_St" + station.str()
197 +
"_Sec" + sector.str()
198 +
"_SL" + superLayer.str()
200 +
"_wire" + wire.str();
202 if (
debug)
cout<<
"[DTAlbertoBenvenutiTask]: histoName "<<histoName<<endl;
204 if (
parameters.getUntrackedParameter<
bool>(
"readDB",
false) )
208 else tTrig =
parameters.getParameter<
int>(
"defaultTtrig");
210 string histoTitle = histoName +
" (TDC Counts)";
211 int timeBoxGranularity =
parameters.getUntrackedParameter<
int>(
"timeBoxGranularity",4);
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);
219 TH1F *TB =
new TH1F(histoName.c_str(),histoTitle.c_str(), 2*tMax/timeBoxGranularity, tTrig-tMax, tTrig+2*tMax);
239 bool checkNoisyChannels =
parameters.getUntrackedParameter<
bool>(
"checkNoisyChannels",
false);
241 if(checkNoisyChannels) {
248 for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
250 digiIt!=((*dtLayerId_It).second).
second; ++digiIt){
255 bool isSyncNoisy =
false;
256 if (tdcCount > maxTDCHits) isSyncNoisy =
true;
258 for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
260 digiIt!=((*dtLayerId_It).second).
second; ++digiIt){
262 bool isNoisy =
false;
263 bool isFEMasked =
false;
264 bool isTDCMasked =
false;
265 bool isTrigMask =
false;
268 const DTWireId wireId(((*dtLayerId_It).first), (*digiIt).wire());
269 if(checkNoisyChannels) {
270 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
283 float t0;
float t0RMS;
284 int tdcTime = (*digiIt).countsTDC();
286 if (
parameters.getParameter<
bool>(
"performPerWireT0Calibration")) {
287 const DTWireId dtWireId(((*dtLayerId_It).first), (*digiIt).wire());
289 tdcTime += int(round(t0));
293 if ((!isNoisy ) && (!isSyncNoisy)) {
295 if (TBMap.find(wireId) == TBMap.end()){
297 TBMap[wireId]->Fill(tdcTime);
300 TBMap[wireId]->Fill(tdcTime);
T getUntrackedParameter(std::string const &, T const &) const
virtual ~DTAlbertoBenvenutiTask()
Destructor.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
DTChamberId chamberId() const
Return the corresponding ChamberId.
void beginRun(const edm::Run &, const edm::EventSetup &)
int layer() const
Return the layer number.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
U second(std::pair< T, U > const &p)
int superlayer() const
Return the superlayer number (deprecated method name)
std::vector< DTDigi >::const_iterator const_iterator
DTLayerId layerId() const
Return the corresponding LayerId.
static std::atomic< unsigned int > counter
void bookHistos(const DTWireId dtWire)
Book the ME.
DTAlbertoBenvenutiTask(const edm::ParameterSet &ps)
Constructor.
int station() const
Return the station number.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
int wheel() const
Return the wheel number.