CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
Digi2Raw2Digi Class Reference

#include <Digi2Raw2Digi.h>

Inheritance diagram for Digi2Raw2Digi:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
template<class Digi >
void compare (const edm::Event &, const edm::EventSetup &)
 
 Digi2Raw2Digi (const edm::ParameterSet &)
 
virtual void endJob ()
 
 ~Digi2Raw2Digi ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

DQMStoredbe_
 
edm::InputTag inputTag1_
 
edm::InputTag inputTag2_
 
MonitorElementmeStatus
 
std::string outputFile_
 
int unsuppressed
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 14 of file Digi2Raw2Digi.h.

Constructor & Destructor Documentation

Digi2Raw2Digi::Digi2Raw2Digi ( const edm::ParameterSet iConfig)
explicit

Definition at line 220 of file Digi2Raw2Digi.cc.

References DQMStore::book1D(), dbe_, timingPdfMaker::histo, meStatus, cppFunctionSkipper::operator, outputFile_, and DQMStore::setCurrentFolder().

221  : inputTag1_(iConfig.getParameter<edm::InputTag>("digiLabel1")),
222  inputTag2_(iConfig.getParameter<edm::InputTag>("digiLabel2")),
223  outputFile_(iConfig.getUntrackedParameter<std::string>("outputFile")),
224  dbe_(0)
225 {
226 
227  // DQM ROOT output
228  if ( outputFile_.size() != 0 ) {
229  edm::LogInfo("OutputInfo")
230  << " Hcal RecHit Task histograms will be saved to '"
231  << outputFile_.c_str() << "'";
232  } else {
233  edm::LogInfo("OutputInfo")
234  << " Hcal RecHit Task histograms will NOT be saved";
235  }
236 
237  // DQM service initialization
239 
240  if ( dbe_ ) {
241  dbe_->setCurrentFolder("Digi2Raw2DigiV/Digi2Raw2DigiTask");
242  }
243 
244  // const char * sub = hcalselector_.c_str();
245  char histo[100];
246  sprintf (histo, "Digi2Raw2Digi_status") ;
247  // bins: 1)full match 2)ID match, not content 3) no match
248  // 4) number of events with diff number of Digis
249  meStatus = dbe_->book1D(histo, histo, 5, 0., 5.);
250 
251 }
std::string outputFile_
Definition: Digi2Raw2Digi.h:27
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
DQMStore * dbe_
Definition: Digi2Raw2Digi.h:28
edm::InputTag inputTag2_
Definition: Digi2Raw2Digi.h:25
edm::InputTag inputTag1_
Definition: Digi2Raw2Digi.h:24
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
MonitorElement * meStatus
Definition: Digi2Raw2Digi.h:30
Digi2Raw2Digi::~Digi2Raw2Digi ( )

Definition at line 258 of file Digi2Raw2Digi.cc.

258 {}

Member Function Documentation

void Digi2Raw2Digi::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 261 of file Digi2Raw2Digi.cc.

References iEvent, and unsuppressed.

262 {
263  unsuppressed = 0;
264 
265  // std::cout << "=== HBHE ==================" << std::endl;
266  compare<HBHEDataFrame>(iEvent,iSetup);
267 
268  // std::cout << "=== HO ====================" << std::endl;
269  compare<HODataFrame>(iEvent,iSetup);
270 
271  // std::cout << "=== HF ====================" << std::endl;
272  compare<HFDataFrame>(iEvent,iSetup);
273 
274 
275  // std::cout << "=== ZDC ===================" << std::endl;
276  unsuppressed = 1;
277  compare<ZDCDataFrame>(iEvent,iSetup);
278 
279 
280  // std::cout << "=== CASTOR ================" << std::endl;
281  // compare<CastorDataFrame>(iEvent,iSetup);
282 
283 }
int iEvent
Definition: GenABIO.cc:243
void Digi2Raw2Digi::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 253 of file Digi2Raw2Digi.cc.

253 {}
template<class Digi >
void Digi2Raw2Digi::compare ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 40 of file Digi2Raw2Digi.cc.

References ecalMGPA::adc(), gather_cfg::cout, HcalDetId::depth(), MonitorElement::Fill(), edm::Event::getByLabel(), i, inputTag1_, inputTag2_, fjr2json::lumi, match(), meStatus, unsuppressed, and HcalZDCDetId::zside().

