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 }
23 
25 
26 void SiPixelDaqInfo::beginLuminosityBlock(const LuminosityBlock& lumiBlock, const EventSetup& iSetup){}
27 
28 
31  if(0 != iSetup.find( recordKey ) ) {
32  // cout<<"record key found"<<endl;
33  //get fed summary information
34  ESHandle<RunInfo> sumFED;
35  iSetup.get<RunInfoRcd>().get(sumFED);
36  vector<int> FedsInIds= sumFED->m_fed_in;
37 
38  int FedCount=0;
39  int FedCountBarrel=0;
40  int FedCountEndcap=0;
41 
42  //loop on all active feds
43  for(unsigned int fedItr=0;fedItr<FedsInIds.size(); ++fedItr) {
44  int fedID=FedsInIds[fedItr];
45  //make sure fed id is in allowed range
46  //cout<<fedID<<endl;
47  if(fedID>=FEDRange_.first && fedID<=FEDRange_.second){
48  ++FedCount;
49  if(fedID>=0 && fedID<=31) ++FedCountBarrel;
50  else if(fedID>=32 && fedID<=39) ++FedCountEndcap;
51  }
52  }
53 
54  //Fill active fed fraction ME
55  if(FedCountBarrel<=32){
56  FedCountBarrel = 0; FedCountEndcap = 0; FedCount = 0; NumberOfFeds_ = 40;
57  for(int i=0; i!=40; i++){
58  if(i<=31 && FEDs_[i]>0) FedCountBarrel++;
59  if(i>=32 && FEDs_[i]>0) FedCountEndcap++;
60  if(FEDs_[i]>0) FedCount++;
61  }
62  }
63  if(NumberOfFeds_>0){
64  //all Pixel:
65  Fraction_->Fill( FedCount/NumberOfFeds_);
66  //Barrel:
67  FractionBarrel_->Fill( FedCountBarrel/32.);
68  //Endcap:
69  FractionEndcap_->Fill( FedCountEndcap/8.);
70  }else{
71  Fraction_->Fill(-1);
72  FractionBarrel_->Fill(-1);
73  FractionEndcap_->Fill(-1);
74  }
75 
76  }else{
77  Fraction_->Fill(-1);
78  FractionBarrel_->Fill(-1);
79  FractionEndcap_->Fill(-1);
80  return;
81  }
82 }
83 
84 void SiPixelDaqInfo::endRun(const edm::Run& r, const edm::EventSetup& iSetup){
86  if(0 != iSetup.find( recordKey ) ) {
87  // cout<<"record key found"<<endl;
88  //get fed summary information
89  ESHandle<RunInfo> sumFED;
90  iSetup.get<RunInfoRcd>().get(sumFED);
91  vector<int> FedsInIds= sumFED->m_fed_in;
92 
93  int FedCount=0;
94  int FedCountBarrel=0;
95  int FedCountEndcap=0;
96 
97  //loop on all active feds
98  for(unsigned int fedItr=0;fedItr<FedsInIds.size(); ++fedItr) {
99  int fedID=FedsInIds[fedItr];
100  //make sure fed id is in allowed range
101  //cout<<fedID<<endl;
102  if(fedID>=FEDRange_.first && fedID<=FEDRange_.second){
103  ++FedCount;
104  if(fedID>=0 && fedID<=31) ++FedCountBarrel;
105  else if(fedID>=32 && fedID<=39) ++FedCountEndcap;
106  }
107  }
108 
109  if(FedCountBarrel>32){
110  FedCountBarrel = nFEDsBarrel_;
111  FedCountEndcap = nFEDsEndcap_;
112  FedCount = FedCountBarrel + FedCountEndcap;
113  NumberOfFeds_ = 40;
114  }
115 
116  //Fill active fed fraction ME
117  if(FedCountBarrel<=32){
118  FedCountBarrel = 0; FedCountEndcap = 0; FedCount = 0; NumberOfFeds_ = 40;
119  for(int i=0; i!=40; i++){
120  if(i<=31 && FEDs_[i]>0) FedCountBarrel++;
121  if(i>=32 && FEDs_[i]>0) FedCountEndcap++;
122  if(FEDs_[i]>0) FedCount++;
123  }
124  }
125  if(NumberOfFeds_>0){
126  //all Pixel:
127  Fraction_->Fill( FedCount/NumberOfFeds_);
128  //Barrel:
129  FractionBarrel_->Fill( FedCountBarrel/32.);
130  //Endcap:
131  FractionEndcap_->Fill( FedCountEndcap/8.);
132  }else{
133  Fraction_->Fill(-1);
134  FractionBarrel_->Fill(-1);
135  FractionEndcap_->Fill(-1);
136  }
137 
138  }else{
139  Fraction_->Fill(-1);
140  FractionBarrel_->Fill(-1);
141  FractionEndcap_->Fill(-1);
142  return;
143  }
144 }
145 
146 
148 
149  dbe_ = 0;
151 
152 
153  dbe_->setCurrentFolder("Pixel/EventInfo");
154  Fraction_= dbe_->bookFloat("DAQSummary");
155  dbe_->setCurrentFolder("Pixel/EventInfo/DAQContents");
156  FractionBarrel_= dbe_->bookFloat("PixelBarrelFraction");
157  FractionEndcap_= dbe_->bookFloat("PixelEndcapFraction");
158 }
159 
160 
162 
163 
164 
166  NEvents_++;
167  //cout<<"in SiPixelDaqInfo::analyze now!"<<endl;
168  if(NEvents_>=1 && NEvents_<=100){
169  // check if any Pixel FED is in readout:
170  edm::Handle<FEDRawDataCollection> rawDataHandle;
171  iEvent.getByLabel(daqSource_, rawDataHandle);
172  if(!rawDataHandle.isValid()){
173  edm::LogInfo("SiPixelDaqInfo") << daqSource_ << " is empty!";
174  return;
175  }
176  const FEDRawDataCollection& rawDataCollection = *rawDataHandle;
177  nFEDsBarrel_ = 0; nFEDsEndcap_ = 0;
178  for(int i = 0; i != 40; i++){
179  if(rawDataCollection.FEDData(i).size() > 208 ) FEDs_[i]++;
180  }
181  }
182 
183 }
184 
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()
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:49
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
int iEvent
Definition: GenABIO.cc:243
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
SiPixelDaqInfo(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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:429
Definition: Run.h:33
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:129