CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTSegmentsTask.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * $Date: 2011/06/27 09:43:36 $
6  * $Revision: 1.5 $
7  * \author G. Mila - INFN Torino
8  */
9 
11 
12 // Framework
18 
21 
22 //Geometry
25 
26 //RecHit
30 
31 #include <iterator>
32 
33 using namespace edm;
34 using namespace std;
35 
37 
38  debug = pset.getUntrackedParameter<bool>("debug",false);
39 
40  // Get the DQM needed services
41  theDbe = edm::Service<DQMStore>().operator->();
42  theDbe->setVerbose(1);
43 
44  parameters = pset;
45 
46 }
47 
48 
50 }
51 
52 
54 
55  // the name of the 4D rec hits collection
56  theRecHits4DLabel = parameters.getParameter<string>("recHits4DLabel");
57 
58  theDbe->setCurrentFolder("Muons/DTSegmentsMonitor");
59 
60  // histos for phi segments
61  phiHistos.push_back(theDbe->book2D("phiSegments_numHitsVsWheel", "phiSegments_numHitsVsWheel", 5, -2.5, 2.5, 20, 0, 20));
62  phiHistos[0]->setBinLabel(1,"W-2",1);
63  phiHistos[0]->setBinLabel(2,"W-1",1);
64  phiHistos[0]->setBinLabel(3,"W0",1);
65  phiHistos[0]->setBinLabel(4,"W1",1);
66  phiHistos[0]->setBinLabel(5,"W2",1);
67  phiHistos.push_back(theDbe->book2D("phiSegments_numHitsVsSector", "phiSegments_numHitsVsSector", 14, 0.5, 14.5, 20, 0, 20));
68  phiHistos[1]->setBinLabel(1,"Sec1",1);
69  phiHistos[1]->setBinLabel(2,"Sec2",1);
70  phiHistos[1]->setBinLabel(3,"Sec3",1);
71  phiHistos[1]->setBinLabel(4,"Sec4",1);
72  phiHistos[1]->setBinLabel(5,"Sec5",1);
73  phiHistos[1]->setBinLabel(6,"Sec6",1);
74  phiHistos[1]->setBinLabel(7,"Sec7",1);
75  phiHistos[1]->setBinLabel(8,"Sec8",1);
76  phiHistos[1]->setBinLabel(9,"Sec9",1);
77  phiHistos[1]->setBinLabel(10,"Sec10",1);
78  phiHistos[1]->setBinLabel(11,"Sec11",1);
79  phiHistos[1]->setBinLabel(12,"Sec12",1);
80  phiHistos[1]->setBinLabel(13,"Sec13",1);
81  phiHistos[1]->setBinLabel(14,"Sec14",1);
82  phiHistos.push_back(theDbe->book2D("phiSegments_numHitsVsStation", "phiSegments_numHitsVsStation", 4, 0.5, 4.5, 20, 0, 20));
83  phiHistos[2]->setBinLabel(1,"St1",1);
84  phiHistos[2]->setBinLabel(2,"St2",1);
85  phiHistos[2]->setBinLabel(3,"St3",1);
86  phiHistos[2]->setBinLabel(4,"St4",1);
87 
88  // histos for theta segments
89  thetaHistos.push_back(theDbe->book2D("thetaSegments_numHitsVsWheel", "thetaSegments_numHitsVsWheel", 5, -2.5, 2.5, 20, 0, 20));
90  thetaHistos[0]->setBinLabel(1,"W-2",1);
91  thetaHistos[0]->setBinLabel(2,"W-1",1);
92  thetaHistos[0]->setBinLabel(3,"W0",1);
93  thetaHistos[0]->setBinLabel(4,"W1",1);
94  thetaHistos[0]->setBinLabel(5,"W2",1);
95  thetaHistos.push_back(theDbe->book2D("thetaSegments_numHitsVsSector", "thetaSegments_numHitsVsSector", 14, 0.5, 14.5, 20, 0, 20));
96  thetaHistos[1]->setBinLabel(1,"Sec1",1);
97  thetaHistos[1]->setBinLabel(2,"Sec2",1);
98  thetaHistos[1]->setBinLabel(3,"Sec3",1);
99  thetaHistos[1]->setBinLabel(4,"Sec4",1);
100  thetaHistos[1]->setBinLabel(5,"Sec5",1);
101  thetaHistos[1]->setBinLabel(6,"Sec6",1);
102  thetaHistos[1]->setBinLabel(7,"Sec7",1);
103  thetaHistos[1]->setBinLabel(8,"Sec8",1);
104  thetaHistos[1]->setBinLabel(9,"Sec9",1);
105  thetaHistos[1]->setBinLabel(10,"Sec10",1);
106  thetaHistos[1]->setBinLabel(11,"Sec11",1);
107  thetaHistos[1]->setBinLabel(12,"Sec12",1);
108  thetaHistos[1]->setBinLabel(13,"Sec13",1);
109  thetaHistos[1]->setBinLabel(14,"Sec14",1);
110  thetaHistos.push_back(theDbe->book2D("thetaSegments_numHitsVsStation", "thetaSegments_numHitsVsStation", 4, 0.5, 4.5, 20, 0, 20));
111  thetaHistos[2]->setBinLabel(1,"St1",1);
112  thetaHistos[2]->setBinLabel(2,"St2",1);
113  thetaHistos[2]->setBinLabel(3,"St3",1);
114  thetaHistos[2]->setBinLabel(4,"St4",1);
115 
116 }
117 
118 
120  bool outputMEsInRootFile = parameters.getParameter<bool>("OutputMEsInRootFile");
121  std::string outputFileName = parameters.getParameter<std::string>("OutputFileName");
122  if(outputMEsInRootFile){
123  theDbe->save(outputFileName);
124  }
125 
126  theDbe->rmdir("DT/DTSegmentsTask");
127 }
128 
130 
131 // if(!(event.id().event()%1000) && debug)
132 // {
133 // cout << "[DTSegmentsTask] Analyze #Run: " << event.id().run()
134 // << " #Event: " << event.id().event() << endl;
135 // }
136 
137 
138  // Get the map of noisy channels
139  bool checkNoisyChannels = parameters.getUntrackedParameter<bool>("checkNoisyChannels",false);
141  if(checkNoisyChannels) {
142  setup.get<DTStatusFlagRcd>().get(statusMap);
143  }
144 
145  // Get the 4D segment collection from the event
147  event.getByLabel(theRecHits4DLabel, all4DSegments);
148 
149  // Loop over all chambers containing a segment
151  for (chamberId = all4DSegments->id_begin();
152  chamberId != all4DSegments->id_end();
153  ++chamberId){
154  // Get the range for the corresponding ChamerId
155  DTRecSegment4DCollection::range range = all4DSegments->get(*chamberId);
156  int nsegm = distance(range.first, range.second);
157  if(debug)
158  cout << " Chamber: " << *chamberId << " has " << nsegm
159  << " 4D segments" << endl;
160 
161 
162  // Loop over the rechits of this ChamerId
163  for (DTRecSegment4DCollection::const_iterator segment4D = range.first;
164  segment4D!=range.second;
165  ++segment4D){
166 
167  //FOR NOISY CHANNELS////////////////////////////////
168  bool segmNoisy = false;
169  if((*segment4D).hasPhi()){
170  const DTChamberRecSegment2D* phiSeg = (*segment4D).phiSegment();
171  vector<DTRecHit1D> phiHits = phiSeg->specificRecHits();
172  map<DTSuperLayerId,vector<DTRecHit1D> > hitsBySLMap;
173  for(vector<DTRecHit1D>::const_iterator hit = phiHits.begin();
174  hit != phiHits.end(); ++hit) {
175  DTWireId wireId = (*hit).wireId();
176 
177  // Check for noisy channels to skip them
178  if(checkNoisyChannels) {
179  bool isNoisy = false;
180  bool isFEMasked = false;
181  bool isTDCMasked = false;
182  bool isTrigMask = false;
183  bool isDead = false;
184  bool isNohv = false;
185  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
186  if(isNoisy) {
187  if(debug)
188  cout << "Wire: " << wireId << " is noisy, skipping!" << endl;
189  segmNoisy = true;
190  }
191  }
192  }
193  }
194 
195  if((*segment4D).hasZed()) {
196  const DTSLRecSegment2D* zSeg = (*segment4D).zSegment(); // zSeg lives in the SL RF
197  // Check for noisy channels to skip them
198  vector<DTRecHit1D> zHits = zSeg->specificRecHits();
199  for(vector<DTRecHit1D>::const_iterator hit = zHits.begin();
200  hit != zHits.end(); ++hit) {
201  DTWireId wireId = (*hit).wireId();
202  if(checkNoisyChannels) {
203  bool isNoisy = false;
204  bool isFEMasked = false;
205  bool isTDCMasked = false;
206  bool isTrigMask = false;
207  bool isDead = false;
208  bool isNohv = false;
209  //cout<<"wire id "<<wireId<<endl;
210  statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
211  if(isNoisy) {
212  if(debug)
213  cout << "Wire: " << wireId << " is noisy, skipping!" << endl;
214  segmNoisy = true;
215  }
216  }
217  }
218  }
219 
220  if (segmNoisy) {
221  if(debug)
222  cout<<"skipping the segment: it contains noisy cells"<<endl;
223  continue;
224  }
225  //END FOR NOISY CHANNELS////////////////////////////////
226 
227  // Fill the histos
228  int nHits=0;
229  if((*segment4D).hasPhi()){
230  nHits = (((*segment4D).phiSegment())->specificRecHits()).size();
231  if(debug)
232  cout<<"Phi segment with number of hits: "<<nHits<<endl;
233  phiHistos[0]->Fill((*chamberId).wheel(), nHits);
234  phiHistos[1]->Fill((*chamberId).sector(), nHits);
235  phiHistos[2]->Fill((*chamberId).station(), nHits);
236  }
237  if((*segment4D).hasZed()) {
238  nHits = (((*segment4D).zSegment())->specificRecHits()).size();
239  if(debug)
240  cout<<"Zed segment with number of hits: "<<nHits<<endl;
241  thetaHistos[0]->Fill((*chamberId).wheel(), nHits);
242  thetaHistos[1]->Fill((*chamberId).sector(), nHits);
243  thetaHistos[2]->Fill((*chamberId).station(), nHits);
244  }
245 
246  } //loop over segments
247  } // loop over chambers
248 
249 }
250 
T getUntrackedParameter(std::string const &, T const &) const
dictionary parameters
Definition: Parameters.py:2
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:52
identifier iterator
Definition: RangeMap.h:138
virtual ~DTSegmentsTask()
Destructor.
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
void endJob()
Endjob.
void analyze(const edm::Event &event, const edm::EventSetup &setup)
DTSegmentsTask(const edm::ParameterSet &pset)
Constructor.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
const T & get() const
Definition: EventSetup.h:55
void beginJob(void)
book the histos
tuple cout
Definition: gather_cfg.py:121
#define debug
Definition: MEtoEDMFormat.h:34
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.