40  {
41 
42  typename edm::Handle<edm::SortedCollection<Digi> > digiCollection1;
44  typename edm::Handle<edm::SortedCollection<Digi> > digiCollection2;
46 
47  if(unsuppressed) { // ZDC
48  iEvent.getByLabel ("simHcalUnsuppressedDigis", digiCollection1);
49  }
50  else iEvent.getByLabel (inputTag1_, digiCollection1);
51 
52  iEvent.getByLabel (inputTag2_, digiCollection2);
53 
54  int size1 = 0;
55  int size2 = 0;
56 
57  for (digiItr1=digiCollection1->begin();digiItr1!=digiCollection1->end();digiItr1++) {
58  size1++;
59  }
60 
61  for (digiItr2=digiCollection2->begin();digiItr2!=digiCollection2->end();digiItr2++) {
62  size2++;
63  }
64 
65  //std::cout << "Digi collections size1 = "<< size1
66  // << " size2 = " << size2 << std::endl;
67 
68 
69  // CYCLE over first DIGI collection ======================================
70 
71  for (digiItr1=digiCollection1->begin();digiItr1!=digiCollection1->end();digiItr1++) {
72  HcalGenericDetId HcalGenDetId(digiItr1->id());
73  int tsize = (*digiItr1).size();
74  int match = 0;
75 
76  if(HcalGenDetId.isHcalZDCDetId()){
77  //for zdc
78  HcalZDCDetId element(digiItr1->id());
79  int zside = element.zside();
80  int section = element.section();
81  int channel = element.channel();
82  int gsub = HcalGenDetId.genericSubdet();
83 
84  if(section==3){// lumi section not reconstructed
85  size2++;
86  match = 1;
87  goto lumi;
88  }
89 
90 
91  //std::cout<< " Zdc genSubdet="<< gsub << " zside=" <<zside
92  // << " section= "<< section << " channel " <<channel
93  // <<std::endl;
94 
95  for (digiItr2=digiCollection2->begin();digiItr2!=digiCollection2->end();digiItr2++) {
96  HcalZDCDetId element2(digiItr2->id());
97 
98  //int zside2 = element2.zside();
99  //int section2 = element2.section();
100  //int channel2 = element2.channel();
101  //int gsub2 = HcalGenDetId.genericSubdet();
102 
103  //std::cout<< " Zdc genSubdet="<<gsub2
104  // << " zside=" <<zside2
105  // << " section= "<<section2
106  // <<" channel "<<channel2
107  // <<std::endl;
108 
109  if(element == element2) {
110  match = 1;
111  int identical = 1;
112  for (int i=0; i<tsize; i++) {
113  double adc = (*digiItr1)[i].adc();
114  int capid = (*digiItr1)[i].capid();
115  // std::cout << std::endl << " capid1=" << capid
116  // << " adc1=" << adc
117  // << std::endl;
118  double adc2 = (*digiItr2)[i].adc();
119  int capid2 = (*digiItr2)[i].capid();
120  // std::cout << " capid2=" << capid2 << " adc2=" << adc2
121  // << std::endl;
122  if( capid != capid2 || adc != adc2) {
123  std::cout << "===> PROBLEM !!! gebsubdet=" << gsub
124  << " zside=" <<zside
125  << " section= "<< section << " channel " <<channel
126  << std::endl;
127  std::cout << " capid1["<< i << "]=" << capid
128  << " adc1["<< i << "]=" << adc
129  << " capid2["<< i << "]=" << capid2
130  << " adc2["<< i << "]=" << adc2
131  << std::endl;
132  identical = 0;
133  meStatus->Fill(1.);
134  break;
135  }
136  } // end of DataFrames array
137  if(identical) meStatus->Fill(0.);
138  break; // matched HcalZDCID is processed,
139  // go to next (primary collection) cell
140  }
141  } // end of cycle over 2d DIGI collection
142  lumi:
143  if (!match) {
144  meStatus->Fill(2.);
145  std::cout << "===> PROBLEM !!! gsubdet=" << gsub
146  << " zside=" <<zside
147  << " section= "<< section << " channel " <<channel
148  << " HcalZDCId match is not found !!!"
149  << std::endl;
150  }
151 
152  }
153  else{
154  //for Hcal subdetectors
155  HcalDetId cell(digiItr1->id());
156  int depth = cell.depth();
157  int iphi = cell.iphi()-1;
158  int ieta = cell.ieta();
159  int sub = cell.subdet();
160  // if(ieta > 0) ieta--;
161  // std::cout << " Cell subdet=" << sub << " ieta=" << ieta
162  // << " inphi=" << iphi << " depth=" << depth << std::endl;
163 
164  // CYCLE over second DIGI collection ======================================
165  for (digiItr2=digiCollection2->begin();digiItr2!=digiCollection2->end();digiItr2++) {
166 
167  HcalDetId cell2(digiItr2->id());
168 
169  if( cell == cell2) {
170  match = 1;
171  int identical = 1;
172  for (int i=0; i<tsize; i++) {
173  double adc = (*digiItr1)[i].adc();
174  int capid = (*digiItr1)[i].capid();
175  // std::cout << std::endl << " capid1=" << capid
176  // << " adc1=" << adc
177  // << std::endl;
178  double adc2 = (*digiItr2)[i].adc();
179  int capid2 = (*digiItr2)[i].capid();
180  // std::cout << " capid2=" << capid2 << " adc2=" << adc2
181  // << std::endl;
182  if( capid != capid2 || adc != adc2) {
183  std::cout << "===> PROBLEM !!! subdet=" << sub << " ieta="
184  << ieta << " inphi=" << iphi << " depth=" << depth
185  << std::endl;
186  std::cout << " capid1["<< i << "]=" << capid
187  << " adc1["<< i << "]=" << adc
188  << " capid2["<< i << "]=" << capid2
189  << " adc2["<< i << "]=" << adc2
190  << std::endl;
191  identical = 0;
192  meStatus->Fill(1.);
193  break;
194  }
195  } // end of DataFrames array
196  if(identical) meStatus->Fill(0.);
197  break; // matched HcalID is processed,
198  // go to next (primary collection) cell
199  }
200  } // end of cycle over 2d DIGI collection
201  if (!match) {
202  meStatus->Fill(2.);
203  std::cout << "===> PROBLEM !!! subdet=" << sub << " ieta="
204  << ieta << " inphi=" << iphi << " depth=" << depth
205  << " HcalID match is not found !!!"
206  << std::endl;
207  }
208  }
209  } // end of cycle over 1st DIGI collection
210 
211  if (size1 != size2) {
212  meStatus->Fill(3.);
213  std::cout << "===> PROBLEM !!! Different size of Digi collections : "
214  << size1 << " and " << size2
215  << std::endl;
216  }
217 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
tuple lumi
Definition: fjr2json.py:35
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:36
std::vector< T >::const_iterator const_iterator
void Fill(long long x)
int depth() const
get the tower depth
Definition: HcalDetId.h:42
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::InputTag inputTag2_
Definition: Digi2Raw2Digi.h:25
tuple cout
Definition: gather_cfg.py:121
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
edm::InputTag inputTag1_
Definition: Digi2Raw2Digi.h:24
MonitorElement * meStatus
Definition: Digi2Raw2Digi.h:30
void Digi2Raw2Digi::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 254 of file Digi2Raw2Digi.cc.

References dbe_, outputFile_, and DQMStore::save().

254  {
255  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
256 }
std::string outputFile_
Definition: Digi2Raw2Digi.h:27
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
DQMStore * dbe_
Definition: Digi2Raw2Digi.h:28

Member Data Documentation

DQMStore* Digi2Raw2Digi::dbe_
private

Definition at line 28 of file Digi2Raw2Digi.h.

Referenced by Digi2Raw2Digi(), and endJob().

edm::InputTag Digi2Raw2Digi::inputTag1_
private

Definition at line 24 of file Digi2Raw2Digi.h.

Referenced by compare().

edm::InputTag Digi2Raw2Digi::inputTag2_
private

Definition at line 25 of file Digi2Raw2Digi.h.

Referenced by compare().

MonitorElement* Digi2Raw2Digi::meStatus
private

Definition at line 30 of file Digi2Raw2Digi.h.

Referenced by compare(), and Digi2Raw2Digi().

std::string Digi2Raw2Digi::outputFile_
private

Definition at line 27 of file Digi2Raw2Digi.h.

Referenced by Digi2Raw2Digi(), and endJob().

int Digi2Raw2Digi::unsuppressed
private

Definition at line 32 of file Digi2Raw2Digi.h.

Referenced by analyze(), and compare().