00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h"
00010 #include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h"
00011
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00016 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00018
00019 #include "CondFormats/DTObjects/interface/DTT0.h"
00020 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
00021 #include "CondFormats/DataRecord/interface/DTDeadFlagRcd.h"
00022 #include "CondFormats/DTObjects/interface/DTDeadFlag.h"
00023
00024
00025 #include <vector>
00026 #include <set>
00027 #include <iostream>
00028 #include <fstream>
00029 #include <string>
00030 #include <sstream>
00031 #include "TFile.h"
00032 #include "TH1.h"
00033
00034 using namespace std;
00035 using namespace edm;
00036
00037
00038
00039 DTTPDeadWriter::DTTPDeadWriter(const ParameterSet& pset) {
00040
00041 debug = pset.getUntrackedParameter<bool>("debug", "false");
00042
00043
00044 tpDeadList = new DTDeadFlag();
00045
00046 if(debug)
00047 cout << "[DTTPDeadWriter]Constructor called!" << endl;
00048 }
00049
00050
00051 DTTPDeadWriter::~DTTPDeadWriter(){
00052 if(debug)
00053 cout << "[DTTPDeadWriter]Destructor called!" << endl;
00054 }
00055
00056 void DTTPDeadWriter::beginJob(const EventSetup& setup) {
00057
00058 ESHandle<DTT0> t0;
00059 setup.get<DTT0Rcd>().get(t0);
00060 tZeroMap = &*t0;
00061
00062
00063 setup.get<MuonGeometryRecord>().get(muonGeom);
00064 }
00065
00066
00067 void DTTPDeadWriter::analyze(const Event & event, const EventSetup& eventSetup) {
00068 set<DTLayerId> analyzedLayers;
00069
00070
00071 for(DTT0::const_iterator tzero = tZeroMap->begin();
00072 tzero != tZeroMap->end(); tzero++){
00073
00074
00075 DTLayerId layerId = (DTWireId((*tzero).first.wheelId,
00076 (*tzero).first.stationId,
00077 (*tzero).first.sectorId,
00078 (*tzero).first.slId,
00079 (*tzero).first.layerId,
00080 (*tzero).first.cellId)).layerId();
00081 if(analyzedLayers.find(layerId)==analyzedLayers.end()){
00082 analyzedLayers.insert(layerId);
00083
00084
00085 const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
00086 const int firstWire = dtTopo.firstChannel();
00087
00088 const int nWires = muonGeom->layer(layerId)->specificTopology().channels();
00089
00090
00091 for(int wire=firstWire; wire<=nWires; wire++){
00092 DTWireId wireId(layerId,wire);
00093 float t0 = 0;
00094 float t0rms = 0;
00095 tZeroMap->cellT0(wireId,
00096 t0,
00097 t0rms,
00098 DTTimeUnits::ns);
00099
00100
00101 if(!t0){
00102 tpDeadList->setCellDead_TP(wireId, true);
00103 cout<<"Wire id "<<wireId<<" is TP dead"<<endl;
00104 }
00105 }
00106 }
00107 }
00108 }
00109
00110
00111 void DTTPDeadWriter::endJob() {
00112 if(debug)
00113 cout << "[DTTPDeadWriter]Writing ttrig object to DB!" << endl;
00114
00115
00116 string deadRecord = "DTDeadFlagRcd";
00117
00118
00119 DTCalibDBUtils::writeToDB(deadRecord, tpDeadList);
00120
00121 }
00122