File indexing completed on 2024-09-07 04:34:31
0001 #include "Alignment/LaserAlignment/interface/LASGlobalData.h"
0002 #include "Alignment/LaserAlignment/interface/LASGlobalLoop.h"
0003 #include "DataFormats/Common/interface/DetSetVector.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008
0009 class TFile;
0010 class TTree;
0011
0012 class RawDataConverter : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0013 public:
0014 explicit RawDataConverter(const edm::ParameterSet&);
0015 ~RawDataConverter() override = default;
0016
0017 private:
0018 enum DigiType { ZeroSuppressed, VirginRaw, ProcessedRaw, Unknown };
0019 void beginJob() override;
0020 void beginRun(edm::Run const&, edm::EventSetup const&) override;
0021 void analyze(const edm::Event&, const edm::EventSetup&) override;
0022 void endRun(edm::Run const&, edm::EventSetup const&) override {}
0023 void endJob() override;
0024
0025 void fillDetectorId(void);
0026 void ClearData(void);
0027 DigiType GetValidLabels(
0028 const edm::Event&
0029 iEvent);
0030
0031 template <class T>
0032 void GetDigis(const edm::Event&);
0033
0034 std::vector<std::string> theDigiModuleLabels;
0035 std::vector<std::string> theProductInstanceLabels;
0036
0037 std::string CurrentModuleLabel;
0038 std::string CurrentInstanceLabel;
0039
0040 TFile* theOutputFile;
0041 TTree* theOutputTree;
0042 LASGlobalData<std::vector<float> > theData;
0043
0044 int latency;
0045 int eventnumber;
0046 int runnumber;
0047 int lumiBlock;
0048 LASGlobalData<int> detectorId;
0049 };
0050
0051
0052
0053
0054 template <class Digitype>
0055 void RawDataConverter::GetDigis(const edm::Event& iEvent) {
0056 LogDebug("RawDataConverter") << "Fill ZeroSuppressed Digis into the Tree";
0057
0058
0059
0060 edm::Handle<edm::DetSetVector<Digitype> > detSetVector;
0061 iEvent.getByLabel(CurrentModuleLabel, CurrentInstanceLabel, detSetVector);
0062 if (!detSetVector.isValid())
0063 throw std::runtime_error("Could not find the Digis");
0064
0065
0066 ClearData();
0067
0068
0069
0070 LASGlobalLoop loop;
0071 int det, ring, beam, disk, pos;
0072
0073
0074 det = 0;
0075 ring = 0;
0076 beam = 0;
0077 disk = 0;
0078 do {
0079
0080 typename edm::DetSetVector<Digitype>::const_iterator theModule =
0081 detSetVector->find(detectorId.GetTECEntry(det, ring, beam, disk));
0082
0083 if (theModule != detSetVector->end()) {
0084
0085 typename edm::DetSet<Digitype>::const_iterator theDigi;
0086 for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi) {
0087
0088 if (theDigi->channel() < 512)
0089 theData.GetTECEntry(det, ring, beam, disk).at(theDigi->channel()) = theDigi->adc();
0090 }
0091 }
0092 } while (loop.TECLoop(det, ring, beam, disk));
0093
0094
0095 det = 2;
0096 beam = 0;
0097 pos = 0;
0098 do {
0099
0100 typename edm::DetSetVector<Digitype>::const_iterator theModule =
0101 detSetVector->find(detectorId.GetTIBTOBEntry(det, beam, pos));
0102
0103 if (theModule != detSetVector->end()) {
0104
0105 typename edm::DetSet<Digitype>::const_iterator theDigi;
0106 for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi) {
0107
0108 if (theDigi->channel() < 512)
0109 theData.GetTIBTOBEntry(det, beam, pos).at(theDigi->channel()) = theDigi->adc();
0110 }
0111 }
0112 } while (loop.TIBTOBLoop(det, beam, pos));
0113
0114
0115 det = 0;
0116 beam = 0;
0117 disk = 0;
0118 do {
0119
0120 typename edm::DetSetVector<Digitype>::const_iterator theModule =
0121 detSetVector->find(detectorId.GetTEC2TECEntry(det, beam, disk));
0122
0123 if (theModule != detSetVector->end()) {
0124
0125 typename edm::DetSet<Digitype>::const_iterator theDigi;
0126 for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi) {
0127
0128 if (theDigi->channel() < 512)
0129 theData.GetTEC2TECEntry(det, beam, disk).at(theDigi->channel()) = theDigi->adc();
0130 }
0131 }
0132 } while (loop.TEC2TECLoop(det, beam, disk));
0133 }