 |
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include "GaudiKernel/PhysicalConstants.h"
20 #include "RooRealVar.h"
21 #include "RooDataHist.h"
23 #include "RooBreitWigner.h"
24 #include "RooCBShape.h"
25 #include "RooFFTConvPdf.h"
26 #include "RooGlobalFunc.h"
27 #include "RooArgList.h"
28 #include "RooFitResult.h"
36 , m_triggerChainName(
"NoTrig")
91 m_varLabels[
"crtDiff"] =
"1/p_{T}(+) - 1/p_{T}(-) [GeV^{-1}]";
107 m_varRanges[
"crtDiff"] = std::make_pair(-0.15,0.15);
115 m_varRanges[
"crtDiff"] = std::make_pair(-0.03,0.03);
129 return StatusCode::SUCCESS;
158 m_stat =
new TH1F(
"statistics",
"Statistics",nCuts, 0.,
double(nCuts));
159 TString binLabels[] ={
"MuonIdTrk",
"TrkIsoPt40/Pt<.2",
"CombMuon",
"MCPgoodTrk",
"MuPtOK",
"eta<2.5",
"OppChargePair",
"InvMassOK"};
160 for(
int ilabel=0;ilabel<nCuts;ilabel++){
161 m_stat->GetXaxis()->SetBinLabel(ilabel+1,binLabels[ilabel]);
166 for (
const std::string& reg :
m_regions) {
170 m_varRanges[
"etaAll"] = std::make_pair(-1.05,1.05);
171 m_varRanges[
"etaPos"] = std::make_pair(-1.05,1.05);
172 m_varRanges[
"etaNeg"] = std::make_pair(-1.05,1.05);
173 }
else if (reg ==
"EAEA") {
177 }
else if (reg ==
"ECEC") {
178 m_varRanges[
"etaAll"] = std::make_pair(-2.5,-1.05);
179 m_varRanges[
"etaPos"] = std::make_pair(-2.5,-1.05);
180 m_varRanges[
"etaNeg"] = std::make_pair(-2.5,-1.05);
189 TString htitle =
hname +
"; Invmass[GeV/c^{2}]";
227 if (varD ==
"eta" || varD ==
"etaAll" || varD ==
"etaPos" || varD ==
"etaNeg" ){
229 }
else if (varD ==
"pt" || varD ==
"ptAll" || varD ==
"ptPos" || varD ==
"ptNeg" ){
231 }
else if (varD ==
"phi" || varD ==
"phiAll" || varD ==
"phiPos" || varD ==
"phiNeg" ){
241 return StatusCode::SUCCESS;
251 if(!muons.isValid()){
253 return StatusCode::FAILURE;
254 }
else ATH_MSG_DEBUG(
"Muon container successfully retrieved.");
260 for(
const auto*
muon : *muons ) {
263 if (!idTrk)
continue;
264 m_stat->Fill(
"MuonIdTrk",1);
265 double idTrkPt(0),ptSum(0);
268 return StatusCode::FAILURE;
271 idTrkPt = idTrk->
pt();
275 m_stat->Fill(
"TrkIsoPt40/Pt<.2",1);
276 if (!
muon->trackParticle(xAOD::Muon::CombinedTrackParticle))
continue;
277 m_stat->Fill(
"CombMuon",1);
280 m_stat->Fill(
"MCPgoodTrk",1);
282 if (idTrkPt <
m_ptCut*1000)
continue;
285 double idTrkEta = idTrk->
eta();
286 if (std::abs(idTrkEta)>2.5)
continue;
287 m_stat->Fill(
"eta<2.5",1);
293 int nMuons = goodMuons.size();
298 for (; mu1!=muEnd;++mu1){
299 const xAOD::TrackParticle *id1 = (*mu1)->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
301 for (; mu2!=muEnd; ++mu2){
304 double q1 = id1->
charge();
305 double q2 =
id2->charge();
306 if (q1*q2>0)
continue;
307 m_stat->Fill(
"OppChargePair",1);
317 if (invmass<m_minInvmass || invmass>
m_maxInvmass)
continue;
318 m_stat->Fill(
"InvMassOK",1);
322 double etaPos = idPos->
eta();
324 double etaNeg = idNeg->
eta();
327 double phiPos = idPos->
phi();
329 double phiNeg = idNeg->
phi();
339 double phiDiff = std::abs(phiPos - phiNeg);
346 std::string region =
"";
347 if ((std::abs(etaPos)<1.05 || std::abs(etaPos)==1.05) && (std::abs(etaNeg)<1.05 || std::abs(etaNeg)==1.05)) region=
"BB";
348 else if ((etaPos>1.05 && etaPos<2.5) && (etaNeg>1.05 && etaNeg<2.5)) region=
"EAEA";
349 else if ((etaPos<-1.05 && etaPos>-2.5) && (etaNeg<-1.05 && etaNeg>-2.5)) region=
"ECEC";
353 bool fillReg =
false;
357 if (!fillAll && !fillReg)
continue;
361 if (fillAll)
m_invmass[
"All"]->Fill(invmass);
362 if (fillReg)
m_invmass[region]->Fill(invmass);
366 std::map<std::string, TH2F*>* allVars =
nullptr;
373 for (
const std::pair<const std::string, TH2F*>&
p : *allVars) {
374 if (
p.first!=
"etaAll" &&
p.first!=
"phiAll" &&
p.first!=
"ptAll"){
377 }
else if (
p.first==
"etaAll"){
386 }
else if (
p.first==
"phiAll"){
395 }
else if (
p.first==
"ptAll"){
410 if (varD!=
"etaAll" && varD!=
"phiAll" && varD!=
"ptAll"){
413 }
else if (varD==
"etaAll"){
415 m_xDistr[
"All"][
"etaAll"]->Fill(etaPos);
416 m_xDistr[
"All"][
"etaAll"]->Fill(etaNeg);
419 m_xDistr[region][
"etaAll"]->Fill(etaPos);
420 m_xDistr[region][
"etaAll"]->Fill(etaNeg);
422 }
else if (varD==
"phiAll"){
424 m_xDistr[
"All"][
"phiAll"]->Fill(phiPos);
425 m_xDistr[
"All"][
"phiAll"]->Fill(phiNeg);
428 m_xDistr[region][
"phiAll"]->Fill(phiPos);
429 m_xDistr[region][
"phiAll"]->Fill(phiNeg);
431 }
else if (varD==
"ptAll"){
433 m_xDistr[
"All"][
"ptAll"]->Fill(ptPos);
434 m_xDistr[
"All"][
"ptAll"]->Fill(ptNeg);
437 m_xDistr[region][
"ptAll"]->Fill(ptPos);
438 m_xDistr[region][
"ptAll"]->Fill(ptNeg);
447 return StatusCode::SUCCESS;
456 for (
const std::string& reg :
m_regions) {
457 for (
const std::pair<const std::string, TH2F*>&
p :
m_2DinvmassVSx[reg]) {
459 std::vector<TH1F*> hout;
477 return StatusCode::SUCCESS;
483 TString
hname = hin->GetName();
485 TCanvas* ctemp =
new TCanvas(
"ctemp",
"ctemp",500,500);
487 hin->SetMarkerSize(1.2);
490 int nbins=hin->GetNbinsX();
492 std::ostringstream o; o<<
i;
493 TString projName =
hname + o.str();
494 TH1D* htemp = (TH1D*) (hin->ProjectionY(projName,
i+1,
i+1)->Clone());
495 htemp->SetTitle(projName);
497 if (htemp->GetEntries()>50){
498 double mean = 999., meanErr = 999.,
sigma = 999., sigmaErr = 999.,
chi2=0;
500 mean = htemp->GetMean();
501 sigma= htemp->GetRMS();
503 fn->SetParameters(
float(htemp->GetEntries())/10.,
mean,
sigma);
504 htemp->Fit(
"fn",
"RMLQN");
505 mean =
fn->GetParameter(1);
508 fn->SetParameters(
float(htemp->GetEntries())/10.,
mean,
sigma);
511 htemp->Fit(
"fn",
"RML");
512 ctemp->Print(psName);
513 }
else htemp->Fit(
"fn",
"RMLQN");
514 double frange = 2.4*
sigma;
515 double hrange = htemp->GetXaxis()->GetXmax()-htemp->GetXaxis()->GetXmin();
516 double ndf = frange/hrange*(htemp->GetNbinsX()) - 3;
519 mean =
fn->GetParameter(1);
520 meanErr =
fn->GetParError(1);
522 sigmaErr =
fn->GetParError(2);
527 RooRealVar
m(
"mass",
"dimuon invariant mass", 91.2, 71., 111.,
"GeV");
528 RooDataHist *
data =
nullptr;
529 data =
new RooDataHist(
"data",
"data",
m, htemp);
530 RooRealVar bwm0(
"bw_#mu",
"bw_#mu", 91.2, 85.2, 97.2) ;
531 RooRealVar bwsg(
"bw_#sigma",
"bw_#sigma", 2.4952) ;
532 RooBreitWigner bw(
"bw",
"bw",
m, bwm0, bwsg);
534 RooRealVar cbm0(
"cb_#mu",
"cb_#mu", 0 ) ;
535 RooRealVar cbsg(
"cb_#sigma",
"cb_#sigma", 3., 1., 10.) ;
536 RooRealVar cbal(
"cb_#alpha",
"cb_#alpha", 2.0) ;
537 RooRealVar cbn(
"cb_n",
"cb_n", 1., 0.05, 3.) ;
538 RooCBShape cb(
"cb",
"cb",
m, cbm0, cbsg, cbal, cbn);
541 RooFFTConvPdf bxc(
"bxc",
"BW (X) CB",
m, bw, cb) ;
542 bxc.fitTo(*
data, RooFit::PrintLevel(-1), RooFit::PrintEvalErrors(-1));
543 RooPlot* frame =
m.frame();
544 data->plotOn(frame, RooFit::MarkerSize(0.9));
546 bxc.plotOn (frame, RooFit::LineColor(kBlue));
549 ctemp->Print(psName);
551 mean = bwm0.getVal();
552 meanErr = bwm0.getError();
553 sigma = cbsg.getVal();
554 sigmaErr = cbsg.getError();
555 chi2 = frame->chiSquare();
561 hout.at(0)->SetBinContent(
i+1,
mean);
562 hout.at(0)->SetBinError(
i+1,meanErr);
563 hout.at(1)->SetBinContent(
i+1,
sigma);
564 hout.at(1)->SetBinError(
i+1,sigmaErr);
566 hout.at(0)->SetBinContent(
i+1,
mean);
567 hout.at(0)->SetBinError(
i+1,meanErr);
569 hout.at(0)->SetBinContent(
i+1,
sigma);
570 hout.at(0)->SetBinError(
i+1,sigmaErr);
578 if (hout.size()==2) hout.at(1)->Sumw2();
587 if (
sc.isFailure() ) {
606 if (nBLhits>0 || !(eBLhits)) countPass+=1;
607 if ((nhitsPIX+nPIXDS)>1) countPass+=1;
608 if ((nhitsSCT+nSCTDS)>5) countPass+=1;
609 if ((nPIXH+nSCTH)<3) countPass+=1;
612 int n = nTRTout + nTRThits;
613 if (std::abs(idTrk->
eta())<1.9){
614 if (
n>5 && nTRTout<(0.9*
n)) countPass+=1;
617 if (nTRTout<(0.9*
n)) countPass+=1;
622 ATH_MSG_WARNING(
"Trying to check trackquality but no xAOD::TrackParticle available!");
629 TLorentzVector particle1,particle2,
v;
632 v=particle1+particle2;
639 double px = id1->
p4().Px()+
id2->p4().Px();
640 double py = id1->
p4().Py()+
id2->p4().Py();
647 double px=id1->
p4().Px()+
id2->p4().Px();
648 double py = id1->
p4().Py()+
id2->p4().Py();
649 double pz = id1->
p4().Pz()+
id2->p4().Pz();
656 double px=id1->
p4().Px()+
id2->p4().Px();
657 double py = id1->
p4().Py()+
id2->p4().Py();
665 double qoverpt1=id1->
charge()/id1->
pt();
666 double qoverpt2=
id2->charge()/
id2->pt();
668 asym=std::abs(qoverpt1)-std::abs(qoverpt2);
virtual double pt() const override final
The transverse momentum ( ) of the particle.
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
char data[hepevt_bytes_allocation_ATLAS]
std::map< std::string, std::pair< double, double > > m_varRanges
Const iterator class for DataVector/DataList.
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Scalar phi() const
phi method
double getEta(const xAOD::TrackParticle *id1, const xAOD::TrackParticle *id2) const
std::string find(const std::string &s)
return a remapped string
std::vector< std::string > m_varsVSmean
std::vector< std::string > m_varsVSwidth
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
iterator end() noexcept
Return an iterator pointing past the end of the collection.
float charge() const
Returns the charge.
Scalar eta() const
pseudorapidity method
DataVector adapter that acts like it holds const pointers.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
constexpr double muonMassInMeV
the mass of the muon (in MeV)
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
double getPt(const xAOD::TrackParticle *id1, const xAOD::TrackParticle *id2) const
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
@ numberOfTRTHits
number of TRT hits [unit8_t].
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
std::map< std::string, std::map< std::string, TH1F * > > m_xDistr
static Environment_t environment()
Returns the running environment of the monitoring application to help ManagedMonitorToolBase objects ...
std::map< std::string, TH1F * > m_invmass
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
static DataType_t dataType()
Returns the data type that the monitoring application is running over to help ManagedMonitorToolBase ...
std::map< std::string, std::map< std::string, TH2F * > > m_2DinvmassVSx
std::map< std::string, std::map< std::string, TH1F * > > m_invmassVSx
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
double chi2(TH1 *h0, TH1 *h1)
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
@ numberOfSCTHoles
number of SCT holes [unit8_t].
SG::ReadHandleKey< xAOD::MuonContainer > m_muonCollection
std::map< std::string, std::map< std::string, TH1F * > > m_widthVSx
std::string m_triggerChainName
value_type push_back(value_type pElem)
Add an element to the end of the collection.
double getPhi(const xAOD::TrackParticle *id1, const xAOD::TrackParticle *id2) const
std::map< std::string, double > m_varValues
double getCrtDiff(const xAOD::TrackParticle *id1, const xAOD::TrackParticle *id2) const
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
@ numberOfTRTOutliers
number of TRT outliers [unit8_t].
bool trackQuality(const xAOD::TrackParticle *idTrk)
std::vector< std::string > m_regions
virtual StatusCode initialize()
void iterativeGausFit(TH2F *hin, const std::vector< TH1F * > &hout, int mode)
DiMuMon(const std::string &type, const std::string &name, const IInterface *parent)
#define ATH_MSG_WARNING(x)
@ numberOfSCTDeadSensors
number of dead SCT sensors crossed [unit8_t].
DataVector adapter that acts like it holds const pointers.
void RegisterHisto(MonGroup &mon, T *histo)
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelDeadSensors
number of dead pixel sensors crossed [unit8_t].
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
std::vector< std::string > m_varsDistr
Class describing a TrackParticle.
Define macros for attributes used to control the static checker.
constexpr int pow(int base, int exp) noexcept
iterator begin() noexcept
Return an iterator pointing at the beginning of the collection.
double getInvmass(const xAOD::TrackParticle *track1, const xAOD::TrackParticle *track2, double Mass) const
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
std::map< std::string, std::string > m_varLabels