CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTLocalTriggerLutTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTLocalLutTriggerTask.cc
3  *
4  * $Date: 2011/06/10 13:23:26 $
5  * $Revision: 1.1 $
6  * \author D. Fasanella - INFN Bologna
7  *
8  */
9 
11 
12 // Framework
14 
15 // DT trigger
18 
19 // Geometry
25 
26 //Root
27 #include"TH1.h"
28 #include"TAxis.h"
29 
30 #include <sstream>
31 #include <iostream>
32 #include <math.h>
33 
34 
35 using namespace edm;
36 using namespace std;
37 
39 
40  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerLutTask") << "[DTLocalTriggerLutTask]: Constructor"<<endl;
41 
42  dccInputTag = ps.getUntrackedParameter<InputTag>("inputTagDCC");
43  segInputTag = ps.getUntrackedParameter<InputTag>("inputTagSEG");
44 
45  overUnderIn = ps.getUntrackedParameter<bool>("rebinOutFlowsInGraph");
46  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis");
47  theGeomLabel = ps.getUntrackedParameter<string>("geomLabel");
48 
49  if (detailedAnalysis){
50  nPhiBins = 401;
51  rangePhi = 10.025;
52  nPhibBins = 401;
53  rangePhiB = 10.025;
54  } else {
55  nPhiBins = 51;
56  rangePhi = 5.1;
57  nPhibBins = 51;
58  rangePhiB = 10.2;
59  }
60 
61  baseFolder = "DT/03-LocalTrigger-DCC/";
62  parameters = ps;
64 
65 }
66 
67 
69 
70  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerLutTask") << "[DTLocalTriggerLutTask]: analyzed " << nEvents << " events" << endl;
71  if (trigGeomUtils) { delete trigGeomUtils; }
72 
73 }
74 
75 
77 
78  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerLutTask") << "[DTLocalTriggerLutTask]: BeginJob" << endl;
79  nEvents = 0;
80  nLumis = 0;
81 
82 }
83 
85 
86  stringstream wheel; wheel << chId.wheel();
87  stringstream sector; sector << chId.sector();
88  stringstream station; station << chId.station();
89 
90  dbe->setCurrentFolder(topFolder() + "Wheel" + wheel.str() + "/Sector" + sector.str() +
91  "/Station" + station.str() + "/Segment");
92 
93  string chTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
94  std::map<std::string, MonitorElement*> &chambMap = chHistos[chId.rawId()];
95 
96  string hName = "DCC_PhiResidual";
97  chambMap[hName] = dbe->book1D(hName+chTag,"Trigger local position - Segment local position (correlated triggers)",nPhiBins,-rangePhi,rangePhi);
98  hName = "DCC_PhibResidual";
99  chambMap[hName] =dbe->book1D(hName+chTag,"Trigger local direction - Segment local direction (correlated triggers)",nPhibBins,-rangePhiB,rangePhiB);
100 
101  if (detailedAnalysis) {
102 
103  hName = "DCC_PhitkvsPhitrig";
104  chambMap[hName] = dbe->book2D(hName+chTag,"Local position: segment vs trigger",100,-500.,500.,100,-500.,500.);
105  hName = "DCC_PhibtkvsPhibtrig";
106  chambMap[hName] =dbe->book2D(hName+chTag,"Local direction : segment vs trigger",200,-40.,40.,200,-40.,40.);
107  hName = "DCC_PhibResidualvsTkPos";
108  chambMap[hName] =dbe->book2D(hName+chTag,"Local direction residual vs Segment Position",100,-500.,500.,200,-10.,10.);
109  hName = "DCC_PhiResidualvsTkPos";
110  chambMap[hName] =dbe->book2D(hName+chTag,"Local Position residual vs Segment Position",100,-500.,500.,200,-10.,10.);
111 
112  }
113 
114 }
115 
116 
117 
119 
120  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerLutTask") << "[DTLocalTriggerLutTask]: BeginRun" << endl;
121 
124 
125  std::vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
126  std::vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
127 
128  for (; chambIt!=chambEnd; ++chambIt)
129  bookHistos((*chambIt)->id());
130 
131 }
132 
133 
135 
136  nLumis++;
137  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerLutTask") << "[DTLocalTriggerLutTask]: Begin of LS transition" << endl;
138 
139  if(nLumis%parameters.getUntrackedParameter<int>("ResetCycle") == 0) {
140 
141  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerLutTask") << "[DTLocalTriggerLutTask]: Cleaning histos" << endl;
142  map<uint32_t, map<string, MonitorElement*> > ::const_iterator chambIt = chHistos.begin();
143  map<uint32_t, map<string, MonitorElement*> > ::const_iterator chambEnd = chHistos.end();
144 
145  for(; chambIt!=chambEnd; ++chambIt) {
146  map<string, MonitorElement*> ::const_iterator histoIt = chambIt->second.begin();
147  map<string, MonitorElement*> ::const_iterator histoEnd = chambIt->second.end();
148  for(; histoIt!=histoEnd; ++ histoIt) {
149  histoIt->second->Reset();
150  }
151  }
152 
153  }
154 
155 }
156 
157 
159 
160  LogVerbatim("DTDQM|DTMonitorModule|DTLocalTriggerLutTask") << "[DTLocalTriggerLutTask]: analyzed " << nEvents << " events" << endl;
161  dbe->rmdir(topFolder());
162 
163 }
164 
165 
167 
168  nEvents++;
169 
171  e.getByLabel(dccInputTag,trigHandle);
172  vector<L1MuDTChambPhDigi>* trigs = trigHandle->getContainer();
173  searchDccBest(trigs);
174 
176  e.getByLabel(segInputTag,segments4D);
178 
179  // Preliminary loop finds best 4D Segment and high quality ones
180  vector<const DTRecSegment4D*> best4DSegments;
181 
182  for (chamberId = segments4D->id_begin(); chamberId != segments4D->id_end(); ++chamberId){
183 
184  DTRecSegment4DCollection::range rangeInCh = segments4D->get(*chamberId);
185  DTRecSegment4DCollection::const_iterator trackIt = rangeInCh.first;
186  DTRecSegment4DCollection::const_iterator trackEnd = rangeInCh.second;
187 
188  const DTRecSegment4D* tmpBest = 0;
189  int tmpdof = 0;
190  int dof = 0;
191 
192  for (; trackIt!=trackEnd; ++trackIt){
193 
194  if(trackIt->hasPhi()) {
195  dof = trackIt->phiSegment()->degreesOfFreedom();
196  if (dof>tmpdof) {
197  tmpBest = &(*trackIt);
198  tmpdof = dof;
199  }
200  }
201 
202  }
203 
204  if (tmpBest) best4DSegments.push_back(tmpBest);
205 
206  }
207 
208  vector<const DTRecSegment4D*>::const_iterator bestTrackIt = best4DSegments.begin();
209  vector<const DTRecSegment4D*>::const_iterator bestTrackEnd = best4DSegments.end();
210 
211  for (; bestTrackIt!=bestTrackEnd; ++bestTrackIt) {
212 
213  if((*bestTrackIt)->hasPhi()) {
214 
215  DTChamberId chId = (*bestTrackIt)->chamberId();
216  int nHitsPhi = (*bestTrackIt)->phiSegment()->degreesOfFreedom()+2;
217 
218  int wheel = chId.wheel();
219  int station = chId.station();
220  int scsector = 0;
221  float trackPosPhi, trackPosEta, trackDirPhi, trackDirEta;
222  trigGeomUtils->computeSCCoordinates((*bestTrackIt),scsector,trackPosPhi,trackDirPhi,trackPosEta,trackDirEta);
223 
224  map<string, MonitorElement*> &chMap = chHistos[chId.rawId()];
225 
226  if (trigQualBest[wheel+3][station][scsector] > 3 && // residuals only for correlate triggers
227  trigQualBest[wheel+3][station][scsector] < 7 &&
228  nHitsPhi>=7 ) {
229 
230  float trigPos = trigGeomUtils->trigPos(trigBest[wheel+3][station][scsector]);
231  float trigDir = trigGeomUtils->trigDir(trigBest[wheel+3][station][scsector]);
232  trigGeomUtils->trigToSeg(station,trigPos,trackDirPhi);
233 
234  double deltaPos = trigPos-trackPosPhi;
235  deltaPos = overUnderIn ? max(min(deltaPos,rangePhi-0.01),-rangePhi+0.01) : deltaPos;
236  double deltaDir = trigDir-trackDirPhi;
237  deltaDir = overUnderIn ? max(min(deltaDir,rangePhiB-0.01),-rangePhiB+0.01) : deltaDir;
238  chMap.find("DCC_PhiResidual")->second->Fill(deltaPos);
239  chMap.find("DCC_PhibResidual")->second->Fill(deltaDir);
240 
241  if (detailedAnalysis){
242  chMap.find("DCC_PhitkvsPhitrig")->second->Fill(trigPos,trackPosPhi);
243  chMap.find("DCC_PhibtkvsPhibtrig")->second->Fill(trigDir,trackDirPhi);
244  chMap.find("DCC_PhibResidualvsTkPos")->second->Fill(trackPosPhi,trigDir-trackDirPhi);
245  chMap.find("DCC_PhiResidualvsTkPos")->second->Fill(trackPosPhi,trigPos-trackPosPhi);
246  }
247 
248  }
249 
250  }
251  }
252 
253 }
254 
255 void DTLocalTriggerLutTask::searchDccBest( std::vector<L1MuDTChambPhDigi>* trigs ){
256 
257  string histoType ;
258  string histoTag ;
259 
260  // define best quality trigger segment
261  // start from 1 and zero is kept empty
262  for (int st=0;st<=4;++st)
263  for (int wh=0;wh<=5;++wh)
264  for (int sec=0;sec<=12;++sec)
265  trigQualBest[wh][st][sec] = -1;
266 
267  vector<L1MuDTChambPhDigi>::const_iterator trigIt = trigs->begin();
268  vector<L1MuDTChambPhDigi>::const_iterator trigEnd = trigs->end();
269  for(; trigIt!=trigEnd; ++trigIt) {
270 
271  int wh = trigIt->whNum();
272  int sec = trigIt->scNum() + 1; // DTTF -> DT sector range transform
273  int st = trigIt->stNum();
274  int qual = trigIt->code();
275 
276  if(qual>trigQualBest[wh+3][st][sec] && qual<7) {
277  trigQualBest[wh+3][st][sec]=qual;
278  trigBest[wh+3][st][sec] = &(*trigIt);
279  }
280 
281  }
282 }
T getUntrackedParameter(std::string const &, T const &) const
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:52
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
virtual int degreesOfFreedom() const
return the DOF of the segment
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
std::string & topFolder()
Get the top folder.
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
float trigDir(const L1MuDTChambPhDigi *trig)
Return local direction (trigger RF) for a given trigger primitive.
DTLocalTriggerLutTask(const edm::ParameterSet &ps)
Constructor.
identifier iterator
Definition: RangeMap.h:138
#define min(a, b)
Definition: mlp_lapack.h:161
edm::ParameterSet parameters
edm::ESHandle< DTGeometry > muonGeom
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
virtual ~DTLocalTriggerLutTask()
Destructor.
const T & max(const T &a, const T &b)
void trigToSeg(int st, float &x, float dir)
Compute Trigger x coordinate in chamber RF.
void searchDccBest(std::vector< L1MuDTChambPhDigi > *trigs)
Find best (highest qual) DCC trigger segments.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chHistos
DTTrigGeomUtils * trigGeomUtils
const T & get() const
Definition: EventSetup.h:55
void beginRun(const edm::Run &, const edm::EventSetup &)
BeginRun.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
To reset the MEs.
int sector() const
Definition: DTChamberId.h:63
void bookHistos(DTChamberId chId)
Book histos.
const L1MuDTChambPhDigi * trigBest[6][5][13]
float trigPos(const L1MuDTChambPhDigi *trig)
Return local position (trigger RF) for a given trigger primitive.
int station() const
Return the station number.
Definition: DTChamberId.h:53
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
void computeSCCoordinates(const DTRecSegment4D *track, int &scsec, float &x, float &xdir, float &y, float &ydir)
Compute track coordinates with SC sector numbering.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33