24 LogDebug(
"MuonME0SegmentsValidation")<<
"Info : Loading Geometry information\n";
27 unsigned int nregion = 2;
29 edm::LogInfo(
"MuonME0SegmentsValidation")<<
"+++ Info : # of region : "<<nregion<<std::endl;
31 LogDebug(
"MuonME0SegmentsValidation")<<
"+++ Info : finish to get geometry information from ES.\n";
34 me0_simsegment_pt = ibooker.
book1D(
"me0_simsegment_pt",
"SimSegment pT Distribution; p_{T}; entries",20,0.0,100.0);
44 me0_segment_numRH = ibooker.
book1D(
"me0_seg_NumberRH",
"Number of fitted RecHits; # RecHits; entries",11,-0.5,10.5);
45 me0_segment_numRHSig = ibooker.
book1D(
"me0_seg_NumberRHSig",
"Number of fitted Signal RecHits; # RecHits; entries",11,-0.5,10.5);
51 me0_segment_size = ibooker.
book1D(
"me0_seg_size",
"Segment Multiplicity; Number of ME0 segments; entries",200,0,200);
53 for(
unsigned int region_num = 0 ; region_num < nregion ; region_num++ ) {
55 for(
unsigned int layer_num = 0 ; layer_num < 6 ; layer_num++) {
64 " layer "+layerLabel[layer_num]+
" "+
" ; x_{SimHit} - x_{Segment RecHits} ; entries";
66 " layer "+layerLabel[layer_num]+
" "+
" ; y_{SimHit} - y_{Segment RecHit} ; entries";
68 me0_specRH_DeltaX[region_num][layer_num] = ibooker.
book1D(histo_name_DeltaX.c_str(), histo_label_DeltaX.c_str(),100,-10,10);
69 me0_specRH_DeltaY[region_num][layer_num] = ibooker.
book1D(histo_name_DeltaY.c_str(), histo_label_DeltaY.c_str(),100,-10,10);
74 " layer "+layerLabel[layer_num]+
" "+
" ; #frac{x_{SimHit} - x_{Segment RecHit}}{#sigma_{x,RecHit}} ; entries";
76 " layer "+layerLabel[layer_num]+
" "+
" ; #frac{y_{SimHit} - y_{Segment RecHit}}{#sigma_{y,RecHit}} ; entries";
78 me0_specRH_PullX[region_num][layer_num] = ibooker.
book1D(histo_name_PullX.c_str(), histo_label_DeltaX.c_str(),100,-10,10);
79 me0_specRH_PullY[region_num][layer_num] = ibooker.
book1D(histo_name_PullY.c_str(), histo_label_DeltaY.c_str(),100,-10,10);
110 edm::LogError(
"ME0SegmentsValidation") <<
"Cannot get ME0Digis by Token InputTagToken";
115 edm::LogError(
"ME0SegmentsValidation") <<
"Cannot get ME0RecHits/ME0Segments by Token InputTagToken";
120 edm::LogError(
"ME0HitsValidation") <<
"Cannot get ME0Hits by Token simInputTagToken";
130 edm::SimTrackContainer::const_iterator
simTrack;
131 for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++
simTrack){
138 for (edm::PSimHitContainer::const_iterator itHit = ME0Hits->begin(); itHit != ME0Hits->end(); ++itHit){
140 int particleType_sh = itHit->particleType();
141 int evtId_sh = itHit->eventId().event();
142 int bx_sh = itHit->eventId().bunchCrossing();
143 int procType_sh = itHit->processType();
144 if(!(
abs(particleType_sh) == 13 && evtId_sh == 0 && bx_sh == 0 && procType_sh == 0))
continue;
149 selectedME0Hits.push_back(*itHit);;
155 if(selectedME0Hits.size() >= 3){
169 for (
auto me0s = ME0Segments->begin(); me0s != ME0Segments->end(); me0s++) {
174 auto segLP = me0s->localPosition();
175 auto segLD = me0s->localDirection();
176 auto me0rhs = me0s->specificRecHits();
182 int numberRH = me0rhs.size();
184 float ndof = me0s->degreesOfFreedom();
185 double time = me0s->time();
186 double timeErr = me0s->timeErr();
188 float reducedChi2 = chi2/
ndof;
200 std::vector<ME0RecHit> selectedME0RecHits;
202 for (
auto rh = me0rhs.begin(); rh!= me0rhs.end(); rh++)
205 auto me0id = rh->me0Id();
207 auto rhLP = rh->localPosition();
213 selectedME0RecHits.push_back(*rh);
218 auto erhLEP = rh->localPositionError();
219 auto rhGP = rhr->toGlobal(rhLP);
220 auto rhLPSegm =
chamber->toLocal(rhGP);
221 float xe = segLP.x()+segLD.x()*rhLPSegm.z()/segLD.z();
222 float ye = segLP.y()+segLD.y()*rhLPSegm.z()/segLD.z();
223 float ze = rhLPSegm.z();
225 auto extSegm = rhr->toLocal(
chamber->toGlobal(extrPoint));
227 int region = me0id.region();
228 int layer = me0id.layer();
232 float xErr = erhLEP.xx();
234 float yErr = erhLEP.yy();
236 float globalR = rhGP.perp();
237 float globalX = rhGP.x();
238 float globalY = rhGP.y();
239 float globalZ = rhGP.z();
241 float xExt = extSegm.x();
242 float yExt = extSegm.y();
244 float pull_x = (x - xExt) /
sqrt(xErr);
245 float pull_y = (y - yExt) /
sqrt(yErr);
248 if ( region ==-1 ) region_num = 0 ;
249 else if ( region==1) region_num = 1;
250 int layer_num = layer-1;
270 for(
auto const& st : myMap) {
272 int num_sh = st.second.size();
273 bool isThereOneSegmentMatched =
false;
275 for(
auto const& seg : myMapSeg) {
277 int num_sh_matched = 0;
278 if(seg.second.empty())
continue;
280 for(
auto const& sh : st.second) {
282 for(
auto const& rh : seg.second) {
284 auto me0id = rh.me0Id();
285 int region_rh = (
int) me0id.region();
286 int layer_rh = (
int) me0id.layer();
287 int chamber_rh = (
int) me0id.chamber();
288 int roll_rh = (
int) me0id.roll();
291 int region_sh =
id.region();
292 int layer_sh =
id.layer();
293 int chamber_sh =
id.chamber();
294 int roll_sh =
id.roll();
296 if( !(region_sh == region_rh && chamber_sh == chamber_rh && layer_sh == layer_rh && roll_sh == roll_rh) )
continue;
303 float dphi_glob = gp_sh.
phi()-gp.
phi();
304 float deta_glob = gp_sh.
eta()-gp.
eta();
306 if(fabs(dphi_glob) < 3*
sigma_x_ && fabs(deta_glob) < 3*
sigma_y_) ++num_sh_matched;
313 if(num_sh != 0) quality = num_sh_matched/(1.0*num_sh);
314 if(quality > 0) isThereOneSegmentMatched =
true;
319 if(isThereOneSegmentMatched){
336 int roll_rh = (
int) me0id.
roll();
339 float l_x_rh = rhLP.
x();
340 float l_y_rh = rhLP.
y();
349 int region_dg = (
int)
id.region();
350 int layer_dg = (
int)
id.layer();
351 int roll_dg = (
int)
id.roll();
354 if(region_rh != region_dg)
continue;
355 if(layer_rh != layer_dg)
continue;
356 if(chamber_rh != chamber_dg)
continue;
357 if(roll_rh != roll_dg)
continue;
360 for (digiItr = (*cItr ).second.first; digiItr != (*cItr ).second.second; ++digiItr)
363 float l_x_dg = digiItr->x();
364 float l_y_dg = digiItr->y();
366 if(l_x_rh != l_x_dg)
continue;
367 if(l_y_rh != l_y_dg)
continue;
369 particleType = digiItr->pdgid();
370 isPrompt = digiItr->prompt();
376 std::pair<int,int>
result;
377 result = std::make_pair(particleType,isPrompt);
387 if ((*t).noVertex() && !
isMuonGun_)
return false;
388 if ((*t).noGenpart() && !
isMuonGun_)
return false;
389 if (
std::abs((*t).type()) != 13)
return false;
390 if ((*t).momentum().pt() <
pt_min_ )
return false;
392 if (eta < eta_min_ || eta >
eta_max_ )
return false;
402 int trackId = simTrack->trackId();
403 int trackId_sim = itHit->trackId();
404 if(trackId == trackId_sim) result =
true;
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
MonitorElement * BookHistZR(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
T getParameter(std::string const &) const
bool isSimTrackGood(edm::SimTrackContainer::const_iterator simTrack)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * me0_segment_redchi2
MonitorElement * me0_simsegment_pt
void analyze(const edm::Event &e, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Geom::Phi< T > phi() const
std::vector< std::string > layerLabel
edm::EDGetToken InputTagToken_Segments
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
const Plane & surface() const
The nominal surface of the GeomDet.
MonitorElement * me0_specRH_xy[2][6]
MonitorElement * me0_segment_ndof
MonitorElement * BookHistXY(DQMStore::IBooker &, const char *name, const char *label, unsigned int region_num, unsigned int layer_num=99)
ME0SegmentsValidation(const edm::ParameterSet &)
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Container::value_type value_type
MonitorElement * me0_segment_numRH
MonitorElement * me0_specRH_DeltaX[2][6]
simTrack
per collection params
MonitorElement * book1D(Args &&...args)
MonitorElement * me0_segment_time
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Abs< T >::type abs(const T &t)
MonitorElement * me0_specRH_PullX[2][6]
MonitorElement * me0_segment_numRHBkg
edm::EDGetToken InputTagTokenST_
std::vector< std::string > regionLabel
MonitorElement * me0_matchedsimsegment_phi
std::map< ME0SegmentCollection::const_iterator, std::vector< ME0RecHit > > MapTypeSeg
edm::EDGetToken InputTagToken_
MonitorElement * me0_segment_timeErr
edm::EDGetToken InputTagToken_Digis
MonitorElement * me0_specRH_PullY[2][6]
void setCurrentFolder(const std::string &fullpath)
MonitorElement * me0_matchedsimsegment_pt
~ME0SegmentsValidation() override
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
std::pair< int, int > isMatched(ME0DetId, LocalPoint, edm::Handle< ME0DigiPreRecoCollection >)
MonitorElement * me0_segment_size
std::vector< ME0DigiPreReco >::const_iterator const_iterator
const GeomDet * idToDet(DetId) const override
return(e1-e2)*(e1-e2)+dp *dp
MonitorElement * me0_segment_chi2
MonitorElement * me0_simsegment_eta
MonitorElement * me0_segment_numRHSig
std::map< edm::SimTrackContainer::const_iterator, edm::PSimHitContainer > MapTypeSim
MonitorElement * me0_specRH_DeltaY[2][6]
std::vector< PSimHit > PSimHitContainer
int layer() const
Layer id: each chamber has six layers of chambers: layer 1 is the inner layer and layer 6 is the oute...
MonitorElement * me0_simsegment_phi
MonitorElement * me0_matchedsimsegment_eta
bool isSimMatched(edm::SimTrackContainer::const_iterator, edm::PSimHitContainer::const_iterator)
MonitorElement * me0_specRH_zr[2]