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  *
10  * Modification:
11  *
12  *********************************/
13 
14 #include "DTRunConditionVar.h"
15 
20 
22 
24 
27 
30 
32 
34 
38 
39 #include <TMath.h>
40 #include <cmath>
41 
42 using namespace std;
43 using namespace edm;
44 
46  // Get the debug parameter for verbose output
47  debug(pSet.getUntrackedParameter<bool>("debug",false)),
48  nMinHitsPhi(pSet.getUntrackedParameter<int>("nMinHitsPhi")),
49  maxAnglePhiSegm(pSet.getUntrackedParameter<double>("maxAnglePhiSegm")),
50  dt4DSegmentsToken_(consumes<DTRecSegment4DCollection>(
51  pSet.getParameter<InputTag>("recoSegments")))
52 {
53  // LogVerbatim("DTDQM|DTRunConditionVar|DTRunConditionVar")
54  // << "DTRunConditionVar: constructor called";
55 
56  // Get the DQM needed services
58 
59 }
60 
62 {
63  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
64  << "DTRunConditionVar: destructor called";
65 
66  // free memory
67 }
68 
69 
70 
72 
73  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
74  << "DTRunConditionVar: beginOfJob";
75 
76  for(int wheel=-2;wheel<=2;wheel++){
77  for(int sec=1; sec<=14; sec++) {
78  for(int stat=1; stat<=4; stat++) {
79 
80  bookChamberHistos(DTChamberId(wheel,stat,sec),"VDrift_FromSegm",100,0.0043,0.0065);
81  bookChamberHistos(DTChamberId(wheel,stat,sec),"T0_FromSegm",100,-25.,25.);
82 
83  }
84  }
85  }
86 
87 
88  return;
89 }
90 
91 
92 
93 
94 
96 {
97  // Get the DT Geometry
98  setup.get<MuonGeometryRecord>().get(dtGeom);
99 
100  return;
101 }
102 
103 
104 
105 
107 {
108  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
109  << "DTRunConditionVar: endOfJob";
110 
111  return;
112 }
113 
114 
115 
117  const EventSetup& eventSetup)
118 {
119 
120  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") <<
121  "--- [DTRunConditionVar] Event analysed #Run: " <<
122  event.id().run() << " #Event: " << event.id().event() << endl;
123 
124  // Get the DT Geometry
126  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
127 
128  // Get the map of vdrift from the setup
129  eventSetup.get<DTMtimeRcd>().get(mTime);
130  mTimeMap_ = &*mTime;
131 
132  // Get the segment collection from the event
133  Handle<DTRecSegment4DCollection> all4DSegments;
134  event.getByToken(dt4DSegmentsToken_, all4DSegments);
135 
136  // Loop over the segments
137  for(DTRecSegment4DCollection::const_iterator segment = all4DSegments->begin();
138  segment != all4DSegments->end(); ++segment){
139 
140  // Get the chamber from the setup
141  DTChamberId DTid = (DTChamberId) segment->chamberId();
142  uint32_t indexCh = DTid.rawId();
143 
144  // Fill v-drift values
145  if( (*segment).hasPhi() ) {
146 
147  int nHitsPhi = (*segment).phiSegment()->degreesOfFreedom()+2;
148  double xdir = (*segment).phiSegment()->localDirection().x();
149  double zdir = (*segment).phiSegment()->localDirection().z();
150 
151  double anglePhiSegm = fabs(atan(xdir/zdir))*180./TMath::Pi();
152 
153  if( nHitsPhi >= nMinHitsPhi && anglePhiSegm <= maxAnglePhiSegm ) {
154 
155  double segmentVDrift = segment->phiSegment()->vDrift();
156 
157 
158  DTSuperLayerId indexSLPhi1(DTid,1);
159  DTSuperLayerId indexSLPhi2(DTid,3);
160 
161  float vDriftPhi1(0.), vDriftPhi2(0.);
162  float ResPhi1(0.), ResPhi2(0.);
163  int status1 = mTimeMap_->get(indexSLPhi1,vDriftPhi1,ResPhi1,DTVelocityUnits::cm_per_ns);
164  int status2 = mTimeMap_->get(indexSLPhi2,vDriftPhi2,ResPhi2,DTVelocityUnits::cm_per_ns);
165 
166  if(status1 != 0 || status2 != 0) {
167  DTSuperLayerId sl = (status1 != 0) ? indexSLPhi1 : indexSLPhi2;
168  throw cms::Exception("DTRunConditionVarClient") << "Could not find vDrift entry in DB for"
169  << sl << endl;
170  }
171 
172  float vDriftMed = (vDriftPhi1 + vDriftPhi2) / 2.;
173 
174  segmentVDrift = vDriftMed*(1. - segmentVDrift);
175 
176  double segmentT0 = segment->phiSegment()->t0();
177 
178  if( segment->phiSegment()->ist0Valid() ) (chamberHistos[indexCh])["T0_FromSegm"]->Fill(segmentT0);
179  if( segmentVDrift != vDriftMed ) (chamberHistos[indexCh])["VDrift_FromSegm"]->Fill(segmentVDrift);
180 
181  }
182  }
183 
184  // if( (*segment).hasZed() ){
185  // double segmentVDrift = segment->zSegment()->vDrift();
186  // double segmentT0 = segment->zSegment()->t0();
187  //
188  //
189  // if(segmentT0 != -999 ) ht0[sector-1]->Fill(segmentT0);
190  // if( segmentVDrift > 0.00 ) hvd[sector-1]->Fill(segmentVDrift);
191  //
192  // }
193  } //end loop on segment
194 
195 } //end analyze
196 
197 
198 
199 
200 void DTRunConditionVar::bookChamberHistos(const DTChamberId& dtCh, string histoType, int nbins, float min, float max) {
201 
202  int wh = dtCh.wheel();
203  int sc = dtCh.sector();
204  int st = dtCh.station();
205  stringstream wheel; wheel << wh;
206  stringstream station; station << st;
207  stringstream sector; sector << sc;
208 
209  string bookingFolder = "DT/02-Segments/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str();
210  string histoTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
211 
212  theDbe->setCurrentFolder(bookingFolder);
213 
214  LogTrace ("DTDQM|DTMonitorModule|DTRunConditionVar")
215  << "[DTRunConditionVar]: booking histos in " << bookingFolder << endl;
216 
217  string histoName = histoType + histoTag;
218  string histoLabel = histoType;
219 
220  (chamberHistos[dtCh.rawId()])[histoType] =
221  theDbe->book1D(histoName,histoLabel,nbins,min,max);
222 
223 }
224 
225 // Local Variables:
226 // show-trailing-whitespace: t
227 // truncate-lines: t
228 // End:
const double Pi
edm::ESHandle< DTMtime > mTime
edm::EDGetTokenT< DTRecSegment4DCollection > dt4DSegmentsToken_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:942
void bookChamberHistos(const DTChamberId &dtCh, std::string histoType, int, float, float)
const DTMtime * mTimeMap_
void beginRun(const edm::Run &, const edm::EventSetup &)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const T & max(const T &a, const T &b)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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)
#define debug
Definition: HDRShower.cc:19
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:82
int sector() const
Definition: DTChamberId.h:61
volatile std::atomic< bool > shutdown_flag false
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
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:655
Definition: Run.h:41
DTRunConditionVar(const edm::ParameterSet &pset)