CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Digi2Raw2Digi.cc
Go to the documentation of this file.
5 
14 
17 
23 #include <vector>
24 #include <utility>
25 #include <ostream>
26 #include <string>
27 #include <algorithm>
28 #include <cmath>
29 
30 
31 // Qunatities of interest in :
32 // DataFormats/HcalDigi/test/HcalDigiDump.cc - example of Digi dumping...
33 // DataFormats/HcalDigi/interface/HcalQIESample.h - adc, capid etc.
34 // DataFormats/HcalDigi/interface/HBHEDataFrame.h -
35 // zsMarkAndPass, zsUnsuppressed etc.
36 
37 template<class Digi>
38 
39 
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 }
218 
219 
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 }
252 
255  if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
256 }
257 
259 
260 
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 }
284 
285 
int adc(sample_type sample)
get the ADC sample (12 bits)
Digi2Raw2Digi(const edm::ParameterSet &)
std::string outputFile_
Definition: Digi2Raw2Digi.h:27
int i
Definition: DBlmapReader.cc:9
virtual void beginJob()
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple lumi
Definition: fjr2json.py:41
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:1883
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:36
std::vector< T >::const_iterator const_iterator
void compare(const edm::Event &, const edm::EventSetup &)
tuple histo
Definition: trackerHits.py:12
void Fill(long long x)
int depth() const
get the tower depth
Definition: HcalDetId.h:42
int iEvent
Definition: GenABIO.cc:243
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
DQMStore * dbe_
Definition: Digi2Raw2Digi.h:28
DQMStore * dbe_
edm::InputTag inputTag2_
Definition: Digi2Raw2Digi.h:25
tuple cout
Definition: gather_cfg.py:41
virtual void endJob()
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
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
MonitorElement * meStatus
Definition: Digi2Raw2Digi.h:30