test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZDCTask.cc
Go to the documentation of this file.
1 
3 #include <map>
4 
5 using namespace hcaldqm;
6 using namespace hcaldqm::constants;
8 {
9 
10  // tags
11  _tagQIE10 = ps.getUntrackedParameter<edm::InputTag>("tagQIE10",
12  edm::InputTag("hcalDigis"));
13  _tokQIE10 = consumes<ZDCDigiCollection>(_tagQIE10);
14 
15  // cuts
16  _cut = ps.getUntrackedParameter<double>("cut", 50.0);
17  _ped = ps.getUntrackedParameter<int>("ped", 4);
18 }
19 
21  edm::Run const& r, edm::EventSetup const& es)
22 {
23 
24  //############################## hardcode manually the zdc mapping #############################
25  //############################# this follows from https://github.com/cms-sw/cmssw/blob/CMSSW_8_0_X/EventFilter/CastorRawToDigi/src/ZdcUnpacker.cc#L118
26  //##############################################################################################
28  //PZDC
29  std::map<HcalElectronicsId,DetId> myEMap;
30  HcalElectronicsId eid = HcalElectronicsId(0, 1, 0, 3);
31  eid.setHTR(18, 8, 1);
32  myEMap[eid]=DetId(0x54000051);//PZDC EM1
33 
34  eid = HcalElectronicsId(1, 1, 0, 3);
35  eid.setHTR(18, 8, 1);
36  myEMap[eid]=DetId(0x54000052);//PZDC EM2
37 
38  eid = HcalElectronicsId(2, 1, 0, 3);
39  eid.setHTR(18, 8, 1);
40  myEMap[eid]=DetId(0x54000053);//PZDC EM3
41 
42  eid = HcalElectronicsId(0, 2, 0, 3);
43  eid.setHTR(18, 8, 1);
44  myEMap[eid]=DetId(0x54000061);//PZDC HAD1
45 
46  eid = HcalElectronicsId(1, 2, 0, 3);
47  eid.setHTR(18, 8, 1);
48  myEMap[eid]=DetId(0x54000054);//PZDC EM4
49 
50  eid = HcalElectronicsId(2, 2, 0, 3);
51  eid.setHTR(18, 8, 1);
52  myEMap[eid]=DetId(0x54000055);//PZDC EM5
53 
54  eid = HcalElectronicsId(0, 3, 0, 3);
55  eid.setHTR(18, 8, 1);
56  myEMap[eid]=DetId(0x54000062);//PZDC HAD2
57 
58  eid = HcalElectronicsId(1, 3, 0, 3);
59  eid.setHTR(18, 8, 1);
60  myEMap[eid]=DetId(0x54000063);//PZDC HAD3
61 
62  eid = HcalElectronicsId(2, 3, 0, 3);
63  eid.setHTR(18, 8, 1);
64  myEMap[eid]=DetId(0x54000064);//PZDC HAD4
65 
66  //NZDC
67  eid = HcalElectronicsId(0,1,1,3);
68  eid.setHTR(18, 8, 0);
69  myEMap[eid]=DetId(0x54000011);//NZDC EM1
70 
71  eid = HcalElectronicsId(1,1,1,3);
72  eid.setHTR(18, 8, 0);
73  myEMap[eid]=DetId(0x54000012);//NZDC EM2
74 
75  eid = HcalElectronicsId(2,1,1,3);
76  eid.setHTR(18, 8, 0);
77  myEMap[eid]=DetId(0x54000013);//NZDC EM3
78 
79  eid = HcalElectronicsId(0,2,1,3);
80  eid.setHTR(18, 8, 0);
81  myEMap[eid]=DetId(0x54000015);//NZDC EM5
82 
83  eid = HcalElectronicsId(1,2,1,3);
84  eid.setHTR(18, 8, 0);
85  myEMap[eid]=DetId(0x54000021);//NZDC HAD1
86 
87  eid = HcalElectronicsId(2,2,1,3);
88  eid.setHTR(18, 8, 0);
89  myEMap[eid]=DetId(0x54000014);//NZDC EM4
90 
91  eid = HcalElectronicsId(0,3,1,3);
92  eid.setHTR(18, 8, 0);
93  myEMap[eid]=DetId(0x54000022);//NZDC HAD2
94 
95  eid = HcalElectronicsId(1,3,1,3);
96  eid.setHTR(18, 8, 0);
97  myEMap[eid]=DetId(0x54000023);//NZDC HAD3
98 
99  eid = HcalElectronicsId(2,3,1,3);
100  eid.setHTR(18, 8, 0);
101  myEMap[eid]=DetId(0x54000024);//NZDC HAD4
102  //##################################### end hardcoding ###################################
103 
104  ib.cd();
105 
106  //quantities for axis
109 
111 
112  //book histos per channel
113  for (std::map<HcalElectronicsId,DetId>::const_iterator itr=myEMap.begin(); itr!=myEMap.end(); ++itr)
114  {
115  char histoname[300];
116 
117  sprintf(histoname,"%d_%d_%d_%d",itr->first.fiberChanId(),itr->first.fiberIndex(),itr->first.spigot(),itr->first.dccid());
118 
119  ib.setCurrentFolder("Hcal/ZDCTask/Shape_perChannel");
120  _cShape_EChannel[histoname] = ib.bookProfile(histoname,histoname,xAxisShape.nbins(),xAxisShape.min(),xAxisShape.max(),yAxisShape.nbins(),yAxisShape.min(),yAxisShape.max());
121  _cShape_EChannel[histoname]->setAxisTitle("Timing",1);
122  _cShape_EChannel[histoname]->setAxisTitle("fC QIE8",2);
123 
124  ib.setCurrentFolder("Hcal/ZDCTask/ADC_perChannel");
125  _cADC_EChannel[histoname] = ib.book1D(histoname,histoname,xAxisADC.nbins(),xAxisADC.min(),xAxisADC.max());
126  _cADC_EChannel[histoname]->getRootObject()->SetBit(BIT(hcaldqm::constants::BIT_OFFSET+hcaldqm::quantity::AxisType::fYAxis));
127  _cADC_EChannel[histoname]->setAxisTitle("ADC QIE8",1);
128 
129  ib.setCurrentFolder("Hcal/ZDCTask/ADC_vs_TS_perChannel");
130  _cADC_vs_TS_EChannel[histoname] = ib.book2D(histoname,histoname,xAxisShape.nbins(),xAxisShape.min(),xAxisShape.max(),xAxisADC.nbins(),xAxisADC.min(),xAxisADC.max());
131  _cADC_vs_TS_EChannel[histoname]->getRootObject()->SetBit(BIT(hcaldqm::constants::BIT_OFFSET+hcaldqm::quantity::AxisType::fYAxis));
132  _cADC_vs_TS_EChannel[histoname]->setAxisTitle("Timing",1);
133  _cADC_vs_TS_EChannel[histoname]->setAxisTitle("ADC QIE8",2);
134 
135 
136  }
137 
138  //book global histos
139  ib.setCurrentFolder("Hcal/ZDCTask");
140 
141  _cShape = ib.bookProfile("Shape","Shape",xAxisShape.nbins(),xAxisShape.min(),xAxisShape.max(),yAxisShape.nbins(),yAxisShape.min(),yAxisShape.max());
142  _cShape->setAxisTitle("Timing",1);
143  _cShape->setAxisTitle("fC QIE8",2);
144 
145  _cADC = ib.book1D("ADC","ADC",xAxisADC.nbins(),xAxisADC.min(),xAxisADC.max());
147  _cADC->setAxisTitle("ADC QIE8",1);
148 
149  _cADC_vs_TS = ib.book2D("ADC_vs_TS","ADC_vs_TS",xAxisShape.nbins(),xAxisShape.min(),xAxisShape.max(),xAxisADC.nbins(),xAxisADC.min(),xAxisADC.max());
151  _cADC_vs_TS->setAxisTitle("Timing",1);
152  _cADC_vs_TS->setAxisTitle("ADC QIE8",2);
153 
154 }
155 
156 
157 /* virtual */ void ZDCTask::analyze(edm::Event const& e, edm::EventSetup const&)
158 {
160  if (!e.getByToken(_tokQIE10, cqie10))
161  edm::LogError("Collection ZDCDigiCollection isn't available"
162  + _tagQIE10.label() + " " + _tagQIE10.instance());
163 
164 
165  for (uint32_t i=0; i<cqie10->size(); i++)
166  {
167  ZDCDataFrame frame = static_cast<ZDCDataFrame>((*cqie10)[i]);
168  HcalElectronicsId eid = frame.elecId();
169 
170  char histoname[300];
171  sprintf(histoname,"%d_%d_%d_%d",eid.fiberChanId(),eid.fiberIndex(),eid.spigot(),eid.dccid());
172 
173  // compute the signal, ped subracted
174  //double q = hcaldqm::utilities::sumQ_v10<ZDCDataFrame>(frame, constants::adc2fC[_ped], 0, frame.size()-1);
175 
176  // iterate thru all TS and fill
177  for (int j=0; j<frame.size(); j++)
178  {
179  _cShape_EChannel[histoname]->Fill(j, frame[j].nominal_fC());
180  _cShape->Fill(j, frame[j].nominal_fC());
181 
182  _cADC_EChannel[histoname]->Fill(frame[j].adc());
183  _cADC->Fill(frame[j].adc());
184 
185  _cADC_vs_TS_EChannel[histoname]->Fill(j,frame[j].adc());
186  _cADC_vs_TS->Fill(j,frame[j].adc());
187 
188 
189  }
190  }
191 }
192 
193 
int adc(sample_type sample)
get the ADC sample (12 bits)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
int ib
Definition: cuy.py:660
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void cd(void)
Definition: DQMStore.cc:268
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(edm::Event const &, edm::EventSetup const &)
Definition: ZDCTask.cc:157
ZDCTask(edm::ParameterSet const &)
Definition: ZDCTask.cc:7
int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
Definition: DetId.h:18
void setHTR(int crate, int slot, int tb)
TObject * getRootObject(void) const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
int size() const
total number of samples in the digi
Definition: ZDCDataFrame.h:26
const HcalElectronicsId & elecId() const
Definition: ZDCDataFrame.h:23
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
Definition: ZDCTask.cc:20
int const BIT_OFFSET
Definition: Constants.h:263
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Readout chain identification for Hcal.
Definition: Run.h:43