49 theDbe->setCurrentFolder(
"DT/DTEfficiencyTask");
61 theRecHits4DLabel =
parameters.getParameter<
string>(
"recHits4DLabel");
63 theRecHitLabel =
parameters.getParameter<
string>(
"recHitLabel");
71 for(
map<
DTLayerId, vector<MonitorElement*> > ::const_iterator
histo = histosPerL.begin();
72 histo != histosPerL.end();
74 int size = (*histo).second.size();
76 (*histo).second[
i]->Reset();
85 theDbe->rmdir(
"DT/DTEfficiencyTask");
93 cout <<
"[DTEfficiencyTask] Analyze #Run: " <<
event.id().run()
94 <<
" #Event: " <<
event.id().event() << endl;
99 event.getByLabel(theRecHits4DLabel, all4DSegments);
103 event.getByLabel(theRecHitLabel, dtRecHits);
111 for (chamberId = all4DSegments->id_begin();
112 chamberId != all4DSegments->id_end();
116 const DTChamber* chamber = dtGeom->chamber(*chamberId);
119 const vector<const DTSuperLayer*> SLayers = chamber->
superLayers();
120 map<DTWireId, int> wireAnd1DRecHits;
121 for(vector<const DTSuperLayer*>::const_iterator superlayer = SLayers.begin();
122 superlayer != SLayers.end();
127 rechit!=range.second;
129 wireAnd1DRecHits[(*rechit).wireId()] = (*rechit).wireId().wire();
136 int nsegm = distance(range.first, range.second);
138 cout <<
" Chamber: " << *chamberId <<
" has " << nsegm
139 <<
" 4D segments" << endl;
144 segment4D!=range.second;
147 cout <<
" == RecSegment dimension: " << (*segment4D).dimension() << endl;
151 if((*chamberId).station() != 4 && (*segment4D).dimension() != 4) {
153 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 4 but "
154 << (*segment4D).dimension() <<
", skipping!" << endl;
156 }
else if((*chamberId).station() == 4 && (*segment4D).dimension() != 2) {
158 cout <<
"[DTEfficiencyTask]***Warning: RecSegment dimension is not 2 but "
159 << (*segment4D).dimension() <<
", skipping!" << endl;
163 vector<DTRecHit1D> recHits1D;
171 if(phiRecHits.size() < 7 || phiRecHits.size() > 8 ) {
173 cout <<
"[DTEfficiencyTask] Phi segments has: " << phiRecHits.size()
174 <<
" hits, skipping" << endl;
177 copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D));
179 if((*segment4D).dimension() == 4) {
181 zSeg = (*segment4D).zSegment();
183 if(zRecHits.size() < 3 || zRecHits.size() > 4 ) {
185 cout <<
"[DTEfficiencyTask] Theta segments has: " << zRecHits.size()
186 <<
" hits, skipping" << endl;
189 copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D));
193 vector<DTWireId> wireMap;
194 for(vector<DTRecHit1D>::const_iterator recHit1D = recHits1D.begin();
195 recHit1D != recHits1D.end();
197 wireMap.push_back((*recHit1D).wireId());
200 bool hitsOnSameLayer =
false;
201 for(vector<DTWireId>::const_iterator channelId = wireMap.begin();
202 channelId != wireMap.end(); channelId++) {
203 vector<DTWireId>::const_iterator next = channelId;
205 for(vector<DTWireId>::const_iterator ite = next; ite != wireMap.end(); ite++) {
206 if((*channelId).layerId() == (*ite).layerId()) {
207 hitsOnSameLayer =
true;
211 if(hitsOnSameLayer) {
213 cout <<
"[DTEfficiencyTask] This RecHit has 2 hits on the same layer, skipping!" << endl;
219 LocalVector phiDirectionInChamber = (*phiSeg).localDirection();
220 if(rPhi && fabs(phiDirectionInChamber.
x()/phiDirectionInChamber.
z()) > 1) {
222 cout <<
" RPhi segment has angle > 45 deg, skipping! " << endl;
223 cout <<
" Theta = " << phiDirectionInChamber.
theta() << endl;
228 LocalVector zDirectionInChamber = (*zSeg).localDirection();
229 if(fabs(zDirectionInChamber.
y()/zDirectionInChamber.
z()) > 1) {
231 cout <<
" RZ segment has angle > 45 deg, skipping! " << endl;
232 cout <<
" Theta = " << zDirectionInChamber.
theta() << endl;
240 if(recHits1D.size() == 10) {
242 cout <<
"[DTEfficiencyTask] 4D Segment with only 10 hits, skipping!" << endl;
248 if((rPhi && recHits1D.size() == 7) || (rZ && recHits1D.size() == 11)) {
251 if(rPhi && recHits1D.size() == 7)
252 cout <<
"[DTEfficiencyTask] MB4 Segment with only 7 hits!" << endl;
253 if(rZ && recHits1D.size() == 11)
254 cout <<
"[DTEfficiencyTask] 4D Segment with only 11 hits!" << endl;
258 const vector<const DTSuperLayer*> SupLayers = chamber->
superLayers();
259 map<DTLayerId, bool> layerMap;
260 map<DTWireId, float> wireAndPosInChamberAtLayerZ;
262 for(vector<const DTSuperLayer*>::const_iterator superlayer = SupLayers.begin();
263 superlayer != SupLayers.end();
265 const vector<const DTLayer*> Layers = (*superlayer)->layers();
266 for(vector<const DTLayer*>::const_iterator layer = Layers.begin();
267 layer != Layers.end();
269 layerMap.insert(make_pair((*layer)->id(),
false));
270 const int firstWire = dtGeom->layer((*layer)->id())->specificTopology().firstChannel();
271 const int lastWire = dtGeom->layer((*layer)->id())->specificTopology().lastChannel();
272 for(
int i=firstWire;
i <= lastWire;
i++) {
274 float wireX = (*layer)->specificTopology().wirePosition(wireId.wire());
276 GlobalPoint wirePosGlob = (*layer)->toGlobal(wirePosInLay);
278 if((*superlayer)->id().superlayer() == 1 || (*superlayer)->id().superlayer() == 3) {
279 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
x()));
281 wireAndPosInChamberAtLayerZ.insert(make_pair(wireId, wirePosInChamber.
y()));
288 map<DTLayerId, int> NumWireMap;
289 for(vector<DTRecHit1D>::const_iterator recHit = recHits1D.begin();
290 recHit != recHits1D.end();
292 layerMap[(*recHit).wireId().layerId()]=
true;
293 NumWireMap[(*recHit).wireId().layerId()]= (*recHit).wireId().wire();
298 for(map<DTLayerId, bool>::const_iterator iter = layerMap.begin();
299 iter != layerMap.end(); iter++) {
300 if(!(*iter).second) missLayerId = (*iter).first;
303 cout <<
"[DTEfficiencyTask] Layer without recHits is: " << missLayerId << endl;
313 LocalPoint segPosAtZLayer = (*segment4D).localPosition()
314 + (*segment4D).localDirection()*missLayerPosInChamber.
z()/
cos((*segment4D).localDirection().theta());
319 for(map<DTWireId, float>::const_iterator wireAndPos = wireAndPosInChamberAtLayerZ.begin();
320 wireAndPos != wireAndPosInChamberAtLayerZ.end();
322 DTWireId wireId = (*wireAndPos).first;
323 if(wireId.
layerId() == missLayerId) {
325 if(fabs(segPosAtZLayer.
x() - (*wireAndPos).second) < 2.1)
328 if(fabs(segPosAtZLayer.
y() - (*wireAndPos).second) < 2.1)
334 cout <<
"[DTEfficiencyTask] Cell without hit is: " << missWireId << endl;
338 bool foundUnAssRechit =
false;
341 if(wireAnd1DRecHits.find(missWireId) != wireAnd1DRecHits.end()) {
343 cout <<
"[DTEfficiencyTask] Unassociated Hit found!" << endl;
344 foundUnAssRechit =
true;
348 for(map<DTLayerId, bool>::const_iterator iter = layerMap.begin();
349 iter != layerMap.end(); iter++) {
351 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), NumWireMap[(*iter).first]);
353 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), missWireId.wire(), foundUnAssRechit);
358 if((rPhi && recHits1D.size() == 8) || (rZ && recHits1D.size() == 12)) {
359 map<DTLayerId, int> NumWireMap;
361 for(vector<DTRecHit1D>::const_iterator recHit = recHits1D.begin();
362 recHit != recHits1D.end();
364 LayerID = (*recHit).wireId().layerId();
365 NumWireMap[LayerID]= (*recHit).wireId().wire();
367 for(map<DTLayerId, int>::const_iterator iter = NumWireMap.begin();
368 iter != NumWireMap.end(); iter++) {
369 fillHistos((*iter).first, dtGeom->layer((*iter).first)->specificTopology().firstChannel(), dtGeom->layer((*iter).first)->specificTopology().lastChannel(), NumWireMap[(*iter).first]);
381 cout <<
" Booking histos for L: " << lId << endl;
388 stringstream layer; layer << lId.
layer();
392 "_St" + station.str() +
393 "_Sec" + sector.str() +
394 "_SL" + superLayer.str()+
397 theDbe->setCurrentFolder(
"DT/DTEfficiencyTask/Wheel" + wheel.str() +
398 "/Station" + station.str() +
399 "/Sector" + sector.str() +
400 "/SuperLayer" +superLayer.str());
402 vector<MonitorElement *>
histos;
404 histos.push_back(theDbe->book1D(
"hEffOccupancy"+lHistoName,
"4D segments recHits occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
406 histos.push_back(theDbe->book1D(
"hEffUnassOccupancy"+lHistoName,
"4D segments recHits and Hits not associated occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
408 histos.push_back(theDbe->book1D(
"hRecSegmOccupancy"+lHistoName,
"4D segments cells occupancy",lastWire-firstWire+1, firstWire-0.5, lastWire+0.5));
416 int firstWire,
int lastWire,
418 if(histosPerL.find(lId) == histosPerL.end()){
421 vector<MonitorElement *>
histos = histosPerL[lId];
422 histos[0]->Fill(numWire);
423 histos[1]->Fill(numWire);
424 histos[2]->Fill(numWire);
429 int firstWire,
int lastWire,
432 if(histosPerL.find(lId) == histosPerL.end()){
435 vector<MonitorElement *>
histos = histosPerL[lId];
437 histos[1]->Fill(missingWire);
438 histos[2]->Fill(missingWire);
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
To reset the MEs.
DTChamberId chamberId() const
Return the corresponding ChamberId.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
static std::pair< DTLayerId, DTSuperLayerIdComparator > layersBySuperLayer(DTSuperLayerId slId)
Access by SL objects written into a RangeMap by layer.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
const DTLayer * layer(DTLayerId id) const
Return the layer corresponding to the given id.
int layer() const
Return the layer number.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
void fillHistos(DTLayerId lId, int firstWire, int lastWire, int numWire)
Geom::Theta< T > theta() const
C::const_iterator const_iterator
constant access iterator type
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Cos< T >::type cos(const T &t)
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
void bookHistos(DTLayerId lId, int fisrtWire, int lastWire)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
virtual ~DTEfficiencyTask()
Destructor.
int superlayer() const
Return the superlayer number (deprecated method name)
void analyze(const edm::Event &event, const edm::EventSetup &setup)
LuminosityBlockNumber_t luminosityBlock() const
DTLayerId layerId() const
Return the corresponding LayerId.
DTEfficiencyTask(const edm::ParameterSet &pset)
Constructor.
int station() const
Return the station number.
int wheel() const
Return the wheel number.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.