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 
14  public:
15  explicit RawDataConverter(const edm::ParameterSet&);
16  ~RawDataConverter() override;
17 
18 
19  private:
21  void beginJob() override ;
22  void beginRun(edm::Run const &, edm::EventSetup const &) override ;
23  void analyze(const edm::Event&, const edm::EventSetup&) override;
24  void endJob() override ;
25 
26  void fillDetectorId( void );
27  void ClearData( void );
28  DigiType GetValidLabels( const edm::Event& 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 
51 
52 // Copy the Digis into the local container (theData)
53 // Currently this has only been implemented and tested for SiStripDigis
54 // SiStripRawDigis and SiStripProcessedRawDigis will need some changes to work (this is the final goal)
55 template <class Digitype>
57 {
58  LogDebug("RawDataConverter") << "Fill ZeroSuppressed Digis into the Tree";
59 
60  // Get the DetSetVector for the SiStripDigis
61  // This is a vector with all the modules, each module containing zero or more strips with signal (Digis)
62  edm::Handle< edm::DetSetVector< Digitype > > detSetVector; // Handle for holding the DetSetVector
63  iEvent.getByLabel( CurrentModuleLabel , CurrentInstanceLabel , detSetVector );
64  if( ! detSetVector.isValid() ) throw std::runtime_error("Could not find the Digis");
65 
66  // set everything in the local container to zero
67  ClearData();
68 
69  // Fill the Digis into the Raw Data Container
70 
71  LASGlobalLoop loop; // loop helper
72  int det, ring, beam, disk, pos; // and its variables
73 
74  // loop over TEC+- (internal) modules
75  det = 0; ring = 0; beam = 0; disk = 0;
76  do {
77  // Find the module in the DetSetVector and get a pointer (iterator) to it
78  typename edm::DetSetVector< Digitype >::const_iterator theModule = detSetVector->find( detectorId.GetTECEntry( det, ring, beam, disk ) );
79 
80  if ( theModule != detSetVector->end() ) {
81  // loop over all the Digis in this Module
83  for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi ) {
84  // fill the number of adc counts into the local container
85  if ( theDigi->channel() < 512 ) theData.GetTECEntry( det, ring, beam, disk ).at( theDigi->channel() ) = theDigi->adc();
86  }
87  }
88  } while( loop.TECLoop( det, ring, beam, disk ) );
89 
90  // loop TIB/TOB
91  det = 2; beam = 0; pos = 0; // <- set det = 2 (TIB)
92  do {
93  // Find the module in the DetSetVector and get a pointer (iterator) to it
94  typename edm::DetSetVector< Digitype >::const_iterator theModule = detSetVector->find( detectorId.GetTIBTOBEntry( det, beam, pos ) );
95 
96  if ( theModule != detSetVector->end() ) {
97  // loop over all the Digis in this Module
99  for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi ) {
100  // fill the number of adc counts into the local container
101  if ( theDigi->channel() < 512 ) theData.GetTIBTOBEntry( det, beam, pos ).at( theDigi->channel() ) = theDigi->adc();
102  }
103  }
104  } while( loop.TIBTOBLoop( det, beam, pos ) );
105 
106 
107  // loop TEC (AT)
108  det = 0; beam = 0; disk = 0;
109  do {
110  // Find the module in the DetSetVector and get a pointer (iterator) to it
111  typename edm::DetSetVector< Digitype >::const_iterator theModule = detSetVector->find( detectorId.GetTEC2TECEntry( det, beam, disk ) );
112 
113  if ( theModule != detSetVector->end() ) {
114  // loop over all the Digis in this Module
116  for (theDigi = theModule->data.begin(); theDigi != theModule->data.end(); ++theDigi ) {
117  // fill the number of adc counts into the local container
118  if ( theDigi->channel() < 512 ) theData.GetTEC2TECEntry( det, beam, disk ).at( theDigi->channel() ) = theDigi->adc();
119  }
120  }
121  } while( loop.TEC2TECLoop( det, beam, disk ) );
122 }
123 
#define LogDebug(id)
void fillDetectorId(void)
DigiType GetValidLabels(const edm::Event &iEvent)
LASGlobalData< int > detectorId
void beginJob() override
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > theDigiModuleLabels
void beginRun(edm::Run const &, edm::EventSetup const &) override
bool TEC2TECLoop(int &, int &, int &) const
void GetDigis(const edm::Event &)
T & GetTIBTOBEntry(int subdetector, int beam, int tibTobPosition)
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
RawDataConverter(const edm::ParameterSet &)
~RawDataConverter() override
T & GetTEC2TECEntry(int subdetector, int beam, int tecDisk)
void endJob() override
T & GetTECEntry(int subdetector, int tecRing, int beam, int tecDisk)
Definition: LASGlobalData.h:91
std::string CurrentModuleLabel
LASGlobalData< std::vector< float > > theData
bool TECLoop(int &, int &, int &, int &) const
bool TIBTOBLoop(int &, int &, int &) const
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
std::string CurrentInstanceLabel
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
std::vector< std::string > theProductInstanceLabels
Definition: Run.h:45