CMS 3D CMS Logo

RawDataConverter.h
Go to the documentation of this file.
7 
8 // Forward declarations
9 class TFile;
10 class TTree;
11 
13 public:
14  explicit RawDataConverter(const edm::ParameterSet&);
15  ~RawDataConverter() override;
16 
17 private:
19  void beginJob() override;
20  void beginRun(edm::Run const&, edm::EventSetup const&) override;
21  void analyze(const edm::Event&, const edm::EventSetup&) override;
22  void endJob() override;
23 
24  void fillDetectorId(void);
25  void ClearData(void);
27  const edm::Event&
28  iEvent); // Check what kind of file is being processed and get valid module and instance labels returns the type of Digis that was found
29 
30  template <class T>
31  void GetDigis(const edm::Event&); // Copy the Digis into the local container (theData)
32 
33  std::vector<std::string> theDigiModuleLabels;
34  std::vector<std::string> theProductInstanceLabels;
35 
38 
39  TFile* theOutputFile;
40  TTree* theOutputTree;
42 
43  int latency;
45  int runnumber;
46  int lumiBlock;
48 };
49 
50 // Copy the Digis into the local container (theData)
51 // Currently this has only been implemented and tested for SiStripDigis
52 // SiStripRawDigis and SiStripProcessedRawDigis will need some changes to work (this is the final goal)
53 template <class Digitype>
55  LogDebug("RawDataConverter") << "Fill ZeroSuppressed Digis into the Tree";
56 
57  // Get the DetSetVector for the SiStripDigis
58  // This is a vector with all the modules, each module containing zero or more strips with signal (Digis)
59  edm::Handle<edm::DetSetVector<Digitype> > detSetVector; // Handle for holding the DetSetVector
60  iEvent.getByLabel(CurrentModuleLabel, CurrentInstanceLabel, detSetVector);
61  if (!detSetVector.isValid())
62  throw std::runtime_error("Could not find the Digis");
63 
64  // set everything in the local container to zero
65  ClearData();
66 
67  // Fill the Digis into the Raw Data Container
68 
69  LASGlobalLoop loop; // loop helper
70  int det, ring, beam, disk, pos; // and its variables
71 
72  // loop over TEC+- (internal) modules
73  det = 0;
74  ring = 0;
75  beam = 0;
76  disk = 0;
77  do {
78  // Find the module in the DetSetVector and get a pointer (iterator) to it
80  detSetVector->find(detectorId.GetTECEntry(det, ring, beam, disk));
81 
82  if (theModule != detSetVector->end()) {
83  // loop over all the Digis in this Module
85  for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi) {
86  // fill the number of adc counts into the local container
87  if (theDigi->channel() < 512)
88  theData.GetTECEntry(det, ring, beam, disk).at(theDigi->channel()) = theDigi->adc();
89  }
90  }
91  } while (loop.TECLoop(det, ring, beam, disk));
92 
93  // loop TIB/TOB
94  det = 2;
95  beam = 0;
96  pos = 0; // <- set det = 2 (TIB)
97  do {
98  // Find the module in the DetSetVector and get a pointer (iterator) to it
100  detSetVector->find(detectorId.GetTIBTOBEntry(det, beam, pos));
101 
102  if (theModule != detSetVector->end()) {
103  // loop over all the Digis in this Module
104  typename edm::DetSet<Digitype>::const_iterator theDigi;
105  for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi) {
106  // fill the number of adc counts into the local container
107  if (theDigi->channel() < 512)
108  theData.GetTIBTOBEntry(det, beam, pos).at(theDigi->channel()) = theDigi->adc();
109  }
110  }
111  } while (loop.TIBTOBLoop(det, beam, pos));
112 
113  // loop TEC (AT)
114  det = 0;
115  beam = 0;
116  disk = 0;
117  do {
118  // Find the module in the DetSetVector and get a pointer (iterator) to it
120  detSetVector->find(detectorId.GetTEC2TECEntry(det, beam, disk));
121 
122  if (theModule != detSetVector->end()) {
123  // loop over all the Digis in this Module
124  typename edm::DetSet<Digitype>::const_iterator theDigi;
125  for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi) {
126  // fill the number of adc counts into the local container
127  if (theDigi->channel() < 512)
128  theData.GetTEC2TECEntry(det, beam, disk).at(theDigi->channel()) = theDigi->adc();
129  }
130  }
131  } while (loop.TEC2TECLoop(det, beam, disk));
132 }
RawDataConverter::runnumber
int runnumber
Definition: RawDataConverter.h:45
RawDataConverter::GetDigis
void GetDigis(const edm::Event &)
Definition: RawDataConverter.h:54
MessageLogger.h
RawDataConverter::ProcessedRaw
Definition: RawDataConverter.h:18
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
edm::Run
Definition: Run.h:45
RawDataConverter::CurrentModuleLabel
std::string CurrentModuleLabel
Definition: RawDataConverter.h:36
RawDataConverter::RawDataConverter
RawDataConverter(const edm::ParameterSet &)
Definition: RawDataConverter.cc:22
pos
Definition: PixelAliasList.h:18
LASGlobalData
Definition: LASGlobalData.h:31
edm::DetSetVector::begin
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
LASGlobalLoop
Definition: LASGlobalLoop.h:24
EDAnalyzer.h
RawDataConverter::latency
int latency
Definition: RawDataConverter.h:43
RawDataConverter::~RawDataConverter
~RawDataConverter() override
Definition: RawDataConverter.cc:47
edm::Handle
Definition: AssociativeIterator.h:50
RawDataConverter::theData
LASGlobalData< std::vector< float > > theData
Definition: RawDataConverter.h:41
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
RawDataConverter::CurrentInstanceLabel
std::string CurrentInstanceLabel
Definition: RawDataConverter.h:37
RawDataConverter::endJob
void endJob() override
Definition: RawDataConverter.cc:176
RawDataConverter::VirginRaw
Definition: RawDataConverter.h:18
LASGlobalData::GetTECEntry
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
Definition: LASGlobalData.h:84
EcalCondDBWriter_cfi.beam
beam
Definition: EcalCondDBWriter_cfi.py:45
RawDataConverter::fillDetectorId
void fillDetectorId(void)
Definition: RawDataConverter.cc:225
LASGlobalLoop.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RawDataConverter
Definition: RawDataConverter.h:12
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
RawDataConverter::theProductInstanceLabels
std::vector< std::string > theProductInstanceLabels
Definition: RawDataConverter.h:34
heppy_loop.loop
loop
Definition: heppy_loop.py:28
iEvent
int iEvent
Definition: GenABIO.cc:224
RawDataConverter::GetValidLabels
DigiType GetValidLabels(const edm::Event &iEvent)
Definition: RawDataConverter.cc:67
LASGlobalData::GetTIBTOBEntry
T & GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition)
Definition: LASGlobalData.h:107
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
RawDataConverter::theOutputTree
TTree * theOutputTree
Definition: RawDataConverter.h:40
RawDataConverter::ZeroSuppressed
Definition: RawDataConverter.h:18
RawDataConverter::theOutputFile
TFile * theOutputFile
Definition: RawDataConverter.h:39
RawDataConverter::lumiBlock
int lumiBlock
Definition: RawDataConverter.h:46
LASGlobalData::GetTEC2TECEntry
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
Definition: LASGlobalData.h:129
RawDataConverter::ClearData
void ClearData(void)
Definition: RawDataConverter.cc:184
LASGlobalData.h
RawDataConverter::Unknown
Definition: RawDataConverter.h:18
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
RawDataConverter::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: RawDataConverter.cc:128
RawDataConverter::detectorId
LASGlobalData< int > detectorId
Definition: RawDataConverter.h:47
RawDataConverter::theDigiModuleLabels
std::vector< std::string > theDigiModuleLabels
Definition: RawDataConverter.h:33
RawDataConverter::DigiType
DigiType
Definition: RawDataConverter.h:18
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
RawDataConverter::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: RawDataConverter.cc:57
RawDataConverter::beginJob
void beginJob() override
Definition: RawDataConverter.cc:52
RawDataConverter::eventnumber
int eventnumber
Definition: RawDataConverter.h:44
edm::Event
Definition: Event.h:73
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31