Go to the documentation of this file.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::beginRun(const edm::Run&, 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
00076
00077
00078
00079
00080
00081
00082 int channelId = tzero->channelId;
00083 if ( channelId == 0 ) continue;
00084 DTLayerId layerId = (DTWireId(channelId)).layerId();
00085
00086 if(analyzedLayers.find(layerId)==analyzedLayers.end()){
00087 analyzedLayers.insert(layerId);
00088
00089
00090 const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
00091 const int firstWire = dtTopo.firstChannel();
00092
00093 const int nWires = muonGeom->layer(layerId)->specificTopology().channels();
00094
00095
00096 for(int wire=firstWire; wire<=nWires; wire++){
00097 DTWireId wireId(layerId,wire);
00098 float t0 = 0;
00099 float t0rms = 0;
00100 tZeroMap->get(wireId,
00101 t0,
00102 t0rms,
00103 DTTimeUnits::ns);
00104
00105
00106 if(!t0){
00107 tpDeadList->setCellDead_TP(wireId, true);
00108 cout<<"Wire id "<<wireId<<" is TP dead"<<endl;
00109 }
00110 }
00111 }
00112 }
00113 }
00114
00115
00116 void DTTPDeadWriter::endJob() {
00117 if(debug)
00118 cout << "[DTTPDeadWriter]Writing ttrig object to DB!" << endl;
00119
00120
00121 string deadRecord = "DTDeadFlagRcd";
00122
00123
00124 DTCalibDBUtils::writeToDB(deadRecord, tpDeadList);
00125
00126 }
00127