test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTLocalTriggerSynchTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTLocalTriggerSynchTask.cc
3  *
4  * \author C. Battilana - CIEMAT
5  *
6 */
7 
9 
10 // Framework
13 
14 // Geometry
21 
22 // tTrigs
25 
26 // DT Digi
29 
30 
31 //Root
32 #include"TH1.h"
33 #include"TAxis.h"
34 
35 #include <sstream>
36 #include <iostream>
37 #include <fstream>
38 
39 
40 using namespace edm;
41 using namespace std;
42 
44 
45  edm::LogVerbatim ("DTLocalTriggerSynchTask") << "[DTLocalTriggerSynchTask]: Constructor" << endl;
46  parameters = ps;
47  tm_Token_ = consumes<L1MuDTChambPhContainer>(
48  parameters.getParameter<edm::InputTag>("TMInputTag"));
49  ddu_Token_ = consumes<DTLocalTriggerCollection>(
50  parameters.getParameter<edm::InputTag>("DDUInputTag"));
51  seg_Token_ = consumes<DTRecSegment4DCollection>(
52  parameters.getParameter<edm::InputTag>("SEGInputTag"));
53 
54  bxTime = parameters.getParameter<double>("bxTimeInterval"); // CB move this to static const or DB
55  rangeInBX = parameters.getParameter<bool>("rangeWithinBX");
56  nBXLow = parameters.getParameter<int>("nBXLow");
57  nBXHigh = parameters.getParameter<int>("nBXHigh");
58  angleRange = parameters.getParameter<double>("angleRange");
59  minHitsPhi = parameters.getParameter<int>("minHitsPhi");
60  baseDirectory = parameters.getParameter<string>("baseDir");
61 }
62 
63 
65 
66  edm::LogVerbatim ("DTLocalTriggerSynchTask") << "[DTLocalTriggerSynchTask]: analyzed " << nevents << " events" << endl;
67 
68 }
69 
71 
72  edm::LogVerbatim ("DTLocalTriggerSynchTask") <<"[DTLocalTriggerSynchTask]: Book Histograms"<<endl;
73 
74  ibooker.setCurrentFolder(baseDir());
75  ibooker.bookFloat("BXTimeSpacing")->Fill(bxTime);
76 
78  parameters.getParameter<edm::ParameterSet>("tTrigModeConfig"));
79  tTrigSync->setES(context);
80 
81 
82  std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
83  std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
84 
85  for (; chambIt!=chambEnd; ++chambIt) {
86  bookHistos(ibooker,(*chambIt)->id());
87  triggerHistos[(*chambIt)->id().rawId()]["tTrig_SL1"]->Fill(tTrigSync->offset(DTWireId((*chambIt)->id(),1,1,2)));
88  triggerHistos[(*chambIt)->id().rawId()]["tTrig_SL3"]->Fill(tTrigSync->offset(DTWireId((*chambIt)->id(),3,1,2)));
89  }
90 
91 
92 }
93 
94 
96 
97  context.get<MuonGeometryRecord>().get(muonGeom);
98 }
99 
100 
102 
103  nevents++;
104 
105  InputTag inputTagTM = parameters.getParameter<edm::InputTag>("TMInputTag");
106  InputTag inputTagDDU = parameters.getParameter<edm::InputTag>("DDUInputTag");
107  InputTag inputTagSEG = parameters.getParameter<edm::InputTag>("SEGInputTag");
108 
109  for (int i=0;i<5;++i){
110  for (int j=0;j<6;++j){
111  for (int k=0;k<13;++k){
112  phCodeBestTM[j][i][k] = -1;
113  phCodeBestDDU[j][i][k] = -1;
114  }
115  }
116  }
117 
118  // Get best TM triggers
120  event.getByToken(tm_Token_, l1DTTPGPh);
121  vector<L1MuDTChambPhDigi> const* phTrigs = l1DTTPGPh->getContainer();
122 
123  vector<L1MuDTChambPhDigi>::const_iterator iph = phTrigs->begin();
124  vector<L1MuDTChambPhDigi>::const_iterator iphe = phTrigs->end();
125  for(; iph !=iphe ; ++iph) {
126 
127  int phwheel = iph->whNum();
128  int phsec = iph->scNum() + 1; // DTTF[0-11] -> DT[1-12] Sector Numbering
129  int phst = iph->stNum();
130  int phcode = iph->code();
131 
132  if(phcode>phCodeBestTM[phwheel+3][phst][phsec] && phcode<7) {
133  phCodeBestTM[phwheel+3][phst][phsec]=phcode;
134  }
135 
136  }
137 
138  // Get best DDU triggers
140  event.getByToken(ddu_Token_, trigsDDU);
142 
143  for (detUnitIt=trigsDDU->begin();detUnitIt!=trigsDDU->end();++detUnitIt){
144 
145  const DTChamberId& id = (*detUnitIt).first;
146  const DTLocalTriggerCollection::Range& range = (*detUnitIt).second;
147 
148  int wh = id.wheel();
149  int sec = id.sector();
150  int st = id.station();
151 
152  for (DTLocalTriggerCollection::const_iterator trigIt = range.first; trigIt!=range.second;++trigIt){
153 
154  int quality = trigIt->quality();
155 
156  if(quality>-1 && quality<7 &&
157  quality>phCodeBestDDU[wh+3][st][sec]) {
158  phCodeBestDDU[wh+3][st][sec]=quality;
159  }
160  }
161  }
162 
163  //Get best segments (highest number of phi hits)
164  vector<const DTRecSegment4D*> bestSegments4D;
166  event.getByToken(seg_Token_, segments4D);
168  DTRecSegment4DCollection::id_iterator chambIdIt;
169 
170  for (chambIdIt = segments4D->id_begin(); chambIdIt != segments4D->id_end(); ++chambIdIt){
171 
172  DTRecSegment4DCollection::range range = segments4D->get(*chambIdIt);
173  const DTRecSegment4D* best=0;
174  int hitsBest = 0;
175  int hits = 0;
176 
177  for ( track = range.first; track != range.second; ++track){
178  if( (*track).hasPhi() ) {
179  hits = (*track).phiSegment()->degreesOfFreedom()+2;
180  if ( hits>hitsBest ){
181  best = &(*track);
182  hitsBest = hits;
183  }
184  }
185  }
186  if (best) {
187  bestSegments4D.push_back(best);
188  }
189  }
190 
191 
192  // Filling histos
193  vector<const DTRecSegment4D*>::const_iterator bestSegIt = bestSegments4D.begin();
194  vector<const DTRecSegment4D*>::const_iterator bestSegEnd = bestSegments4D.end();
195  for (; bestSegIt!=bestSegEnd; ++bestSegIt ){
196 
197  float dir = atan((*bestSegIt)->localDirection().x()/ (*bestSegIt)->localDirection().z())*180/Geom::pi(); // CB cerca un modo migliore x farlo
198  const DTRecSegment2D* seg2D = (*bestSegIt)->phiSegment();
199  int nHitsPhi = seg2D->degreesOfFreedom()+2;
200  DTChamberId chambId = (*bestSegIt)->chamberId();
201  map<string, MonitorElement*> &innerME = triggerHistos[chambId.rawId()];
202 
203  if (fabs(dir)<angleRange &&
204  nHitsPhi>=minHitsPhi &&
205  seg2D->ist0Valid()){
206 
207  float t0seg = (*bestSegIt)->phiSegment()->t0();
208  float tTrig = (tTrigSync->offset(DTWireId(chambId,1,1,2)) + tTrigSync->offset(DTWireId(chambId,3,1,2)) )/2;
209  float time = tTrig+t0seg;
210  float htime = rangeInBX ? time-int(time/bxTime)*bxTime : time-int(tTrig/bxTime)*bxTime;
211 
212  int wheel = chambId.wheel();
213  int sector = chambId.sector();
214  int station = chambId.station();
215  int scsector = sector>12 ? sector==13 ? 4 : 10 : sector;
216 
217  int qualTM = phCodeBestTM[wheel+3][station][scsector];
218  int qualDDU = phCodeBestDDU[wheel+3][station][scsector];
219 
220  if (fabs(t0seg)>0.01) {
221  innerME.find("SEG_TrackCrossingTime")->second->Fill(htime);
222  if ( qualTM>=0 ) innerME.find("TM_TrackCrossingTimeAll")->second->Fill(htime);
223  if ( qualTM==6 ) innerME.find("TM_TrackCrossingTimeHH")->second->Fill(htime);
224  if ( qualDDU>=0 ) innerME.find("DDU_TrackCrossingTimeAll")->second->Fill(htime);
225  if ( qualDDU==6 ) innerME.find("DDU_TrackCrossingTimeHH")->second->Fill(htime);
226  }
227 
228  }
229  }
230 
231 }
232 
234 
235  stringstream wheel; wheel << dtChId.wheel();
236  stringstream station; station << dtChId.station();
237  stringstream sector; sector << dtChId.sector();
238  uint32_t chRawId = dtChId.rawId();
239 
240  ibooker.setCurrentFolder(baseDir() + "/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str() );
241 
242 
243  string histoTag[5] = { "SEG_TrackCrossingTime", "TM_TrackCrossingTimeAll", "TM_TrackCrossingTimeHH", "DDU_TrackCrossingTimeAll", "DDU_TrackCrossingTimeHH" };
244 
245  float min = rangeInBX ? 0 : nBXLow*bxTime;
246  float max = rangeInBX ? bxTime : nBXHigh*bxTime;
247  int nbins = static_cast<int>(ceil( rangeInBX ? bxTime : (nBXHigh-nBXLow)*bxTime));
248 
249  for (int iHisto=0;iHisto<5;++iHisto) {
250  string histoName = histoTag[iHisto] + (rangeInBX ? "InBX" : "") + "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
251  edm::LogVerbatim ("DTLocalTriggerSynchTask") << "[DTLocalTriggerSynchTask]: booking "
252  << baseDir() + "/Wheel" << wheel.str()
253  << "/Sector" << sector.str()
254  << "/Station"<< station.str()
255  << "/" << histoName << endl;
256 
257  triggerHistos[chRawId][histoTag[iHisto]] = ibooker.book1D(histoName.c_str(),"Track time distribution",nbins,min,max);
258  }
259 
260  string floatTag[2] = { "tTrig_SL1", "tTrig_SL3" };
261 
262  for (int iFloat=0;iFloat<2;++iFloat) {
263  string floatName = floatTag[iFloat] + "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
264  triggerHistos[chRawId][floatTag[iFloat]] = ibooker.bookFloat(floatName);
265  }
266 
267 }
268 
269 // Local Variables:
270 // show-trailing-whitespace: t
271 // truncate-lines: t
272 // End:
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
virtual int degreesOfFreedom() const
return the DOF of the segment
void analyze(const edm::Event &event, const edm::EventSetup &context) override
Analyze.
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
double offset(const DTLayer *layer, const DTWireId &wireId, const GlobalPoint &globalPos)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Beginrun.
edm::EDGetTokenT< DTLocalTriggerCollection > ddu_Token_
void Fill(long long x)
edm::ESHandle< DTGeometry > muonGeom
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual void setES(const edm::EventSetup &setup)=0
Pass the Event Setup to the synchronization module at each event.
virtual ~DTLocalTriggerSynchTask()
Destructor.
DTLocalTriggerSynchTask(const edm::ParameterSet &ps)
Constructor.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Book the histograms.
int j
Definition: DBlmapReader.cc:9
T min(T a, T b)
Definition: MathUtil.h:58
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
bool ist0Valid() const
edm::EDGetTokenT< DTRecSegment4DCollection > seg_Token_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
const T & get() const
Definition: EventSetup.h:56
std::vector< DTLocalTrigger >::const_iterator const_iterator
std::map< uint32_t, std::map< std::string, MonitorElement * > > triggerHistos
int sector() const
Definition: DTChamberId.h:61
std::pair< const_iterator, const_iterator > Range
void bookHistos(DQMStore::IBooker &, const DTChamberId &dtCh)
Book the histograms.
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109
dbl *** dir
Definition: mlp_gen.cc:35
constexpr double pi()
Definition: Pi.h:31
int station() const
Return the station number.
Definition: DTChamberId.h:51
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_Token_
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:42