CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTRunConditionVar.cc
Go to the documentation of this file.
1 /******* \class DTRunConditionVar *******
2  *
3  * Description:
4  *
5  * detailed description
6  *
7  * \author : Paolo Bellan, Antonio Branca
8  * $date : 23/09/2011 15:42:04 CET $
9  * $Revision: 1.4 $
10  *
11  * Modification:
12  *
13  *********************************/
14 
15 #include "DTRunConditionVar.h"
16 
21 
23 
25 
29 
32 
34 
36 
40 
41 #include <TMath.h>
42 #include <cmath>
43 
44 using namespace std;
45 using namespace edm;
46 
48  // Get the debug parameter for verbose output
49  debug(pSet.getUntrackedParameter<bool>("debug",false)),
50  nMinHitsPhi(pSet.getUntrackedParameter<int>("nMinHitsPhi")),
51  maxAnglePhiSegm(pSet.getUntrackedParameter<double>("maxAnglePhiSegm")),
52  thedt4DSegments_(pSet.getParameter<InputTag>("recoSegments"))
53 {
54  // LogVerbatim("DTDQM|DTRunConditionVar|DTRunConditionVar")
55  // << "DTRunConditionVar: constructor called";
56 
57  // Get the DQM needed services
59 
60 }
61 
63 {
64  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
65  << "DTRunConditionVar: destructor called";
66 
67  // free memory
68 }
69 
70 
71 
73 
74  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
75  << "DTRunConditionVar: beginOfJob";
76 
77  for(int wheel=-2;wheel<=2;wheel++){
78  for(int sec=1; sec<=14; sec++) {
79  for(int stat=1; stat<=4; stat++) {
80 
81  bookChamberHistos(DTChamberId(wheel,stat,sec),"VDrift_FromSegm",100,0.0043,0.0065);
82  bookChamberHistos(DTChamberId(wheel,stat,sec),"T0_FromSegm",100,-25.,25.);
83 
84  }
85  }
86  }
87 
88 
89  return;
90 }
91 
92 
93 
94 
95 
97 {
98  // Get the DT Geometry
99  setup.get<MuonGeometryRecord>().get(dtGeom);
100 
101  return;
102 }
103 
104 
105 
106 
108 {
109  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
110  << "DTRunConditionVar: endOfJob";
111 
112  return;
113 }
114 
115 
116 
118  const EventSetup& eventSetup)
119 {
120 
121  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") <<
122  "--- [DTRunConditionVar] Event analysed #Run: " <<
123  event.id().run() << " #Event: " << event.id().event() << endl;
124 
125  // Get the DT Geometry
127  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
128 
129  // Get the map of vdrift from the setup
130  eventSetup.get<DTMtimeRcd>().get(mTime);
131  mTimeMap_ = &*mTime;
132 
133  // Get the segment collection from the event
134  Handle<DTRecSegment4DCollection> all4DSegments;
135  event.getByLabel(thedt4DSegments_, all4DSegments);
136 
137  // Loop over the segments
138  for(DTRecSegment4DCollection::const_iterator segment = all4DSegments->begin();
139  segment != all4DSegments->end(); ++segment){
140 
141  // Get the chamber from the setup
142  DTChamberId DTid = (DTChamberId) segment->chamberId();
143  uint32_t indexCh = DTid.rawId();
144 
145  // Fill v-drift values
146  if( (*segment).hasPhi() ) {
147 
148  int nHitsPhi = (*segment).phiSegment()->degreesOfFreedom()+2;
149  double xdir = (*segment).phiSegment()->localDirection().x();
150  double zdir = (*segment).phiSegment()->localDirection().z();
151 
152  double anglePhiSegm = fabs(atan(xdir/zdir))*180./TMath::Pi();
153 
154  if( nHitsPhi >= nMinHitsPhi && anglePhiSegm <= maxAnglePhiSegm ) {
155 
156  double segmentVDrift = segment->phiSegment()->vDrift();
157 
158 
159  DTSuperLayerId indexSLPhi1(DTid,1);
160  DTSuperLayerId indexSLPhi2(DTid,3);
161 
162  float vDriftPhi1(0.), vDriftPhi2(0.);
163  float ResPhi1(0.), ResPhi2(0.);
164  int status1 = mTimeMap_->get(indexSLPhi1,vDriftPhi1,ResPhi1,DTVelocityUnits::cm_per_ns);
165  int status2 = mTimeMap_->get(indexSLPhi2,vDriftPhi2,ResPhi2,DTVelocityUnits::cm_per_ns);
166 
167  if(status1 != 0 || status2 != 0) {
168  DTSuperLayerId sl = (status1 != 0) ? indexSLPhi1 : indexSLPhi2;
169  throw cms::Exception("DTRunConditionVarClient") << "Could not find vDrift entry in DB for"
170  << sl << endl;
171  }
172 
173  float vDriftMed = (vDriftPhi1 + vDriftPhi2) / 2.;
174 
175  segmentVDrift = vDriftMed*(1. - segmentVDrift);
176 
177  double segmentT0 = segment->phiSegment()->t0();
178 
179  if( segment->phiSegment()->ist0Valid() ) (chamberHistos[indexCh])["T0_FromSegm"]->Fill(segmentT0);
180  if( segmentVDrift != vDriftMed ) (chamberHistos[indexCh])["VDrift_FromSegm"]->Fill(segmentVDrift);
181 
182  }
183  }
184 
185  // if( (*segment).hasZed() ){
186  // double segmentVDrift = segment->zSegment()->vDrift();
187  // double segmentT0 = segment->zSegment()->t0();
188  //
189  //
190  // if(segmentT0 != -999 ) ht0[sector-1]->Fill(segmentT0);
191  // if( segmentVDrift > 0.00 ) hvd[sector-1]->Fill(segmentVDrift);
192  //
193  // }
194  } //end loop on segment
195 
196 } //end analyze
197 
198 
199 
200 
201 void DTRunConditionVar::bookChamberHistos(const DTChamberId& dtCh, string histoType, int nbins, float min, float max) {
202 
203  int wh = dtCh.wheel();
204  int sc = dtCh.sector();
205  int st = dtCh.station();
206  stringstream wheel; wheel << wh;
207  stringstream station; station << st;
208  stringstream sector; sector << sc;
209 
210  string bookingFolder = "DT/02-Segments/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str();
211  string histoTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
212 
213  theDbe->setCurrentFolder(bookingFolder);
214 
215  LogTrace ("DTDQM|DTMonitorModule|DTRunConditionVar")
216  << "[DTRunConditionVar]: booking histos in " << bookingFolder << endl;
217 
218  string histoName = histoType + histoTag;
219  string histoLabel = histoType;
220 
221  (chamberHistos[dtCh.rawId()])[histoType] =
222  theDbe->book1D(histoName,histoLabel,nbins,min,max);
223 
224 }
const double Pi
edm::ESHandle< DTMtime > mTime
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
void bookChamberHistos(const DTChamberId &dtCh, std::string histoType, int, float, float)
#define min(a, b)
Definition: mlp_lapack.h:161
const DTMtime * mTimeMap_
void beginRun(const edm::Run &, const edm::EventSetup &)
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
const T & max(const T &a, const T &b)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
edm::InputTag thedt4DSegments_
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
#define LogTrace(id)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chamberHistos
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
const T & get() const
Definition: EventSetup.h:55
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:86
int sector() const
Definition: DTChamberId.h:63
int station() const
Return the station number.
Definition: DTChamberId.h:53
#define debug
Definition: MEtoEDMFormat.h:34
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::ESHandle< DTGeometry > dtGeom
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
DTRunConditionVar(const edm::ParameterSet &pset)