CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelDaqInfo.cc
Go to the documentation of this file.
8 
9 using namespace std;
10 using namespace edm;
12 
13  FEDRange_.first = ps.getUntrackedParameter<unsigned int>("MinimumPixelFEDId", 0);
14  FEDRange_.second = ps.getUntrackedParameter<unsigned int>("MaximumPixelFEDId", 39);
15  daqSource_ = ps.getUntrackedParameter<string>("daqSource", "source");
16 
17  NumberOfFeds_ =FEDRange_.second - FEDRange_.first +1;
18 
19  NEvents_ = 0;
20  for(int i=0; i!=40; i++) FEDs_[i] = 0;
21 
22  //set Token(-s)
23  daqSourceToken_ = consumes<FEDRawDataCollection>(ps.getUntrackedParameter<string>("daqSource", "source"));
24 }
25 
27 
28 void SiPixelDaqInfo::beginLuminosityBlock(const LuminosityBlock& lumiBlock, const EventSetup& iSetup){}
29 
30 
33  if(0 != iSetup.find( recordKey ) ) {
34  // cout<<"record key found"<<endl;
35  //get fed summary information
36  ESHandle<RunInfo> sumFED;
37  iSetup.get<RunInfoRcd>().get(sumFED);
38  vector<int> FedsInIds= sumFED->m_fed_in;
39 
40  int FedCount=0;
41  int FedCountBarrel=0;
42  int FedCountEndcap=0;
43 
44  //loop on all active feds
45  for(unsigned int fedItr=0;fedItr<FedsInIds.size(); ++fedItr) {
46  int fedID=FedsInIds[fedItr];
47  //make sure fed id is in allowed range
48  //cout<<fedID<<endl;
49  if(fedID>=FEDRange_.first && fedID<=FEDRange_.second){
50  ++FedCount;
51  if(fedID>=0 && fedID<=31) ++FedCountBarrel;
52  else if(fedID>=32 && fedID<=39) ++FedCountEndcap;
53  }
54  }
55 
56  //Fill active fed fraction ME
57  if(FedCountBarrel<=32){
58  FedCountBarrel = 0; FedCountEndcap = 0; FedCount = 0; NumberOfFeds_ = 40;
59  for(int i=0; i!=40; i++){
60  if(i<=31 && FEDs_[i]>0) FedCountBarrel++;
61  if(i>=32 && FEDs_[i]>0) FedCountEndcap++;
62  if(FEDs_[i]>0) FedCount++;
63  }
64  }
65  if(NumberOfFeds_>0){
66  //all Pixel:
67  Fraction_->Fill( FedCount/NumberOfFeds_);
68  //Barrel:
69  FractionBarrel_->Fill( FedCountBarrel/32.);
70  //Endcap:
71  FractionEndcap_->Fill( FedCountEndcap/8.);
72  }else{
73  Fraction_->Fill(-1);
74  FractionBarrel_->Fill(-1);
75  FractionEndcap_->Fill(-1);
76  }
77 
78  }else{
79  Fraction_->Fill(-1);
80  FractionBarrel_->Fill(-1);
81  FractionEndcap_->Fill(-1);
82  return;
83  }
84 }
85 
86 void SiPixelDaqInfo::endRun(const edm::Run& r, const edm::EventSetup& iSetup){
88  if(0 != iSetup.find( recordKey ) ) {
89  // cout<<"record key found"<<endl;
90  //get fed summary information
91  ESHandle<RunInfo> sumFED;
92  iSetup.get<RunInfoRcd>().get(sumFED);
93  vector<int> FedsInIds= sumFED->m_fed_in;
94 
95  int FedCount=0;
96  int FedCountBarrel=0;
97  int FedCountEndcap=0;
98 
99  //loop on all active feds
100  for(unsigned int fedItr=0;fedItr<FedsInIds.size(); ++fedItr) {
101  int fedID=FedsInIds[fedItr];
102  //make sure fed id is in allowed range
103  //cout<<fedID<<endl;
104  if(fedID>=FEDRange_.first && fedID<=FEDRange_.second){
105  ++FedCount;
106  if(fedID>=0 && fedID<=31) ++FedCountBarrel;
107  else if(fedID>=32 && fedID<=39) ++FedCountEndcap;
108  }
109  }
110 
111  if(FedCountBarrel>32){
112  FedCountBarrel = nFEDsBarrel_;
113  FedCountEndcap = nFEDsEndcap_;
114  FedCount = FedCountBarrel + FedCountEndcap;
115  NumberOfFeds_ = 40;
116  }
117 
118  //Fill active fed fraction ME
119  if(FedCountBarrel<=32){
120  FedCountBarrel = 0; FedCountEndcap = 0; FedCount = 0; NumberOfFeds_ = 40;
121  for(int i=0; i!=40; i++){
122  if(i<=31 && FEDs_[i]>0) FedCountBarrel++;
123  if(i>=32 && FEDs_[i]>0) FedCountEndcap++;
124  if(FEDs_[i]>0) FedCount++;
125  }
126  }
127  if(NumberOfFeds_>0){
128  //all Pixel:
129  Fraction_->Fill( FedCount/NumberOfFeds_);
130  //Barrel:
131  FractionBarrel_->Fill( FedCountBarrel/32.);
132  //Endcap:
133  FractionEndcap_->Fill( FedCountEndcap/8.);
134  }else{
135  Fraction_->Fill(-1);
136  FractionBarrel_->Fill(-1);
137  FractionEndcap_->Fill(-1);
138  }
139 
140  }else{
141  Fraction_->Fill(-1);
142  FractionBarrel_->Fill(-1);
143  FractionEndcap_->Fill(-1);
144  return;
145  }
146 }
147 
148 
150 
151  dbe_ = 0;
153 
154 
155  dbe_->setCurrentFolder("Pixel/EventInfo");
156  Fraction_= dbe_->bookFloat("DAQSummary");
157  dbe_->setCurrentFolder("Pixel/EventInfo/DAQContents");
158  FractionBarrel_= dbe_->bookFloat("PixelBarrelFraction");
159  FractionEndcap_= dbe_->bookFloat("PixelEndcapFraction");
160 }
161 
162 
164 
165 
166 
168  NEvents_++;
169  //cout<<"in SiPixelDaqInfo::analyze now!"<<endl;
170  if(NEvents_>=1 && NEvents_<=100){
171  // check if any Pixel FED is in readout:
172  edm::Handle<FEDRawDataCollection> rawDataHandle;
173  iEvent.getByToken(daqSourceToken_, rawDataHandle);
174  if(!rawDataHandle.isValid()){
175  edm::LogInfo("SiPixelDaqInfo") << daqSource_ << " is empty!";
176  return;
177  }
178  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
179  nFEDsBarrel_ = 0; nFEDsEndcap_ = 0;
180  for(int i = 0; i != 40; i++){
181  if(rawDataCollection.FEDData(i).size() > 208 ) FEDs_[i]++;
182  }
183  }
184 
185 }
186 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
virtual void endJob()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:879
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
int iEvent
Definition: GenABIO.cc:230
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
SiPixelDaqInfo(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:76
DQMStore * dbe_
const T & get() const
Definition: EventSetup.h:55
virtual void endRun(const edm::Run &, const edm::EventSetup &)
virtual void beginJob()
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655
Definition: Run.h:41
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125