//_ AliFemtoManager* ConfigFemtoAnalysis(int runcentrality0, int runcentrality1, int runcentrality2, int runcentrality3, int runcentrality4,int runcentrality5, int runcentrality6, int runcentrality7, int runcentrality8, int runcentrality9, int runSHCorrFctn, int runNonIdCorrFctn, int paircutantigammaon, int fieldsign, double distance, double fraction1, double fraction2, int runDPhiStarKStarMergedFraction) { double PionMass = 0.13956995; double KaonMass = 0.493677; double ProtonMass = 0.938272013; const int numOfMultBins = 10; const int numOfChTypes = 4; const int numOfkTbins = 1; int runmults[numOfMultBins] = {runcentrality0, runcentrality1, runcentrality2, runcentrality3, runcentrality4, runcentrality5, runcentrality6, runcentrality7, runcentrality8, runcentrality9}; int multbins[numOfMultBins + 1] = {0.001, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900}; int runch[numOfChTypes] = {1, 1, 1, 1}; const char *chrgs[numOfChTypes] = { "PIpKp", "PImKm", "PIpKm","PImKp"}; int runktdep = 1; double ktrng[numOfkTbins + 1] = {fraction1, fraction2}; int runqinv = 1; int run3d = 0; // Do 3D cartesian analysis? int runshlcms = 0;// 0:PRF(PAP), 1:LCMS(PP,APAP) int runtype = 2; // Types 0 - global, 1 - ITS only, 2 - TPC Inner int isrealdata = 1; int gammacut = 1; double shqmax = 0.5; //if (runshlcms) shqmax = 2.0; //else shqmax = 0.9; int nbinssh = 100; AliFemtoEventReaderAODChain *Reader = new AliFemtoEventReaderAODChain(); Reader->SetFilterBit(7); Reader->SetCentralityPreSelection(0.001, 950); //AliFemtoEventReaderESDChainKine* Reader=new AliFemtoEventReaderESDChainKine(); //Reader->SetConstrained(true); // Reader->SetUseTPCOnly(false); //AliFemtoEventReaderESDChain *Reader = new AliFemtoEventReaderESDChain(); //Reader->SetUseMultiplicity(AliFemtoEventReaderESDChain::kV0Centrality); //Reader->SetReadTrackType(AliFemtoEventReaderESDChain::kGlobal); AliFemtoManager* Manager=new AliFemtoManager(); Manager->SetEventReader(Reader); const int size = numOfMultBins * numOfChTypes; AliFemtoVertexMultAnalysis *anetaphitpc[size]; AliFemtoBasicEventCut *mecetaphitpc[size]; AliFemtoCutMonitorEventMult *cutPassEvMetaphitpc[size]; AliFemtoCutMonitorEventMult *cutFailEvMetaphitpc[size]; AliFemtoCutMonitorEventVertex *cutPassEvVetaphitpc[size]; AliFemtoCutMonitorEventVertex *cutFailEvVetaphitpc[size]; AliFemtoCutMonitorCollections *cutPassColletaphitpc[size]; AliFemtoCutMonitorCollections *cutFailColletaphitpc[size]; AliFemtoESDTrackCut *dtc1etaphitpc[size]; //AliFemtoESDTrackCut *dtc2etaphitpc[size]; AliFemtoKKTrackCut *dtc2etaphitpc[size]; AliFemtoCutMonitorParticleYPt *cutPass1YPtetaphitpc[size]; AliFemtoCutMonitorParticleYPt *cutFail1YPtetaphitpc[size]; AliFemtoCutMonitorParticlePID *cutPass1PIDetaphitpc[size]; AliFemtoCutMonitorParticlePID *cutFail1PIDetaphitpc[size]; AliFemtoCutMonitorParticleYPt *cutPass2YPtetaphitpc[size]; AliFemtoCutMonitorParticleYPt *cutFail2YPtetaphitpc[size]; AliFemtoCutMonitorParticlePID *cutPass2PIDetaphitpc[size]; AliFemtoCutMonitorParticlePID *cutFail2PIDetaphitpc[size]; AliFemtoPairCutAntiGamma *sqpcetaphitpc[size]; //AliFemtoShareQualityTPCEntranceSepPairCut *sqpcetaphitpc[20]; //AliFemtoPairCutRadialDistance *sqpcetaphitpc[size]; //AliFemtoPairCutRadialDistanceAsymmetric *sqpcetaphitpc[size]; AliFemtoPairCutMergedFraction *sqpcetaphitpcmf[size]; AliFemtoPairCutRadialDistanceLM *sqpcetaphitpcRD[size]; AliFemtoCorrFctnDirectYlm *cylmetaphitpc[size]; AliFemtoCorrFctnDEtaDPhi *cdedpetaphi[size]; AliFemtoChi2CorrFctn *cchiqinvetaphitpc[size]; AliFemtoCorrFctnDPhiStarKStarMergedFraction *dphistarkstarmftpc[size]; //AliFemtoKTPairCut *ktpcuts[size*numOfkTbins]; AliFemtoPairCutMergedFraction *ktpcuts[size*numOfkTbins]; AliFemtoCorrFctnDirectYlm *cylmkttpc[size*numOfkTbins]; AliFemtoQinvCorrFctn *cqinvkttpc[size*numOfkTbins]; AliFemtoCorrFctn3DLCMSSym *cq3dlcmskttpc[size*numOfkTbins]; AliFemtoCorrFctn3DSpherical *cq3dspherical[size*numOfkTbins]; AliFemtoCorrFctnTPCNcls *cqinvnclstpc[size]; AliFemtoChi2CorrFctn *cqinvchi2tpc[size]; AliFemtoModelGausLCMSFreezeOutGenerator *gausLCMSFreezeOutGenerator[size]; AliFemtoModelWeightGeneratorBasic *weightGeneratorLednicky[size]; AliFemtoModelManager *tModelManager[size]; AliFemtoCorrFctnNonIdDR *cnonidtpc[size*numOfkTbins]; AliFemtoCorrFctnDPhiStarDEta *cdphistardeta08[size*numOfkTbins]; AliFemtoCorrFctnDPhiStarDEta *cdphistardeta12[size*numOfkTbins]; AliFemtoCorrFctnDPhiStarDEta *cdphistardeta16[size*numOfkTbins]; AliFemtoCorrFctnDPhiStarDEta *cdphistardeta20[size*numOfkTbins]; // *** Begin pion-kaon analysis *** int aniter = 0; for (int imult = 0; imult < numOfMultBins; imult++) { if (runmults[imult]) { for (int ichg = 0; ichg < numOfChTypes; ichg++) { if (runch[ichg]) { //Iterator: aniter = ichg * numOfMultBins + imult; //Mix events with respect to the z position of the primary vertex and event total multipliticy: anetaphitpc[aniter] = new AliFemtoVertexMultAnalysis(10, -10.0, 10.0, 4, multbins[imult], multbins[imult+1]); anetaphitpc[aniter]->SetNumEventsToMix(5); anetaphitpc[aniter]->SetMinSizePartCollection(1); //Select basic cuts: mecetaphitpc[aniter] = new AliFemtoBasicEventCut(); mecetaphitpc[aniter]->SetEventMult(0.001,100000); mecetaphitpc[aniter]->SetVertZPos(-10,10); //Study the multiplicity distribution: cutPassEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutPass%stpcM%i", chrgs[ichg], imult),500); cutFailEvMetaphitpc[aniter] = new AliFemtoCutMonitorEventMult(Form("cutFail%stpcM%i", chrgs[ichg], imult),500); mecetaphitpc[aniter]->AddCutMonitor(cutPassEvMetaphitpc[aniter], cutFailEvMetaphitpc[aniter]); //Study the distribution and error of the primary vertex: cutPassEvVetaphitpc[aniter] = new AliFemtoCutMonitorEventVertex(Form("cutPass%stpcM%i", chrgs[ichg], imult)); cutFailEvVetaphitpc[aniter] = new AliFemtoCutMonitorEventVertex(Form("cutFail%stpcM%i", chrgs[ichg], imult)); mecetaphitpc[aniter]->AddCutMonitor(cutPassEvVetaphitpc[aniter], cutFailEvVetaphitpc[aniter]); //Study the multiplicity distribution: cutPassColletaphitpc[aniter] = new AliFemtoCutMonitorCollections(Form("cutPass%stpcM%i", chrgs[ichg], imult)); cutFailColletaphitpc[aniter] = new AliFemtoCutMonitorCollections(Form("cutFail%stpcM%i", chrgs[ichg], imult)); mecetaphitpc[aniter]->AddCutMonitor(cutPassColletaphitpc[aniter], cutFailColletaphitpc[aniter]); //Basic track cut for pions: dtc1etaphitpc[aniter] = new AliFemtoESDTrackCut(); dtc1etaphitpc[aniter]->SetNsigmaTPCTOF(true); dtc1etaphitpc[aniter]->SetNsigma(3.0); //Basic track cut for kaons: dtc2etaphitpc[aniter] = new AliFemtoKKTrackCut(); dtc2etaphitpc[aniter]->SetNsigmaTPCle250(2.0); dtc2etaphitpc[aniter]->SetNsigmaTPC250_400(2.0); dtc2etaphitpc[aniter]->SetNsigmaTPC400_450(2.0); dtc2etaphitpc[aniter]->SetNsigmaTPC450_500(2.0); dtc2etaphitpc[aniter]->SetNsigmaTPCge500(3.0); dtc2etaphitpc[aniter]->SetNsigmaTOF500_800(2.0); dtc2etaphitpc[aniter]->SetNsigmaTOF800_1000(1.5); dtc2etaphitpc[aniter]->SetNsigmaTOFge1000(1.0); //Set charge of particles: if (ichg == 0) { dtc1etaphitpc[aniter]->SetCharge(1.0); dtc2etaphitpc[aniter]->SetCharge(1.0); } else if (ichg == 1) { dtc1etaphitpc[aniter]->SetCharge(-1.0); dtc2etaphitpc[aniter]->SetCharge(-1.0); } else if (ichg == 2) { dtc1etaphitpc[aniter]->SetCharge(1.0); dtc2etaphitpc[aniter]->SetCharge(-1.0); } else if (ichg == 3) { dtc1etaphitpc[aniter]->SetCharge(-1.0); dtc2etaphitpc[aniter]->SetCharge(1.0); } //Set particle 1: dtc1etaphitpc[aniter]->SetPt(0.14,1.5); dtc1etaphitpc[aniter]->SetEta(-0.8,0.8); dtc1etaphitpc[aniter]->SetMass(PionMass); dtc1etaphitpc[aniter]->SetMostProbablePion(); //Set particle 2: dtc2etaphitpc[aniter]->SetPt(0.14,1.5); dtc2etaphitpc[aniter]->SetEta(-0.8,0.8); dtc2etaphitpc[aniter]->SetMass(KaonMass); dtc2etaphitpc[aniter]->SetMostProbableKaon(); // Track quality cuts /*if (runtype == 0) { dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit); // dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit); // dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit); dtc1etaphitpc[aniter]->SetminTPCncls(80); dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE); dtc1etaphitpc[aniter]->SetLabel(kFALSE); // dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0); dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0); dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2); // dtc1etaphitpc[aniter]->SetMaxImpactXYPtDep(0.0182, 0.0350, -1.01); dtc1etaphitpc[aniter]->SetMaxImpactZ(0.15); // dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0); } else if (runtype == 1) { // dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit|AliESDtrack::kITSrefit); // dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCrefit); // dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit|AliESDtrack::kITSpureSA); // dtc1etaphitpc[aniter]->SetminTPCncls(70); dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kITSrefit); dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE); dtc1etaphitpc[aniter]->SetLabel(kFALSE); // dtc1etaphitpc[aniter]->SetMaxITSChiNdof(6.0); // dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(6.0); dtc1etaphitpc[aniter]->SetMaxImpactXY(0.2); dtc1etaphitpc[aniter]->SetMaxImpactZ(0.25); // dtc1etaphitpc[aniter]->SetMaxSigmaToVertex(6.0); } else if (runtype == 2) { dtc1etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin); dtc1etaphitpc[aniter]->SetminTPCncls(80); dtc1etaphitpc[aniter]->SetRemoveKinks(kTRUE); dtc1etaphitpc[aniter]->SetLabel(kFALSE); dtc1etaphitpc[aniter]->SetMaxTPCChiNdof(4.0); dtc1etaphitpc[aniter]->SetMaxImpactXY(2.4); dtc1etaphitpc[aniter]->SetMaxImpactZ(3.0); dtc2etaphitpc[aniter]->SetStatus(AliESDtrack::kTPCin); dtc2etaphitpc[aniter]->SetminTPCncls(80); dtc2etaphitpc[aniter]->SetRemoveKinks(kTRUE); dtc2etaphitpc[aniter]->SetLabel(kFALSE); dtc2etaphitpc[aniter]->SetMaxTPCChiNdof(4.0); dtc2etaphitpc[aniter]->SetMaxImpactXY(2.4); dtc2etaphitpc[aniter]->SetMaxImpactZ(3.0); }*/ //============PION============ //The cut monitor for particles to study the difference between reconstructed and true momentum: cutPass1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass1%stpcM%i", chrgs[ichg], imult),PionMass); cutFail1YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail1%stpcM%i", chrgs[ichg], imult),PionMass); dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1YPtetaphitpc[aniter], cutFail1YPtetaphitpc[aniter]); //The cut monitor for particles to study various aspects of the PID determination: cutPass1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass1%stpcM%i", chrgs[ichg], imult),0);//0-pion,1-kaon,2-proton cutFail1PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail1%stpcM%i", chrgs[ichg], imult),0); dtc1etaphitpc[aniter]->AddCutMonitor(cutPass1PIDetaphitpc[aniter], cutFail1PIDetaphitpc[aniter]); //============KAON============ cutPass2YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutPass2%stpcM%i", chrgs[ichg], imult),KaonMass); cutFail2YPtetaphitpc[aniter] = new AliFemtoCutMonitorParticleYPt(Form("cutFail2%stpcM%i", chrgs[ichg], imult),KaonMass); dtc2etaphitpc[aniter]->AddCutMonitor(cutPass2YPtetaphitpc[aniter], cutFail2YPtetaphitpc[aniter]); cutPass2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutPass2%stpcM%i", chrgs[ichg], imult),1);//0-pion,1-kaon,2-proton cutFail2PIDetaphitpc[aniter] = new AliFemtoCutMonitorParticlePID(Form("cutFail2%stpcM%i", chrgs[ichg], imult),1); dtc2etaphitpc[aniter]->AddCutMonitor(cutPass2PIDetaphitpc[aniter], cutFail2PIDetaphitpc[aniter]); //A pair cut which checks for some pair qualities that attempt to identify slit/doubly reconstructed tracks and also selects pairs based on their separation at the entrance to the TPC //sqpcetaphitpc[aniter] = new AliFemtoPairCutRadialDistance(); //sqpcetaphitpcRD[aniter] = new AliFemtoPairCutRadialDistanceLM(); sqpcetaphitpc[aniter] = new AliFemtoPairCutAntiGamma(); if(paircutantigammaon == 1) sqpcetaphitpc[aniter]->SetDataType(AliFemtoPairCut::kAOD); else sqpcetaphitpc[aniter]->SetDataType(AliFemtoPairCut::kKine); if(gammacut == 1) { sqpcetaphitpc[aniter]->SetMaxEEMinv(0.002); sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.008); } if( runtype==0){ sqpcetaphitpc[aniter]->SetMaxEEMinv(0.0); sqpcetaphitpc[aniter]->SetMaxThetaDiff(0.0); sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(1.5); // sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); // sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(0.12, 0.03); //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02); } else if (runtype==1){ //sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(5.0); //sqpcetaphitpc[aniter]->SetPhiStarDistanceMinimum(0.03); //sqpcetaphitpc[aniter]->SetRadialDistanceMinimum(1.2, 0.03); //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02); } else if ( runtype==2 ){ sqpcetaphitpc[aniter]->SetShareQualityMax(1.0); sqpcetaphitpc[aniter]->SetShareFractionMax(0.05); sqpcetaphitpc[aniter]->SetRemoveSameLabel(kFALSE); sqpcetaphitpc[aniter]->SetTPCEntranceSepMinimum(0.0); // sqpcetaphitpc[aniter]->SetMinimumRadius(1.6); //sqpcetaphitpc[aniter]->SetEtaDifferenceMinimum(0.02); //sqpcetaphitpc[aniter]->SetPhiStarDifferenceMinimum(0.045); //sqpcetaphitpcRD[aniter]->SetMinimumRadius(1.6); //sqpcetaphitpcRD[aniter]->SetEtaDifferenceMinimum(0.02); //sqpcetaphitpcRD[aniter]->SetPhiStarDifferenceMinimum(0.045); } anetaphitpc[aniter]->SetEventCut(mecetaphitpc[aniter]); anetaphitpc[aniter]->SetFirstParticleCut(dtc1etaphitpc[aniter]); anetaphitpc[aniter]->SetSecondParticleCut(dtc2etaphitpc[aniter]); anetaphitpc[aniter]->SetPairCut(sqpcetaphitpc[aniter]); //Correlation functions //Spherical harmonics (without kT bins) if(runSHCorrFctn == 1) { cylmetaphitpc[aniter] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%i", chrgs[ichg], imult),3,nbinssh,0.0,shqmax,runshlcms); anetaphitpc[aniter]->AddCorrFctn(cylmetaphitpc[aniter]); } //Qinv (without kT bins) //cqinvkttpc[aniter] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%i", chrgs[ichg], imult),nbinssh,0.0, shqmax); //anetaphitpc[aniter]->AddCorrFctn(cqinvkttpc[aniter]); // NonId (without kT bins) // Correlation function for non-identical particles uses k* as a function variable. Stores the correlation // function separately for positive and negative signs of k* projections into out, side and long directions, // enabling the calculations of double ratios if(runNonIdCorrFctn == 1) { cnonidtpc[aniter] = new AliFemtoCorrFctnNonIdDR(Form("cnonid%stpcM%i", chrgs[ichg], imult), nbinssh, 0.0, shqmax); anetaphitpc[aniter]->AddCorrFctn(cnonidtpc[aniter]); } if(runDPhiStarKStarMergedFraction) { dphistarkstarmftpc[aniter] = new AliFemtoCorrFctnDPhiStarKStarMergedFraction(Form("cdphistarkstarmergedfraction%stpcM%iD%lfF%lf", chrgs[ichg], imult, distance, ktrng[0]), 0.8, 2.5, distance, ktrng[0], 0.01, 51, 0.0, 0.5, 127, -1.0, 1.0); anetaphitpc[aniter]->AddCorrFctn(dphistarkstarmftpc[aniter]); dphistarkstarmftpc[aniter] = new AliFemtoCorrFctnDPhiStarKStarMergedFraction(Form("cdphistarkstarmergedfraction%stpcM%iD%lfF%lf", chrgs[ichg], imult, distance, ktrng[1]), 0.8, 2.5, distance, ktrng[1], 0.01, 51, 0.0, 0.5, 127, -1.0, 1.0); anetaphitpc[aniter]->AddCorrFctn(dphistarkstarmftpc[aniter]); } // DPhiStarDEta (without bins) // Correlation function for two particle correlations which uses dPhi* and dEta as a function variables. cdphistardeta08[aniter] = new AliFemtoCorrFctnDPhiStarDEta(Form("cdphistardeta08%stpcM%i", chrgs[ichg], imult), 0.8, 51, -0.05, 0.05, 127, -1.0, 1.0); anetaphitpc[aniter]->AddCorrFctn(cdphistardeta08[aniter]); cdphistardeta12[aniter] = new AliFemtoCorrFctnDPhiStarDEta(Form("cdphistardeta12%stpcM%i", chrgs[ichg], imult), 1.2, 51, -0.05, 0.05, 127, -1.0, 1.0); anetaphitpc[aniter]->AddCorrFctn(cdphistardeta12[aniter]); cdphistardeta16[aniter] = new AliFemtoCorrFctnDPhiStarDEta(Form("cdphistardeta16%stpcM%i", chrgs[ichg], imult), 1.6, 51, -0.05, 0.05, 127, -1.0, 1.0); anetaphitpc[aniter]->AddCorrFctn(cdphistardeta16[aniter]); cdphistardeta20[aniter] = new AliFemtoCorrFctnDPhiStarDEta(Form("cdphistardeta20%stpcM%i", chrgs[ichg], imult), 2.0, 51, -0.05, 0.05, 127, -1.0, 1.0); anetaphitpc[aniter]->AddCorrFctn(cdphistardeta20[aniter]); if (runktdep) { int ktm; for (int ikt=0; ikt<numOfkTbins + 1; ikt++) { ktm = aniter*numOfkTbins + ikt; //ktpcuts[ktm] = new AliFemtoKTPairCut(ktrng[ikt], ktrng[ikt+1]); ktpcuts[ktm] = new AliFemtoPairCutMergedFraction(distance, ktrng[ikt], 0.01, 0.8, 2.5); cylmkttpc[ktm] = new AliFemtoCorrFctnDirectYlm(Form("cylm%stpcM%iD%lfF%lf", chrgs[ichg], imult, distance, ktrng[ikt]),3,nbinssh, 0.0,shqmax, runshlcms); cylmkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); anetaphitpc[aniter]->AddCorrFctn(cylmkttpc[ktm]); //cqinvkttpc[ktm] = new AliFemtoQinvCorrFctn(Form("cqinv%stpcM%ikT%i", chrgs[ichg], imult, ikt),nbinssh,0.0, shqmax); //cqinvkttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); //anetaphitpc[aniter]->AddCorrFctn(cqinvkttpc[ktm]); //cnonidtpc[ktm] = new AliFemtoCorrFctnNonIdDR(Form("cnonid%stpcM%ikT%i", chrgs[ichg], imult, ikt), nbinssh, 0.0, shqmax); //cnonidtpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); //anetaphitpc[aniter]->AddCorrFctn(cnonidtpc[ktm]); if (run3d) { cq3dlcmskttpc[ktm] = new AliFemtoCorrFctn3DLCMSSym(Form("cq3d%stpcM%ikT%i", chrgs[ichg], imult, ikt),100,0.5); cq3dlcmskttpc[ktm]->SetPairSelectionCut(ktpcuts[ktm]); anetaphitpc[aniter]->AddCorrFctn(cq3dlcmskttpc[ktm]); /* cq3dspherical[ktm] = new AliFemtoCorrFctn3DSpherical(Form("cq3d%stpcM%ikT%i",chrgs[ichg], imult, ikt), nbinssh,0.0,shqmax,nbinssh,nbinssh); cq3dspherical[ktm]->SetPairSelectionCut(ktpcuts[ktm]); anetaphitpc[aniter]->AddCorrFctn(cq3dspherical[ktm]);*/ } } } Manager->AddAnalysis(anetaphitpc[aniter]); } } } } // *** End pion-kaon analysis return Manager; }
void mergeEff(int iCat_ = 0) { TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName()); dir.ReplaceAll("mergeEff.C",""); dir.ReplaceAll("/./","/"); ifstream in; const int nBinC = 13; // Cent(13), pT(7), y(6) const int nBinP = 7; // Cent(13), pT(7), y(6) const int nBinY = 6; // Cent(13), pT(7), y(6) double eff[100][100] = {0.0}; for(int idir = 1; idir < 101; idir++){ if(iCat_ == 0) in.open(Form("%s../Eff_00%d/eff_HighPt_Cents_default_Bit1_y_0.0_2.4_pT_6.5_30.0_pr.tex",dir.Data(),idir)); if(iCat_ == 1) in.open(Form("%s../Eff_00%d/eff_HighPt_Pts_default_Bit1_y_0.0_2.4_pT_6.5_30.0_pr.tex",dir.Data(),idir)); if(iCat_ == 2) in.open(Form("%s../Eff_00%d/eff_HighPt_Raps_default_Bit1_y_0.0_2.4_pT_6.5_30.0_pr.tex",dir.Data(),idir)); Float_t x[300]; Int_t nlines = 0; int nl = 0; while (1) { in >> x[0] ; eff[nl][idir-1] = x[0]; //cout<<"eff : "<<eff[nl][idir-1]<<endl; if (!in.good()) break; nlines++; nl++; } in.close(); } int nBins = 0; if(iCat_ == 0) nBins = nBinC; if(iCat_ == 1) nBins = nBinP; if(iCat_ == 2) nBins = nBinY; cout<<"nBins : "<<nBins<<endl; TH1F *hDis[13]; string eff_tot[100]; for(int in = 0; in < nBins; in++){ if(iCat_ == 2) hDis[in] = new TH1F(Form("hDis_%d",in),"",150,0.25,0.65); // cent if(iCat_ != 2) hDis[in] = new TH1F(Form("hDis_%d",in),"",120,0.25,0.85); // pT hDis[in]->Sumw2(); hDis[in]->SetMarkerStyle(20); hDis[in]->SetMarkerSize(1.2); puts(""); for(int id = 0; id < 100; id++){ printf("%0.4f ", eff[in][id]); hDis[in]->Fill(eff[in][id]); } } puts(""); const int nCentBins = 13; const int nRapBins = 6; const int nPtBins = 7; double ct_bound[nCentBins+1] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 40}; double pt_bound[nPtBins+1] = {6.5, 7.5, 8.5, 9.5, 11.0, 13.0, 16.0, 30.0}; double rap_bound[nRapBins+1] = {0.0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.4}; char OutTextFile[100]; if(iCat_ == 0) sprintf(OutTextFile,"pbpb_prompt_cent.tex"); if(iCat_ == 1) sprintf(OutTextFile,"pbpb_prompt_pt.tex"); if(iCat_ == 2) sprintf(OutTextFile,"pbpb_prompt_rap.tex"); ofstream dataFile(OutTextFile); TLatex *lt = new TLatex(); lt->SetNDC(); TCanvas *c1 = new TCanvas("c1","",1400,900); c1->Divide(5,3); TCanvas *c2 = new TCanvas("c2","",1400,600); c2->Divide(5,2); for(int ic = 1; ic < nBins+1; ic++){ if(iCat_==0) c1->cd(ic); if(iCat_!=0) c2->cd(ic); hDis[ic-1]->Draw("E"); cout<<"Mean : "<<hDis[ic-1]->GetMean()<<endl; cout<<"RMS : "<<hDis[ic-1]->GetRMS()<<endl; if(iCat_ == 0) dataFile<<"Cent : "<<ct_bound[ic-1]*2.5<<"-"<<ct_bound[ic]*2.5<<endl; if(iCat_ == 1) dataFile<<"pT : "<<pt_bound[ic-1]<<"-"<<pt_bound[ic]<<endl; if(iCat_ == 2) dataFile<<"rap : "<<rap_bound[ic-1]<<"-"<<rap_bound[ic]<<endl; dataFile<<hDis[ic-1]->GetMean()<<" "<<hDis[ic-1]->GetRMS()<<endl; cout<<hDis[ic-1]->GetMean()<<" "<<hDis[ic-1]->GetRMS()<<endl; if(iCat_==0) lt->DrawLatex(0.15,0.95,"PbPb, p_{T} [6.5,30], y [0.0,2.4]"); if(iCat_==0) lt->DrawLatex(0.15,0.85,Form("Cent [%0.0f,%0.0f]",ct_bound[ic-1]*2.5,ct_bound[ic]*2.5)); if(iCat_==1) lt->DrawLatex(0.15,0.95,Form("PbPb, p_{T} [%0.1f,%0.1f], y [0.0,2.4]",pt_bound[ic-1],pt_bound[ic])); if(iCat_==1) lt->DrawLatex(0.15,0.85,"Cent 0-100"); if(iCat_==2) lt->DrawLatex(0.15,0.95,Form("PbPb, p_{T} [6.5,30], y [%0.1f,%0.1f]",rap_bound[ic-1],rap_bound[ic])); if(iCat_==2) lt->DrawLatex(0.15,0.85,"Cent 0-100"); } if(iCat_ == 0) c1->SaveAs("plot_pbpb_eff_STA_pr_dis_cent.png");c1->SaveAs("plot_pbpb_eff_STA_pr_dis_cent.pdf"); if(iCat_ == 1) c2->SaveAs("plot_pbpb_eff_STA_pr_dis_pt.png");c2->SaveAs("plot_pbpb_eff_STA_pr_dis_pt.pdf"); if(iCat_ == 2) c2->SaveAs("plot_pbpb_eff_STA_pr_dis_rap.png");c2->SaveAs("plot_pbpb_eff_STA_pr_dis_rap.pdf"); return; }
void HHbbbbBtagEffBase_76(int wMs,int wM, string st,string st2,string option=""){ //0=signal ,1=QCD ,2=data----------------------------------------------------------- int nameRoot=1; if(st2.find("QCD")!= std::string::npos)nameRoot=0; if(st2.find("data")!= std::string::npos)nameRoot=2; //option----------------------------------------------------------- int JESOption=0; if(option.find("JESUp")!= std::string::npos)JESOption=1; if(option.find("JESDown")!= std::string::npos)JESOption=2; if(option.find("BtagUp")!= std::string::npos)JESOption=3; if(option.find("BtagDown")!= std::string::npos)JESOption=4; if(option.find("tau21Up")!= std::string::npos)JESOption=5; if(option.find("tau21Down")!= std::string::npos)JESOption=6; cout<<"JESOption = "<<JESOption<<endl; //tuple tree and cutflow variables------------------------------------------------------------------------------------ TFile *f; TTree *tree; int nPass[20]={0},total=0,dataPassingcsc=0; double nPassB[6]={0}; //using for Btag Eff ----------------------------------------------------------------------------- string btagsystematicsType="central"; if(JESOption==3)btagsystematicsType="up"; else if(JESOption==4)btagsystematicsType="down"; BTagCalibration calib("CSVv2L", "../CSVv2_76.csv"); BTagCalibrationReader LF(&calib, // calibration instance BTagEntry::OP_LOOSE, // operating point "incl", // measurement type btagsystematicsType); // systematics type BTagCalibrationReader HF(&calib, BTagEntry::OP_LOOSE, "mujets",btagsystematicsType); TFile *f1; if(nameRoot==2)f1=TFile::Open("../btagEffSource/data.root"); else if (nameRoot!=2 && (JESOption==0||JESOption==3||JESOption==4||JESOption==5||JESOption==6))f1=TFile::Open(Form("../btagEffSource/%s.root",st2.data())); else if (nameRoot!=2 && JESOption==1)f1=TFile::Open(Form("../btagEffSource/%s_JESUp.root",st2.data())); else if (nameRoot!=2 && JESOption==2)f1=TFile::Open(Form("../btagEffSource/%s_JESDown.root",st2.data())); TH2D* th1[6]; string btaggingEff[6]={"effD_b","effN_b","effD_c","effN_c","effD_l","effN_l"}; for(int i=0;i<6;i++){ th1[i]=(TH2D*)f1->FindObjectAny(Form("%s",btaggingEff[i].data())); if(i==1||i==3||i==5)th1[i]->Divide(th1[i-1]); } //check for zero btagging SF---------------------------------------------------------------------------------------- TH2D* th3[6]; th3[0]=new TH2D("zeroSF_b","zeroSF_b",200,0,2000,60,-3,3); th3[1]=new TH2D("zeroSF_c","zeroSF_c",200,0,2000,60,-3,3); th3[2]=new TH2D("zeroSF_l","zeroSF_l",200,0,2000,60,-3,3); th3[3]=new TH2D("SF_vs_Pt_b","SF_vs_Pt_b",120,0,1200,40,0.8,1.2); th3[4]=new TH2D("SF_vs_Pt_c","SF_vs_Pt_c",120,0,1200,40,0.8,1.2); th3[5]=new TH2D("SF_vs_Pt_l","SF_vs_Pt_l",120,0,1200,40,0.8,1.2); for(int i=0;i<6;i++)th3[i]->Sumw2(); //check for high btagging SF---------------------------------------------------------------------------------------- TH1D* th4[14]; string SF_jet_sub[8]={"SF_jet0_sub0_pass","SF_jet0_sub1_pass","SF_jet1_sub0_pass","SF_jet1_sub1_pass","SF_jet0_sub0_fail","SF_jet0_sub1_fail","SF_jet1_sub0_fail","SF_jet1_sub1_fail"}; for(int i=0;i<8;i++)th4[i]=new TH1D(Form("%s",SF_jet_sub[i].data()),Form("%s",SF_jet_sub[i].data()),40,0.8,1.2); string weightName[6]={"weight","weight_0b","weight_1b","weight_2b","weight_2b_ll","weight_2b_onel"}; for(int i=0;i<6;i++)th4[i+8]=new TH1D(Form("%s",weightName[i].data()),Form("%s",weightName[i].data()),40,0,2); for(int i=0;i<14;i++)th4[i]->Sumw2(); //saving variables---------------------------------------------------------------------------------------- TH1D * th5[200],* th6[200]; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ th5[(i*2+j)*5+k]=new TH1D(Form("Pt_j%d_sj%d_%db",i,j,k),Form("Pt_j%d_sj%d_%db",i,j,k),200,0,2000); th5[(i*2+j)*5+k+20]=new TH1D(Form("Eta_j%d_sj%d_%db",i,j,k),Form("Eta_j%d_sj%d_%db",i,j,k),60,-3,3); th5[(i*2+j)*5+k+85]=new TH1D(Form("subCSV_j%d_sj%d_%db",i,j,k),Form("subCSV_j%d_sj%d_%db",i,j,k),20,0,1); } } for(int k=0;k<5;k++){ th5[i*5+k+40]=new TH1D(Form("deltaR_j%d_%db",i,k),Form("deltaR_j%d_%db",i,k),20,0,1); th5[i*5+k+50]=new TH1D(Form("Pt_j%d_%db",i,k),Form("Pt_j%d_%db",i,k),200,0,2000); th5[i*5+k+60]=new TH1D(Form("Eta_j%d_%db",i,k),Form("Eta_j%d_%db",i,k),60,-3,3); th5[i*5+k+70]=new TH1D(Form("prMassL2L3_j%d_%db",i,k),Form("prMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+105]=new TH1D(Form("tau21_j%d_%db",i,k),Form("tau21_j%d_%db",i,k),25,0,1); th5[i*5+k+120]=new TH1D(Form("PuppiSDmassL2L3_j%d_%db",i,k),Form("PuppiSDmassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+130]=new TH1D(Form("puppiTau21_j%d_%db",i,k),Form("puppiTau21_j%d_%db",i,k),25,0,1); th5[i*5+k+140]=new TH1D(Form("prMass_j%d_%db",i,k),Form("prMass_j%d_%db",i,k),15,90,150); th5[i*5+k+150]=new TH1D(Form("PuppiSDmass_j%d_%db",i,k),Form("PuppiSDmass_j%d_%db",i,k),15,90,150); } } for(int k=0;k<5;k++){ th5[k+80]=new TH1D(Form("totalMass_%db",k),Form("totalMass_%db",k),200,1000,5000); th5[k+115]=new TH1D(Form("deltaEta_%db",k),Form("deltaEta_%db",k),40,0,2); th5[k+160]=new TH1D(Form("logPt_%db",k),Form("logPt_%db",k),70,0,7); } for(int i=0;i<165;i++){ th6[i]=(TH1D* )th5[i]->Clone(Form("%ss",th5[i]->GetTitle())); th5[i]->Sumw2(); th6[i]->Sumw2(); } //pileup uncertainty---------------------------------------------------------------------------------------- TH1D* th7[14]; th7[0]=new TH1D("totalMass","totalMass",200,1000,5000); th7[1]=new TH1D("totalMass_pileup_up","totalMass_pileup_up",200,1000,5000); th7[2]=new TH1D("totalMass_pileup_down","totalMass_pileup_down",200,1000,5000); th7[3]=new TH1D("pileupEff","pileupEff",15,0.5,15.5); double totalPileup[3]={0},passPileup[3]={0}; standalone_LumiReWeighting LumiWeights_central(0),LumiWeights_up(1),LumiWeights_down(-1); //PDF uncertainty th7[4]=new TH1D("PDFEff","PDFEff",101,0.5,101.5); double passPDF[101]={0},totalPDF[101]={0}; //QCD uncertainty for(int i=5;i<14;i++)th7[i]=new TH1D(Form("uns_QCD_%d",i-5),Form("uns_QCD_%d",i-5),200,1000,5000); //NCUtuple loop---------------------------------------------------------------------------------------- for (int w=wMs;w<wM;w++){ if(w%20==0)cout<<w<<endl; //Get ntuple---------------------------------------------------------------------------------------- if (nameRoot!=1)f = TFile::Open(Form("%s%d.root",st.data(),w)); else f = TFile::Open(st.data()); if (!f || !f->IsOpen())continue; TDirectory * dir; if (nameRoot!=1)dir = (TDirectory*)f->Get(Form("%s%d.root:/tree",st.data(),w)); else dir = (TDirectory*)f->Get(Form("%s:/tree",st.data())); dir->GetObject("treeMaker",tree); TreeReader data(tree); total+=data.GetEntriesFast(); for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){//event loop---------------------------------------------------------------------------------------- data.GetEntry(jEntry); Int_t nVtx = data.GetInt("nVtx"); Float_t ntrue= data.GetFloat("pu_nTrueInt"); //Float_t* pdfscaleSysWeights= data.GetPtrFloat("pdfscaleSysWeights"); double PU_weight[3]={1,1,1}; if(nameRoot!=2){ if(ntrue<51){ PU_weight[0] = LumiWeights_central.weight(ntrue); PU_weight[1]= LumiWeights_up.weight(ntrue); PU_weight[2] = LumiWeights_down.weight(ntrue); } else { PU_weight[0] = LumiWeights_central.weight(50); PU_weight[1] = LumiWeights_up.weight(50); PU_weight[2]= LumiWeights_down.weight(50); } } for(int i=0;i<3;i++)totalPileup[i]+=PU_weight[i]; for(int i=0;i<101;i++)totalPDF[i]+=PU_weight[0]; //0. has a good vertex if(nVtx<1)continue;nPass[0]++; //1.trigger std::string* trigName = data.GetPtrString("hlt_trigName"); vector<bool> &trigResult = *((vector<bool>*) data.GetPtr("hlt_trigResult")); bool passTrigger=false; for(int it=0; it< data.GetPtrStringSize(); it++){ std::string thisTrig= trigName[it]; bool results = trigResult[it]; if( ((thisTrig.find("HLT_PFHT800")!= std::string::npos|| thisTrig.find("HLT_PFHT650")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ900DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_PFHT650_WideJetMJJ950DEtaJJ1p5_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFJet360_TrimMass30_v")!= std::string::npos|| thisTrig.find("HLT_AK8PFHT700_TrimR0p1PT0p03Mass50_v")!= std::string::npos ) && results==1)){ passTrigger=true; break; } } if(!passTrigger && nameRoot==2)continue;nPass[1]++; int nFATJet = data.GetInt("FATnJet"); TClonesArray* fatjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); float* FATjetCorrUncUp = data.GetPtrFloat("FATjetCorrUncUp"); float* FATjetCorrUncDown = data.GetPtrFloat("FATjetCorrUncDown"); vector<bool> &FATjetPassIDTight = *((vector<bool>*) data.GetPtr("FATjetPassIDTight")); //2.nJets if(nFATJet<2)continue;nPass[2]++; TLorentzVector* thisJet ,* thatJet; if (JESOption==1){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1+FATjetCorrUncUp[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1+FATjetCorrUncUp[1] ); thisJet= &test0; thatJet= &test1; } else if (JESOption==2){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1-FATjetCorrUncDown[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1-FATjetCorrUncDown[1] ); thisJet= &test0; thatJet= &test1; } else{ thisJet= (TLorentzVector*)fatjetP4->At(0); thatJet = (TLorentzVector*)fatjetP4->At(1); } //3. Pt if(thisJet->Pt()<300||thatJet->Pt()<300)continue; nPass[3]++; //4tightId----------------------------------------- if(FATjetPassIDTight[0]==0||FATjetPassIDTight[1]==0)continue; Float_t* FATjetCEmEF = data.GetPtrFloat("FATjetCEmEF"); Float_t* FATjetMuEF = data.GetPtrFloat("FATjetMuEF"); if(FATjetMuEF[0]>0.8||FATjetMuEF[1]>0.8)continue; if(FATjetCEmEF[0]>0.9||FATjetCEmEF[1]>0.9)continue; nPass[4]++; //5. Eta----------------------------------------- if(fabs(thisJet->Eta())>2.4||fabs(thatJet->Eta())>2.4)continue; nPass[5]++; //6. DEta----------------------------------------- float dEta = fabs(thisJet->Eta()-thatJet->Eta()); if(dEta>1.3)continue; nPass[6]++; //7. Mjj----------------------------------------- float mjj = (*thisJet+*thatJet).M(); if(mjj<1000)continue; nPass[7]++; //8. fatjetPRmassL2L3Corr----------------------------------------- Float_t* fatjetPRmassL2L3Corr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); Float_t* FATjetPuppiSDmassL2L3Corr = data.GetPtrFloat("FATjetPuppiSDmassL2L3Corr"); Float_t* FATjetPRmass = data.GetPtrFloat("FATjetPRmass"); Float_t* FATjetPuppiSDmass = data.GetPtrFloat("FATjetPuppiSDmass"); if(fatjetPRmassL2L3Corr[0]<105||fatjetPRmassL2L3Corr[0]>135)continue; if(fatjetPRmassL2L3Corr[1]<105||fatjetPRmassL2L3Corr[1]>135)continue; nPass[8]++; //9.----------------------------------------- Float_t* fatjetTau1 = data.GetPtrFloat("FATjetTau1"); Float_t* fatjetTau2 = data.GetPtrFloat("FATjetTau2"); Float_t* FATjetPuppiTau1 = data.GetPtrFloat("FATjetPuppiTau1"); Float_t* FATjetPuppiTau2 = data.GetPtrFloat("FATjetPuppiTau2"); double tau21[2]; tau21[0]=(fatjetTau2[0]/fatjetTau1[0]),tau21[1]=(fatjetTau2[1]/fatjetTau1[1]); double puppiTau21[2]; puppiTau21[0]=(FATjetPuppiTau2[0]/FATjetPuppiTau1[0]),puppiTau21[1]=(FATjetPuppiTau2[1]/FATjetPuppiTau1[1]); if(tau21[0]>0.75||tau21[1]>0.75)continue; if(tau21[0]>0.6 &&tau21[1]>0.6) continue; nPass[9]++; bool isHPHP=0; double tau21_SF=1.031*0.881; if(JESOption==5)tau21_SF=(1.031+0.126)*(0.881+0.49); if(JESOption==6)tau21_SF=(1.031-0.126)*(0.881-0.49); if(tau21[0]<0.6 && tau21[1]<0.6 ){ isHPHP=1; tau21_SF=1.031*1.031; if(JESOption==5)tau21_SF=(1.031+0.126)*(1.031+0.126); if(JESOption==6)tau21_SF=(1.031-0.126)*(1.031-0.126); } //8.btag vector<float> *subjetSDCSV = data.GetPtrVectorFloat("FATsubjetSDCSV"); vector<float> *subjetSDPx = data.GetPtrVectorFloat("FATsubjetSDPx", nFATJet); vector<float> *subjetSDPy = data.GetPtrVectorFloat("FATsubjetSDPy", nFATJet); vector<float> *subjetSDPz = data.GetPtrVectorFloat("FATsubjetSDPz", nFATJet); vector<float> *subjetSDE = data.GetPtrVectorFloat("FATsubjetSDE", nFATJet); vector<Int_t> *FATsubjetSDHadronFlavor = data.GetPtrVectorInt("FATsubjetSDHadronFlavor"); int nbtag=0,nbtag2=0; float MaxBJetPt = 670., MaxLJetPt = 1000.; double sf[2][2],eta[2],pt[2],dr[2],subjetPt[2][2],subjetEta[2][2],eff[2][2],btaggingscaleFactor=1; TLorentzVector* subjetP4[2][2]; for(int i=0;i<2;i++)for(int j=0;j<2;j++)sf[i][j]=1; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ subjetP4[i][j]=new TLorentzVector(0,0,0,0); subjetP4[i][j]->SetPxPyPzE(subjetSDPx[i][j],subjetSDPy[i][j],subjetSDPz[i][j],subjetSDE[i][j]); subjetPt[i][j]=subjetP4[i][j]->Pt(); subjetEta[i][j]=subjetP4[i][j]->Eta(); //get btagging eff------------------------------------------------------------ if(FATsubjetSDHadronFlavor[i][j]==5)eff[i][j]=th1[1]->GetBinContent(ceil(subjetPt[i][j]/10),ceil(subjetEta[i][j]/0.1)+30); else if(FATsubjetSDHadronFlavor[i][j]==4)eff[i][j]=th1[3]->GetBinContent(ceil(subjetPt[i][j]/10),ceil(subjetEta[i][j]/0.1)+30); else eff[i][j]=th1[5]->GetBinContent(ceil(subjetPt[i][j]/10),ceil(subjetEta[i][j]/0.1)+30); //check maxPt------------------------------------------------------------- if(FATsubjetSDHadronFlavor[i][j]!=0 && subjetPt[i][j]>MaxBJetPt )subjetPt[i][j]=MaxBJetPt-0.1; if(FATsubjetSDHadronFlavor[i][j]==0 && subjetPt[i][j]>MaxLJetPt )subjetPt[i][j]=MaxLJetPt-0.1; //Get SF from csv------------------------------------------------------------ if(FATsubjetSDHadronFlavor[i][j]==5){ sf[i][j]=HF.eval(BTagEntry::FLAV_B,subjetEta[i][j],subjetPt[i][j]); th3[3]->Fill(subjetPt[i][j],sf[i][j]); } else if(FATsubjetSDHadronFlavor[i][j]==4){ sf[i][j]=HF.eval(BTagEntry::FLAV_C,subjetEta[i][j],subjetPt[i][j]); th3[4]->Fill(subjetPt[i][j],sf[i][j]); } else { sf[i][j]=LF.eval(BTagEntry::FLAV_UDSG,subjetEta[i][j],subjetPt[i][j]); th3[5]->Fill(subjetPt[i][j],sf[i][j]); } //check zero ------------------------------------------------------------ if(sf[i][j]==0 && FATsubjetSDHadronFlavor[i][j]==5 ) th3[0]->Fill(subjetPt[i][j],subjetEta[i][j]); if(sf[i][j]==0 && FATsubjetSDHadronFlavor[i][j]==4 ) th3[1]->Fill(subjetPt[i][j],subjetEta[i][j]); if(sf[i][j]==0 && FATsubjetSDHadronFlavor[i][j]!=5 && FATsubjetSDHadronFlavor[i][j]!=4 ) th3[2]->Fill(subjetPt[i][j],subjetEta[i][j]); //conut nbtag--------------------------------------------------------- if(subjetSDCSV[i][j]>0.46)nbtag++; //get tot. btagging SF if(subjetSDCSV[i][j]>=0.46)btaggingscaleFactor*=sf[i][j]; else btaggingscaleFactor*=((1-eff[i][j]*sf[i][j])/(1-eff[i][j])); //##############check light jet SF########## if(subjetSDCSV[i][j]>0.46 &&FATsubjetSDHadronFlavor[i][j]==0)nbtag2++; if(subjetSDCSV[i][j]>0.46)th4[i*2+j]->Fill(sf[i][j]); else th4[i*2+j+4]->Fill(sf[i][j]); subjetPt[i][j]=subjetP4[i][j]->Pt(); } dr[i]=subjetP4[i][0]->DeltaR(*subjetP4[i][1]); } th4[8]->Fill(btaggingscaleFactor); if(nbtag2==2 && nbtag==2)th4[12]->Fill(btaggingscaleFactor); if(nbtag2==1 && nbtag==2)th4[13]->Fill(btaggingscaleFactor); //uncertainty ------------------------------------- double scaleFactor=btaggingscaleFactor*PU_weight[0]*tau21_SF; for(int i=0;i<3;i++){ passPileup[i]+=btaggingscaleFactor*PU_weight[i]*tau21_SF; th7[i]->Fill(mjj,btaggingscaleFactor*PU_weight[i]*tau21_SF); } for(int i=0;i<101;i++)passPDF[i]+=btaggingscaleFactor*PU_weight[0]*tau21_SF; for(int i=5;i<14;i++)th7[i]->Fill(mjj,btaggingscaleFactor*PU_weight[0]*tau21_SF); //-------------------------------------- pt[0]=thisJet->Pt(); pt[1]=thatJet->Pt(); eta[0]=thisJet->Eta(); eta[1]=thatJet->Eta(); for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ if(nbtag!=k)continue; th5[(i*2+j)*5+k]->Fill(subjetPt[i][j]); th5[(i*2+j)*5+k+20]->Fill(subjetEta[i][j]); th5[(i*2+j)*5+k+85]->Fill(subjetSDCSV[i][j]); th6[(i*2+j)*5+k]->Fill(subjetPt[i][j],scaleFactor); th6[(i*2+j)*5+k+20]->Fill(subjetEta[i][j],scaleFactor); th6[(i*2+j)*5+k]->Fill(subjetSDCSV[i][j],scaleFactor); } } for(int k=0;k<5;k++){ if(nbtag!=k)continue; th5[i*5+k+40]->Fill(dr[i]); th5[i*5+k+50]->Fill(pt[i]); th5[i*5+k+60]->Fill(eta[i]); th5[i*5+k+70]->Fill(fatjetPRmassL2L3Corr[i]); th5[i*5+k+105]->Fill(tau21[i]); th6[i*5+k+40]->Fill(dr[i],scaleFactor); th6[i*5+k+50]->Fill(pt[i],scaleFactor); th6[i*5+k+60]->Fill(eta[i],scaleFactor); th6[i*5+k+70]->Fill(fatjetPRmassL2L3Corr[i],scaleFactor); th6[i*5+k+105]->Fill(tau21[i],scaleFactor); th5[i*5+k+120]->Fill(FATjetPuppiSDmassL2L3Corr[i]); th6[i*5+k+120]->Fill(FATjetPuppiSDmassL2L3Corr[i],scaleFactor); th5[i*5+k+130]->Fill(puppiTau21[i]); th6[i*5+k+130]->Fill(puppiTau21[i],scaleFactor); th5[i*5+k+140]->Fill(FATjetPRmass[i]); th6[i*5+k+140]->Fill(FATjetPRmass[i],scaleFactor); th5[i*5+k+150]->Fill(FATjetPuppiSDmass[i]); th6[i*5+k+150]->Fill(FATjetPuppiSDmass[i],scaleFactor); } } for(int k=0;k<5;k++){ if(nbtag!=k)continue; th5[k+80]->Fill(mjj); th6[k+80]->Fill(mjj,scaleFactor); th5[k+115]->Fill(dEta); th6[k+115]->Fill(dEta,scaleFactor); th5[k+160]->Fill(log10(pt[0])); th6[k+160]->Fill(log10(pt[0]),scaleFactor); th5[k+160]->Fill(log10(pt[1])); th6[k+160]->Fill(log10(pt[1]),scaleFactor); nPassB[k]+=scaleFactor; nPass[k+10]++; if(k<3)th4[9+k]->Fill(btaggingscaleFactor); } if(nbtag==3){ if(isHPHP)nPassB[5]+=scaleFactor; if(isHPHP)nPass[15]++; } }//end event loop---------------------------------------------------------------------------------------- } //end ntuple loop---------------------------------------------------------------------------------------- cout<<"entries="<<total<<endl; for(int i=0;i<6;i++)cout<<"nPassB["<<i<<"]="<<nPassB[i]<<endl; for(int i=0;i<16;i++)cout<<"nPass["<<i<<"]="<<nPass[i]<<endl; for(int i=0;i<3;i++)th7[3]->SetBinContent(i+1,passPileup[i]/totalPileup[i]); for(int i=0;i<101;i++)th7[4]->SetBinContent(i+1,passPDF[i]/totalPDF[i]); TH1D * th2o=new TH1D("Nbtagjet","Nbtagjet",6,-0.5,5.5); for (int i=0;i<6;i++){ if(nameRoot==2 && i>2)continue; th2o->SetBinContent(i+1,nPass[i+10]); } TH1D * th2ob=new TH1D("NbtagjetB","NbtagjetB",6,-0.5,5.5); for (int i=0;i<6;i++){ if(nameRoot==2 && i>2)continue; th2ob->SetBinContent(i+1,nPassB[i]); } TH1D * cutflow=new TH1D("cutflow","cutflow",17,0.5,17.5); cutflow->SetBinContent(1,total); if(nameRoot==2)for(int ii=1;ii<14;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); else for(int ii=1;ii<17;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); TFile* outFile ; if(JESOption==0)outFile= new TFile(Form("../sf/%s.root",st2.data()),"recreate"); else if(JESOption==1)outFile= new TFile(Form("sf/%s_JESUp.root",st2.data()),"recreate"); else if(JESOption==2)outFile= new TFile(Form("sf/%s_JESDown.root",st2.data()),"recreate"); else if(JESOption==3)outFile= new TFile(Form("sf/%s_BtagUp.root",st2.data()),"recreate"); else if(JESOption==4)outFile= new TFile(Form("sf/%s_BtagDown.root",st2.data()),"recreate"); else if(JESOption==5)outFile= new TFile(Form("sf/%s_tau21Up.root",st2.data()),"recreate"); else if(JESOption==6)outFile= new TFile(Form("sf/%s_tau21Down.root",st2.data()),"recreate"); th2o->Write(); th2ob->Write(); cutflow->Write(); for(int i=0;i<6;i++)th3[i]->Write(); for(int i=0;i<14;i++)th4[i]->Write(); for(int i=0;i<165;i++){ th5[i]->Write(); th6[i]->Write(); } for(int i=0;i<14;i++)th7[i]->Write(); outFile->Close(); }
void SkimStep3(TString fname="ZnnH125", TString outputname = "") { // gROOT->LoadMacro("HelperFunctions.h" ); // make functions visible to TTreeFormula gROOT->SetBatch(1); TChain * chain = new TChain("tree"); TString dijet = ""; TString outdir = "/afs/cern.ch/work/d/degrutto/public/MiniAOD/ZnnHbb_v13/step3Skimmed/"; // TString outdir = ""; TString prefix = "skim_"; // TString prefix = ""; TString suffix = "tree*.root"; // TCut selection = baseline.c_str(); // Different baseline for dimuons // MET filters // selection += metfilter.c_str(); // JSON & trigger /* if (fname.Contains("Data")) { TCut trigger = mettrigger.c_str(); selection += trigger; //selection.Print(); } */ /* } else if (process == "Data_METBTag_R" || process == "Data_METBTag_P") { TCut trigger = metbtagtrigger.c_str(); selection += trigger; //selection.Print(); } else if (process == "Data_SingleMu_R" || process == "Data_SingleMu_P") { TCut trigger = singlemutrigger.c_str(); selection += trigger; //selection.Print(); } else if (process == "Data_SingleEl_R" || process == "Data_SingleEl_P") { TCut trigger = singleeltrigger.c_str(); selection += trigger; //selection.Print(); } */ chain->Add(fname); // Sum Count, CountWithPU, CountWithPUP, CountWithPUM TObjArray * files = chain->GetListOfFiles(); TIter next(files); TChainElement * chainElem = 0; TH1D * h1 = new TH1D("Count", ";Counts", 16, 0, 16); TH1F * htemp = 0; while ((chainElem = (TChainElement*) next())) { //#ifndef XROOTD // f2 = TFile::Open("dcache:" + TString(chainElem->GetTitle())); //#else std::cout << "chainElem->GetTitle() " << chainElem->GetTitle() << std::endl; /* h1->SetBinContent(4, h1->GetBinContent(4)+htemp->GetBinContent(1)); htemp = (TH1F*) f2->Get("CountWithMCProd"); h1->SetBinContent(5, h1->GetBinContent(5)+htemp->GetBinContent(1)); htemp = (TH1F*) f2->Get("CountWithPUMCProd"); h1->SetBinContent(6, h1->GetBinContent(6)+htemp->GetBinContent(1)); htemp = (TH1F*) f2->Get("countWithSignalQCDcorrections"); h1->SetBinContent(7, h1->GetBinContent(7)+htemp->GetBinContent(1)); */ std::clog << fname << ": skimmed from " << chainElem->GetTitle() << std::endl; } // LHE Count /* TH1D * h2 = new TH1D("LHECount", ";LHE Counts", 16, 0, 16); TString process_lhe = fname; if (process_lhe.BeginsWith("WJets")) process_lhe = "WJets"; else if (process_lhe.BeginsWith("ZJets")) process_lhe = "ZJets"; else process_lhe = ""; const std::vector<std::string>& lhecuts = GetLHECuts(process_lhe.Data()); for (unsigned int i=0; i < lhecuts.size(); i++) { TCut cut2 = lhecuts.at(i).c_str(); h2->SetBinContent(i+1, chain->GetEntries(cut2)); } */ // Make output directory if it doesn't exist if (gSystem->AccessPathName(outdir)) gSystem->mkdir(outdir); TString outname = outdir + prefix + Form("%s", outputname.Data()); std::cout << "outname is " << outname << std::endl; TFile* f1 = TFile::Open(outname, "RECREATE"); TTree* t1 = (TTree*) chain->CopyTree("met_pt>150 && HCSV_pt>150 && min( abs( deltaPhi(V_phi,Jet_phi[hJCidx[0]] )), abs(deltaPhi(V_phi,Jet_phi[hJCidx[1]])) )> 0.7 && tkMet_pt>25 && Jet_btagCSV[hJCidx[1]]>0.3"); // the selection is bypassed, loop instead on the events to be faster std::clog << fname << ": skimmed from " << chain->GetEntriesFast() << " to " << t1->GetEntriesFast() << " entries." << std::endl; // t1->Print(); t1->AutoSave(); t1->Write(); h1->Write(); // h2->Write(); f1->Close(); delete f1; return; }
int plotDYAcceptance(int analysisIs2D, const TString conf, DYTools::TRunMode_t runMode=DYTools::NORMAL_RUN, DYTools::TSystematicsStudy_t systMode=DYTools::NO_SYST, TString rndStudyStr="") { gBenchmark->Start("plotDYAcceptance"); { DYTools::printExecMode(runMode,systMode); const int debug_print=1; if (!DYTools::checkSystMode(systMode,debug_print,9, DYTools::NO_SYST, DYTools::FSR_5plus, DYTools::FSR_5minus, DYTools::FSR_RND_STUDY, DYTools::PU_RND_STUDY, DYTools::PILEUP_5plus, DYTools::PILEUP_5minus, DYTools::NO_REWEIGHT, DYTools::NO_REWEIGHT_FEWZ)) return retCodeError; } // // A note on systematics mode // - FSR_5plus, FSR_5minus should be taken care here // - PU_5plus, PU_5minus are taken care by the eventWeight, through // the PUReweight class if (!DYTools::setup(analysisIs2D)) { std::cout << "failed to initialize the analysis\n"; return retCodeError; } //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== InputFileMgr_t inpMgr; if (!inpMgr.Load(conf)) return retCodeError; // no energy correction for this evaluation inpMgr.clearEnergyScaleTag(); // Construct eventSelector, update mgr and plot directory TString extraTag=rndStudyStr; EventSelector_t evtSelector(inpMgr,runMode,systMode, extraTag,"",EventSelector::_selectDefault); evtSelector.setTriggerActsOnData(false); // Acceptance is generator-level quantity and should not // depend on the pile-up. The flag is disabled. // Correction on May 01, 2014: PU should be applied at all steps EventWeight_t evWeight; if (!evWeight.init(inpMgr.puReweightFlag(),inpMgr.fewzFlag(), systMode,rndStudyStr)) { std::cout << "failed to prepare evWeight\n"; return retCodeError; } std::cout << "evWeight: "; evWeight.PrintDetails(); int useSpecWeight=1; double specWeight=1.0; const double FSRmassDiff=1.0; // FSR_RND_STUDY sets own special weights if (systMode==DYTools::FSR_5plus) { specWeight=1.05; useSpecWeight=1; } else if (systMode==DYTools::FSR_5minus) { specWeight=0.95; useSpecWeight=1; } // Prepare output directory inpMgr.constDir(systMode,1); TString outFileName=inpMgr.correctionFullFileName("acceptance",systMode,0); std::cout << "generated outFileName=<" << outFileName << ">\n"; #ifdef calculate_PreFsrAcc std::cout << dashline; std::cout << "\t\tcalculate_PreFsrAcc is defined\n"; std::cout << dashline; #endif //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== std::cout << mainpart; // // Set up histograms // // containers to accumulate the events std::vector<TH2D*> hvPass, hvTotal; std::vector<TH2D*> hvFail; #ifdef calculate_PreFsrAcc std::vector<TH2D*> hvPassPreFsr, hvTotalPreFsr; #endif // debug containters std::vector<TH1D*> hMassv; std::vector<TH1D*> hMassBinsv; std::vector<TH1D*> hZpeakv; TH1D *hSelEvents=NULL; // the main result of the macro createBaseH2Vec(hvPass ,"hvPass_" ,inpMgr.mcSampleNames()); createBaseH2Vec(hvTotal,"hvTotal_",inpMgr.mcSampleNames()); createBaseH2Vec(hvFail,"hvFail_",inpMgr.mcSampleNames()); #ifdef calculate_PreFsrAcc createBaseH2Vec(hvPassPreFsr ,"hvPassPreFsr_" ,inpMgr.mcSampleNames()); createBaseH2Vec(hvTotalPreFsr,"hvTotalPreFsr_",inpMgr.mcSampleNames()); #endif // debug distributions: 1GeV bins createAnyH1Vec(hMassv,"hGenMass_",inpMgr.mcSampleNames(),1990,10.,2000.,"#it{M}_{ee} [GeV]","counts/1GeV"); // debug distributions for current mass bin createBaseH1Vec(hMassBinsv,"hGenMassBins_",inpMgr.mcSampleNames()); // debug: accumulate info about the selected events in the samples hSelEvents=createAnyTH1D("hSelEvents","hSelEvents",inpMgr.mcSampleCount(),0,inpMgr.mcSampleCount(),"sampleId","event count"); // collect number of events in the Z-peak createAnyH1Vec(hZpeakv,"hZpeak_",inpMgr.mcSampleNames(),60,60.,120.,"#it{M}_{ee} [GeV]","counts/1GeV"); // // Access samples and fill histograms // AccessOrigNtuples_t accessInfo; // // loop over samples // if (DYTools::processData(runMode)) { double extraWeightFactor=1.0; EventCounterExt_t ecTotal("total"); for (unsigned int isample=0; isample<inpMgr.mcSampleCount(); ++isample) { const CSample_t *mcSample=inpMgr.mcSampleInfo(isample); std::cout << "Processing " << mcSample->getLabel() << "..." << std::endl; std::cout << " of size " << mcSample->size() << "\n"; if (mcSample->size()!=1) { std::cout << "mcSample->size is expected to be 1\n"; return retCodeError; } // accumulate info about processed files EventCounterExt_t ecSample(mcSample->name); for (unsigned int ifile=0; ifile<mcSample->size(); ++ifile) { // Read input file TFile *infile=new TFile(mcSample->getFName(ifile),"read"); if (!infile || !infile->IsOpen()) { TString skimName=inpMgr.convertSkim2Ntuple(mcSample->getFName(ifile)); std::cout << " .. failed. Trying <" << skimName << ">" << std::endl; infile= new TFile(skimName,"read"); } assert(infile->IsOpen()); std::cout << " Reading file <" << mcSample->getFName(ifile) << ">\n"; // Get the TTrees if (!accessInfo.setTree(*infile,"Events",true)) { return retCodeError; } // Find weight for events for this file // The first file in the list comes with weight 1*extraWeightFactor, // all subsequent ones are normalized to xsection and luminosity ULong_t maxEvents = accessInfo.getEntries(); // to match old version package (DYee 7TeV paper), if ((inpMgr.userKeyValueAsInt("USE7TEVMCWEIGHT")==1) && (isample==0) && (ifile==0)) { extraWeightFactor=maxEvents / (inpMgr.totalLumi() * inpMgr.mcSampleInfo(0)->getXsec(ifile)); } //std::cout << "extraWeightFactor=" << extraWeightFactor << ", chk=" << (maxEvents0/inpMgr.mcSampleInfo(0)->getXsec(ifile)) << "\n"; //const double extraWeightFactor=1.0; if (! evWeight.setWeight_and_adjustMaxEvents(maxEvents, inpMgr.totalLumi(), mcSample->getXsec(ifile), extraWeightFactor, inpMgr.selectEventsFlag())) { std::cout << "adjustMaxEvents failed\n"; return retCodeError; } std::cout << "mcSample xsec=" << mcSample->getXsec(ifile) << ", nEntries=" << maxEvents << "\n"; std::cout << " -> sample base weight is " << evWeight.baseWeight() << "\n"; // loop through events EventCounterExt_t ec(Form("%s_file%d",mcSample->name.Data(),ifile)); ec.setIgnoreScale(0); // 1 - count events, 0 - take weight in account // adjust the scale in the counter // if FEWZ weight should be considered, use evWeight.totalWeight() after // the FEWZ weight has been identified (see a line below) ec.setScale(evWeight.baseWeight()); std::cout << "numEntries = " << accessInfo.getEntriesFast() << ", " << maxEvents << " events will be used" << std::endl; for(ULong_t ientry=0; ientry<maxEvents; ientry++) { if (DYTools::isDebugMode(runMode) && (ientry>1000000)) break; // debug option //if (DYTools::isDebugMode(runMode) && (ientry>100)) break; // debug option printProgress(250000," ientry=",ientry,maxEvents); ec.numEvents_inc(); // Load generator level info accessInfo.GetGen(ientry); // If the Z->ll leptons are not electrons, discard this event. // This is needed for signal MC samples such as Madgraph Z->ll // where all 3 lepton flavors are possible if (!accessInfo.genLeptonsAreElectrons()) continue; // Load event info to get nPU accessInfo.GetInfoEntry(ientry); // FSR study correction for weight if (useSpecWeight) { evWeight.setSpecWeightValue(accessInfo,FSRmassDiff,specWeight); if ((systMode==DYTools::FSR_RND_STUDY) && (ientry<100)) { std::cout << "ientry=" << ientry << ", "; evWeight.PrintDetails(); } } // Adjust event weight // .. here "false" = "not data" evWeight.set_PU_and_FEWZ_weights(accessInfo,false); // adjust the scale in the counter to include FEWZ // (and possibly PU) weight //ec.setScale(evWeight.totalWeight()); // accumulate denominator const mithep::TGenInfo *gen= accessInfo.genPtr(); hMassv[isample]->Fill(gen->vmass, evWeight.totalWeight()); hMassBinsv[isample]->Fill(gen->vmass, evWeight.totalWeight()); hvTotal[isample]->Fill(gen->mass, fabs(gen->y), evWeight.totalWeight()); #ifdef calculate_PreFsrAcc hvTotalPreFsr[isample]->Fill(gen->vmass, fabs(gen->vy), evWeight.totalWeight()); #endif int failAcc=0; // check acceptance at Gen PostFSR level if (!evtSelector.inAcceptance(accessInfo)) { hvFail[isample]->Fill(gen->mass, fabs(gen->y), evWeight.totalWeight()); failAcc=1; } #ifdef calculate_PreFsrAcc if (evtSelector.inAcceptancePreFsr(accessInfo)) { hvPassPreFsr[isample]->Fill(gen->vmass, fabs(gen->vy), evWeight.totalWeight()); } #endif if (failAcc) continue; ec.numEventsPassedAcceptance_inc(); // accumulate denominator hvPass[isample]->Fill(gen->mass, fabs(gen->y), evWeight.totalWeight()); hSelEvents->Fill(isample,evWeight.totalWeight()); } // loop over events ec.print(2); // print info about file ecSample.add(ec); // accumulate event counts ecTotal.add(ec); infile->Close(); delete infile; } ecSample.print(2); // print info about sample evtSelector.printCounts(); } ecTotal.print(2); } // if (processData) std::cout << "outFileName=<" << outFileName << ">\n"; if (DYTools::processData(runMode)) { TFile file(outFileName,"recreate"); int res=file.IsOpen(); if (res) res=saveVec(file,hvPass,"accPassDir"); if (res) res=saveVec(file,hvTotal,"accTotalDir"); if (res) res=saveVec(file,hvFail,"accFailDir"); #ifdef calculate_PreFsrAcc if (res) res=saveVec(file,hvPassPreFsr,"accPassPreFsrDir"); if (res) res=saveVec(file,hvTotalPreFsr,"accTotalPreFsrDir"); #endif if (res) res=saveVec(file,hMassv,"mass_1GeV_bins"); if (res) res=saveVec(file,hMassBinsv,"mass_analysis_bins"); if (res) res=saveVec(file,hZpeakv,"mass_Zpeak_1GeV"); if (res) res=saveHisto(file,hSelEvents,"procFileInfo"); if (res) writeBinningArrays(file); file.Close(); if (!res) { std::cout << "error occurred during save to file <" << outFileName << ">\n"; return retCodeError; } } else { TFile file(outFileName,"read"); int res=file.IsOpen(); if (res) res=checkBinningArrays(file); if (res) res=loadVec(file,hvPass,"accPassDir"); if (res) res=loadVec(file,hvTotal,"accTotalDir"); if (res) res=loadVec(file,hvFail,"accFailDir"); #ifdef calculate_PreFsrAcc if (res) res=saveVec(file,hvPassPreFsr,"accPassPreFsrDir"); if (res) res=saveVec(file,hvTotalPreFsr,"accTotalPreFsrDir"); #endif if (res) res=loadVec(file,hMassv,"mass_1GeV_bins"); if (res) res=loadVec(file,hMassBinsv,"mass_analysis_bins"); if (res) res=loadVec(file,hZpeakv,"mass_Zpeak_1GeV"); if (res) res=loadHisto(file,&hSelEvents,"procFileInfo"); file.Close(); if (!res) { std::cout << "error occurred during save to file <" << outFileName << ">\n"; return retCodeError; } } TH2D *hSumPass_BaseH2=createBaseH2("hSumPass_baseH2","hSumPass_baseH2",1); TH2D *hSumTotal_BaseH2=createBaseH2("hSumTotal_baseH2","hSumTotal_baseH2",1); TH2D *hSumFail_BaseH2=createBaseH2("hSumFail_baseH2","hSumFail_baseH2",1); addHistos(hSumPass_BaseH2,hvPass); addHistos(hSumTotal_BaseH2,hvTotal); addHistos(hSumFail_BaseH2,hvFail); TH2D *hAcc_BaseH2 = createBaseH2("hAcceptance_baseH2","hAcc_baseH2",1); // We need the binomial error for the acceptance // eff=Pass/Tot, // (dEff)^2= (1-eff)^2/T^2 (dPass)^2 + eff^2/T^2 (dFail)^2 // (dFail)^2 = (dTot)^2 - (dPass)^2 hAcc_BaseH2->Divide(hSumPass_BaseH2,hSumTotal_BaseH2,1,1,"b"); TH2D *hSumPass=convertBaseH2actual(hSumPass_BaseH2,"hSumPass",1); TH2D *hSumFail=convertBaseH2actual(hSumFail_BaseH2,"hSumFail",1); TH2D *hSumTotal=convertBaseH2actual(hSumTotal_BaseH2,"hSumTotal",1); TH2D *hAcc=Clone(hAcc_BaseH2,"hAcceptance","hAcc"); hAcc->Divide(hSumPass,hSumTotal,1,1,"b"); #ifdef calculate_PreFsrAcc TH2D *hSumPassPreFsr_BaseH2=createBaseH2("hSumPassPreFsr_baseH2","hSumPassPreFsr_baseH2",1); TH2D *hSumTotalPreFsr_BaseH2=createBaseH2("hSumTotalPreFsr_baseH2","hSumTotalPreFsr_baseH2",1); addHistos(hSumPassPreFsr_BaseH2,hvPassPreFsr); addHistos(hSumTotalPreFsr_BaseH2,hvTotalPreFsr); TH2D *hSumPassPreFsr=convertBaseH2actual(hSumPassPreFsr_BaseH2,"hSumPassPreFsr",1); TH2D *hSumTotalPreFsr=convertBaseH2actual(hSumTotalPreFsr_BaseH2,"hSumTotalPreFsr",1); TH2D *hAccPreFsr=Clone(hSumPassPreFsr,"hAccPreFsr","hAccPreFsr"); hAccPreFsr->Divide(hSumPassPreFsr,hSumTotalPreFsr,1,1,"b"); #endif std::cout << dashline; std::cout << dashline; printHisto(hSumPass_BaseH2); printHisto(hSumTotal_BaseH2); printHisto(hAcc_BaseH2); printHisto(hSumPass); printHisto(hSumTotal); printHisto(hAcc); //printHisto(hSumFail); std::cout << dashline; #ifdef calculate_PreFsrAcc std::cout << dashline; printHisto(hSumPassPreFsr); printHisto(hSumTotalPreFsr); printHisto(hAccPreFsr); std::cout << dashline; #endif if (DYTools::processData(runMode)) { TFile file(outFileName,"update"); int res=file.IsOpen(); std::cout << "res=" << res << "\n"; if (res) res=saveHisto(file,hAcc,""); if (res) res=saveHisto(file,hSumPass,""); if (res) res=saveHisto(file,hSumTotal,""); if (res) res=saveHisto(file,hSumFail,""); #ifdef calculate_PreFsrAcc if (res) res=saveHisto(file,hAccPreFsr,""); if (res) res=saveHisto(file,hSumPassPreFsr,""); if (res) res=saveHisto(file,hSumTotalPreFsr,""); #endif file.Close(); if (!res) { std::cout << "error occurred during additional save to file <" << outFileName << ">\n"; return retCodeError; } } //-------------------------------------------------------------------------------------------------------------- // Make plots //============================================================================================================== //-------------------------------------------------------------------------------------------------------------- // Summary print out //============================================================================================================== /* cout << endl; cout << "*" << endl; cout << "* SUMMARY" << endl; cout << "*--------------------------------------------------" << endl; cout << endl; */ //gBenchmark->Show("plotDYAcceptance"); ShowBenchmarkTime("plotDYAcceptance"); return retCodeOk; }
void drawVariable(int lowCent, int highCent, double lowPt, double highPt, TH1D* hvar, TString var, TCut addCut, bool doLog ,bool onleMC, float maxY ) { TCut ptCut = Form("pt>%.f && pt <%.f",lowPt,highPt); TString ptCutS = Form("E_{T} : %.0f - %.0f GeV",lowPt,highPt); if ( highPt > 200 ) ptCutS = Form("E_{T} > %.0f GeV",lowPt); char* fnamePho50 = "forest/barrelHiForestPhoton_MCphoton50_37k.root"; float csPho50 = 6.663e-7; float nEvtPho50 = 51200; float weightPho50 = csPho50/nEvtPho50; char* fnamePho80 = "forest/barrelHiForestPhoton_MCphoton80_25k.root"; float csPho80 = 8.731e-8; float nEvtPho80 = 26000; float weightPho80 = csPho80/nEvtPho80; char* fnameEmj80 = "forest/barrelHiForestPhoton_MCemJet80_41007events.root"; double csDij80 = 9.869e-5; float nEvtEmj80 = 60000; float effEmj80 = 0.204; float weightEmj80 = csDij80*effEmj80/nEvtEmj80; char* fnameEmj120 = "forest/barrelHiForestPhoton_MCemJet120_25308events.root";; float nEvtEmj120 = 14000; double csDij120 = 1.127e-5; float effEmj120 = 0.54; float weightEmj120 = csDij120*effEmj120/nEvtEmj120; TString fname1 = "forest/barrelHiForestPhotonV6.root"; TFile *f1 =new TFile(fname1.Data()); TTree *tdata = (TTree*)f1->Get("yongsunPhotonTree"); tdata->AddFriend("yEvt=yongsunHiEvt" ,fname1.Data()); tdata->AddFriend("yskim=yongsunSkimTree" ,fname1.Data()); tdata->AddFriend("yhlt=yongsunHltTree" ,fname1.Data()); tdata->AddFriend("tgj" ,fname1.Data()); multiTreeUtil* photon1 = new multiTreeUtil(); photon1->addFile( fnamePho50, "yongsunPhotonTree", "" , weightPho50); photon1->addFile( fnamePho80, "yongsunPhotonTree", "" , weightPho80); photon1->AddFriend("yEvt=yongsunHiEvt"); photon1->AddFriend("tgj"); multiTreeUtil* bkgs1 = new multiTreeUtil(); bkgs1->addFile( fnameEmj80, "yongsunPhotonTree", "" , weightEmj80); bkgs1->addFile( fnameEmj120, "yongsunPhotonTree", "" , weightEmj120); bkgs1->AddFriend("yEvt=yongsunHiEvt"); bkgs1->AddFriend("tgj"); TCut evtSelCut = "tgj.anaEvtSel"; TCut centCut = Form("(yEvt.hiBin >= %d) && (yEvt.hiBin<= %d)",lowCent,highCent); TCut photonJetCut = "tgj.photonEt>60 && tgj.jetEt>30"; TCut dphiCut= "acos(cos(tgj.photonPhi-tgj.jetPhi))>2.0944"; TCut lPhotCut= "leading==1"; TCut generalCutMC = photonJetCut && dphiCut && lPhotCut && centCut && addCut; TCut generalCutData = generalCutMC && evtSelCut; // TCut srIsoCut = FisherCut && "sigmaIetaIeta <0.010"; TCut finalCutData = generalCutData;// && srIsoCut ; TCut finalCutPho = generalCutMC;// && srIsoCut ; TCut finalCutEmj = generalCutMC;// && srIsoCut ; TH1D* tempHist = (TH1D*)hvar->Clone(Form("%s_data",hvar->GetName())); TH1D* tempHistMC1 = (TH1D*)hvar->Clone(Form("%s_MC1",hvar->GetName())); TH1D* tempHistMC2 = (TH1D*)hvar->Clone(Form("%s_MC2",hvar->GetName())); tdata->Draw(Form("%s>>%s",var.Data(),tempHist->GetName()), finalCutData); photon1->Draw2(tempHistMC1, var.Data(), finalCutPho,"ncoll"); bkgs1->Draw2 (tempHistMC2, var.Data(), finalCutPho,"ncoll"); tempHist->Sumw2(); tempHistMC1->Sumw2(); tempHistMC2->Sumw2(); handsomeTH1(tempHist); handsomeTH1(tempHistMC1); handsomeTH1(tempHistMC2); mcStyle(tempHistMC1); dijetStyle(tempHistMC2); if (!onleMC) tempHistMC1->Add(tempHistMC2); float theNorm = tempHistMC1->Integral(); tempHistMC1->Scale(1./theNorm); if (onleMC) tempHistMC2->Scale(1./tempHistMC2->Integral()); else tempHistMC2->Scale(1./theNorm); tempHist->Scale(1./tempHist->Integral()); if ( doLog) cleverRangeLog(tempHistMC1,10,1.e-5); else cleverRange(tempHistMC1,2); tempHistMC1->SetAxisRange(0.0005,maxY,"Y"); tempHistMC1->DrawCopy("hist");//hist"); TH1D* tempHistMC1Err = (TH1D*)tempHistMC1->Clone("temptemp"); tempHistMC1Err->SetLineColor(2); tempHistMC1Err->SetMarkerColor(2); tempHistMC1Err->SetMarkerSize(0); tempHistMC1Err->Draw("same"); tempHistMC2->DrawCopy("hist same");//hist"); if ( !onleMC) tempHist->DrawCopy("same");//hist"); }
//void plotTriggerForTDR(char *infname="/data/yjlee/dmeson/2015/trigger/mb.root") void plotTrigger(string infname="/data/jisun/ppMB2015fullstats/skim_ncand_D0Dntuple_crab_pp_ALLMinimumBias_AOD_D0_tkpt0p5_Ds_01212016.root") { bool sideband = false; infname="/data/jisun/ppMB2015fullstats/skim_ncand_D0Dntuple_crab_pp_ALLMinimumBias_AOD_D0_tkpt0p5_Ds_01212016.root"; TString outf = "result"; //infname="/data/wangj/Data2015/Dntuple/pp/ntD_EvtBase_20160425_HighPtJet80_DfinderData_pp_20160329_dPt0tkPt0p5_D0Dstar_skim.root"; //TString outf = "result_ppJet80"; //infname="/data/wangj/Data2015/Dntuple/pp/ntD_EvtBase_20160425_HighPtLowerJets_DfinderData_pp_20160329_dPt0tkPt0p5_D0Dstar_skim.root"; //TString outf = "result_ppLowerJets"; //infname="/data/jisun/ppMB2015fullstats/skim_ncand_D0Dntuple_crab_pp_ALLMinimumBias_AOD_D0_tkpt0p5_Ds_01212016.root"; //sideband = true; TString outf = "result_sideband"; // ============== Open file and basic settings =============== // Open Dntuple file TFile *inf = new TFile(infname.c_str()); TTree *ntDkpi = (TTree*)inf->Get("ntDkpi"); TTree *ntHlt = (TTree*)inf->Get("ntHlt"); TTree *ntSkim = (TTree*)inf->Get("ntSkim"); ntDkpi->AddFriend(ntHlt); ntDkpi->AddFriend(ntSkim); // Define bin size and bin width for trigger turnon curve histograms const int nBin = 8; Float_t bins[nBin+1]={0,6,8,10,15,20,30,50,80}; //const int nBin = 12; //Float_t bins[nBin+1]={0,5,6,8,10,12,15,20,25,30,35,40,70}; // Templates for plotting TH1D *hTmp2 = new TH1D ("hTmp2","",nBin,bins); // ============== Selection Criteria =============== // This MB sample has all pp MB TCut mbCut = "(HLT_L1MinimumBiasHF1OR_part0_v1|| \ HLT_L1MinimumBiasHF1OR_part1_v1|| \ HLT_L1MinimumBiasHF1OR_part2_v1|| \ HLT_L1MinimumBiasHF1OR_part3_v1|| \ HLT_L1MinimumBiasHF1OR_part4_v1|| \ HLT_L1MinimumBiasHF1OR_part5_v1|| \ HLT_L1MinimumBiasHF1OR_part6_v1|| \ HLT_L1MinimumBiasHF1OR_part7_v1|| \ HLT_L1MinimumBiasHF1OR_part8_v1|| \ HLT_L1MinimumBiasHF1OR_part9_v1|| \ HLT_L1MinimumBiasHF1OR_part10_v1|| \ HLT_L1MinimumBiasHF1OR_part11_v1|| \ HLT_L1MinimumBiasHF1OR_part12_v1|| \ HLT_L1MinimumBiasHF1OR_part13_v1|| \ HLT_L1MinimumBiasHF1OR_part14_v1|| \ HLT_L1MinimumBiasHF1OR_part15_v1|| \ HLT_L1MinimumBiasHF1OR_part16_v1|| \ HLT_L1MinimumBiasHF1OR_part17_v1|| \ HLT_L1MinimumBiasHF1OR_part18_v1|| \ HLT_L1MinimumBiasHF1OR_part19_v1)"; // L1 trigger thresholds TCut l1Cut16 = "L1_SingleJet16_BptxAND==1"; TCut l1Cut24 = "L1_SingleJet24_BptxAND==1"; TCut l1Cut28 = "L1_SingleJet28_BptxAND==1"; TCut l1Cut40 = "L1_SingleJet40_BptxAND==1"; TCut l1Cut48 = "L1_SingleJet48_BptxAND==1"; // D meson selection TCut DmassCut = "(abs(Dmass-1.8696)<0.03)"; TCut DmesonCut = "Dy>-1.&&Dy<1&&(DsvpvDistance/DsvpvDisErr)>3.5&&(DlxyBS/DlxyBSErr)>2.0&&Dchi2cl>0.05&&Dalpha<0.12"; TCut DmesonDaughterTrkCut = "Dtrk1highPurity&&Dtrk2highPurity&&Dtrk1Pt>2.0&&Dtrk2Pt>2.0&&Dtrk1PtErr/Dtrk1Pt<0.1&&Dtrk2PtErr/Dtrk2Pt<0.1&&abs(Dtrk1Eta)<2.0&&abs(Dtrk2Eta)<2.0&&Dtrk1Algo>3&&Dtrk1Algo<8&&Dtrk2Algo>3&&Dtrk2Algo<8&&(Dtrk1PixelHit+Dtrk1StripHit)>=11&&(Dtrk1Chi2ndf/(Dtrk1nStripLayer+Dtrk1nPixelLayer)<0.15)&&(Dtrk2Chi2ndf/(Dtrk2nStripLayer+Dtrk2nPixelLayer)<0.15)"; if (sideband) DmassCut = "(abs(Dmass-1.8696)>0.06 && abs(Dmass-1.8696)>0.12)"; // Final selection for D candidates for trigger turnon studies TCut DAnaCut = DmassCut && DmesonCut && DmesonDaughterTrkCut; // HLT trigger thresholds TCut HLTCut8 = "HLT_DmesonPPTrackingGlobal_Dpt8_v1"; TCut HLTCut15 = "HLT_DmesonPPTrackingGlobal_Dpt15_v1"; TCut HLTCut20 = "HLT_DmesonPPTrackingGlobal_Dpt20_v1"; TCut HLTCut30 = "HLT_DmesonPPTrackingGlobal_Dpt30_v1"; TCut HLTCut50 = "HLT_DmesonPPTrackingGlobal_Dpt50_v1"; // ============== L1 trigger efficiency study =============== int W = 600; int H = 600; int H_ref = 600; int W_ref = 600; // references for T, B, L, R float T = 0.08*H_ref; float B = 0.14*H_ref; float L = 0.14*W_ref; float R = 0.08*W_ref; TString canvName = "TRDFigure_Centrality"; TCanvas* c = new TCanvas(canvName,canvName,50,50,W,H); c->cd(); c->SetFillColor(0); c->SetBorderMode(0); c->SetFrameFillStyle(0); c->SetFrameBorderMode(0); c->SetLeftMargin( L/W ); c->SetRightMargin( R/W ); c->SetTopMargin( T/H ); c->SetBottomMargin( B/H ); TH2D *hTmp = new TH2D ("hTmp","",100,0,60,100,0,1.4); hTmp->GetXaxis()->SetTitle("p_{T} (D^{0}) (GeV)"); hTmp->GetYaxis()->SetTitleOffset(1.15); hTmp->GetXaxis()->SetTitleOffset(0.95); hTmp->GetYaxis()->SetTitle("HLT Efficiency"); hTmp->GetYaxis()->CenterTitle(); hTmp->GetXaxis()->CenterTitle(); hTmp->SetMaximum(1.4); hTmp->GetXaxis()->SetTitleFont(42); hTmp->GetXaxis()->SetLabelFont(42); hTmp->GetXaxis()->SetTitleSize(0.06); hTmp->GetXaxis()->SetLabelSize(0.05); hTmp->GetYaxis()->SetTitleFont(42); hTmp->GetYaxis()->SetLabelFont(42); hTmp->GetYaxis()->SetTitleSize(0.06); hTmp->GetYaxis()->SetLabelSize(0.05); // TGraphAsymmErrors* g8 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut16), HLTCut8, nBin, bins); // TGraphAsymmErrors* g15 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut24), HLTCut15, nBin, bins); TGraphAsymmErrors* g20 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut28), HLTCut20, nBin, bins); TGraphAsymmErrors* g30 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut40), HLTCut30, nBin, bins); TGraphAsymmErrors* g50 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&l1Cut48), HLTCut50, nBin, bins); /* TGraphAsymmErrors* g8 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut16), HLTCut8, nBin, bins); TGraphAsymmErrors* g15 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut24), HLTCut15, nBin, bins); TGraphAsymmErrors* g20 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut28), HLTCut20, nBin, bins); TGraphAsymmErrors* g30 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&l1Cut40), HLTCut30, nBin, bins); */ hTmp->Draw(); // g8->SetLineColor(1); // g8->SetMarkerColor(1); // g8->Draw("p same"); // g15->SetLineColor(2); // g15->SetMarkerColor(2); // g15->Draw("pl same"); g20->SetLineColor(4); g20->SetMarkerColor(4); g20->Draw("pl same"); g30->SetLineColor(kGreen+2); g30->SetMarkerColor(kGreen+2); g30->Draw("pl same"); g50->SetLineColor(kOrange); g50->SetMarkerColor(kOrange); g50->Draw("pl same"); TLegend *legend=new TLegend(0.4579866,0.2472028,0.8389262,0.4342657,""); legend->SetBorderSize(0); legend->SetLineColor(0); legend->SetFillColor(0); legend->SetFillStyle(1001); legend->SetTextFont(42); legend->SetTextSize(0.04); // TLegendEntry *ent_g8=legend->AddEntry(g8,"HLT D meson p_{T} #geq 8","pl"); // ent_g8->SetTextFont(42); // ent_g8->SetLineColor(1); // ent_g8->SetMarkerColor(1); // TLegendEntry *ent_g15=legend->AddEntry(g15,"HLT D meson p_{T} #geq15","pl"); // ent_g15->SetTextFont(42); // ent_g15->SetLineColor(1); // ent_g15->SetMarkerColor(1); TLegendEntry *ent_g20=legend->AddEntry(g20,"HLT D meson p_{T} #geq 20","pl"); ent_g20->SetTextFont(42); ent_g20->SetLineColor(1); ent_g20->SetMarkerColor(1); TLegendEntry *ent_g30=legend->AddEntry(g30,"HLT D meson p_{T} #geq 30","pl"); ent_g30->SetTextFont(42); ent_g30->SetLineColor(1); ent_g30->SetMarkerColor(1); TLegendEntry *ent_g50=legend->AddEntry(g50,"HLT D meson p_{T} #geq 50","pl"); ent_g50->SetTextFont(42); ent_g50->SetLineColor(1); ent_g50->SetMarkerColor(1); legend->Draw("same"); CMS_lumi( c, 1, 11 ); TLatex * tlatexeff=new TLatex(0.2079866,0.70,"HLT efficiency with respect to L1 seed"); tlatexeff->SetNDC(); tlatexeff->SetTextColor(1); tlatexeff->SetTextFont(42); tlatexeff->SetTextSize(0.040); // tlatexeff->Draw("same"); c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.pdf"); c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.png"); // c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.jpeg"); // c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.eps"); c->SaveAs(outf+"/Dmeson-HLTriggerEfficiency.C"); /* // ============== HLT trigger efficiency study =============== TCanvas *c2 = new TCanvas("c2","",600,600); TGraphAsymmErrors* gL16 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet16_BptxAND_Prescl==1"), l1Cut16, nBin, bins); TGraphAsymmErrors* gL24 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet24_BptxAND_Prescl==1"), l1Cut24, nBin, bins); TGraphAsymmErrors* gL28 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet28_BptxAND_Prescl==1"), l1Cut28, nBin, bins); TGraphAsymmErrors* gL40 = getEfficiency(ntDkpi,Form("Max$(Dpt*(%s))",DAnaCut.GetTitle()), TCut(DAnaCut&&mbCut&&"L1_SingleJet40_BptxAND_Prescl==1"), l1Cut40, nBin, bins); hTmp2->Draw(); hTmp2->SetXTitle("p_{T} (D^{0})(GeV/c)"); hTmp2->SetYTitle("L1 Trigger Efficiency"); gL16->SetMarkerColor(1); gL16->SetLineColor(1); gL16->Draw("p same"); gL24->SetMarkerColor(2); gL24->SetLineColor(2); gL24->Draw("p same"); gL28->SetMarkerColor(4); gL28->SetLineColor(4); gL28->Draw("p same"); gL40->SetMarkerColor(kGreen+2); gL40->SetLineColor(kGreen+2); gL40->Draw("p same"); TLegend *leg2 = new TLegend(0.4916107,0.3059441,0.8322148,0.4912587); leg2->SetBorderSize(0); leg2->SetFillStyle(0); leg2->AddEntry(gL16,"pp #sqrt{s} = 5.02 TeV",""); leg2->AddEntry(gL16,"Level 1 Jet 16","pl"); leg2->AddEntry(gL24,"Level 1 Jet 24","pl"); leg2->AddEntry(gL28,"Level 1 Jet 28","pl"); leg2->AddEntry(gL40,"Level 1 Jet 40","pl"); leg2->Draw(); c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.pdf"); c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.png"); // c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.jpeg"); c2->SaveAs(outf+"/Dmeson-L1TriggerEfficiency.C"); // ============== Plot an example D mass distribution =============== TCanvas *c3 = new TCanvas("c3","",600,600); ntDkpi->Draw("Dmass>>h(100,1.7696,1.9696)",DmesonCut&&DmesonDaughterTrkCut&&mbCut&&l1Cut16); // ..done */ }
void formEtArr(Double_t min, Double_t max, string* arr) { *arr = Form("%.0f-%.0f",min,max); }
void Plot_AM_MR2j_07Sep_Susy_4_auto() { TString cutNameBefore = Form("Data/"); // cut_variable TString cutNameAfter = Form("_4_3_Tot_temp"); gROOT->LoadMacro("PlotVHqqHggH.C+"); gInterpreter->ExecuteMacro("LatinoStyle2.C"); TCanvas* c1 = new TCanvas("MR2j","MR2j",500,600); TFile* f = new TFile("~/Cern/Code/VBF/qqHWW/AnalysisPackage_qqHWWlnulnu/out_test_Latinos_07Sep2012_2000_Run2012AB_8TeV_SUSY.root"); PlotVHqqHggH* hs = new PlotVHqqHggH(); hs->setLumi(5.063); hs->setLabel("mR_{jet-jet}"); hs->addLabel(" #sqrt{s} = 8 TeV"); TString name; std::vector<int> vectColourBkg; std::vector<double> vectSystBkg; std::vector<std::string> vectNameBkg; std::vector<TH1F*> vectTHBkg; std::vector<int> vectColourSig; std::vector<double> vectSystSig; std::vector<std::string> vectNameSig; std::vector<TH1F*> vectTHSig; ///==== signal (begin) ==== name = Form("%sT2tt-350-70%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHSig.push_back ( (TH1F*) f->Get(name) ); vectNameSig.push_back ("T2tt-stop350-lsp70"); vectColourSig.push_back(6); name = Form("%sT2tt-500-70%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHSig.push_back ( (TH1F*) f->Get(name) ); vectNameSig.push_back ("T2tt-stop500-lsp70"); vectColourSig.push_back(97); name = Form("%sT2tt-350-100%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHSig.push_back ( (TH1F*) f->Get(name) ); vectNameSig.push_back ("T2tt-stop350-lsp100"); vectColourSig.push_back(70); name = Form("%sT2tt-500-100%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHSig.push_back ( (TH1F*) f->Get(name) ); vectNameSig.push_back ("T2tt-stop500-lsp100"); vectColourSig.push_back(65); name = Form("%sT2tt-500-200%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHSig.push_back ( (TH1F*) f->Get(name) ); vectNameSig.push_back ("T2tt-stop500-lsp200"); vectColourSig.push_back(5); name = Form("%sT2tt-200-0%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHSig.push_back ( (TH1F*) f->Get(name) ); vectNameSig.push_back ("T2tt-stop200-lsp0"); vectColourSig.push_back(7); ///==== signal (end) ==== name = Form("%sDATA%s",cutNameBefore.Data(),cutNameAfter.Data()); hs->setDataHist ((TH1F*)f->Get(name)); hs->setBlindBinSx(0); hs->setBlindBinDx(0); hs->setCutSx(-999,">"); hs->setCutDx(-999,"<"); ///==== background (begin) ==== name = Form("%sH-125%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHBkg.push_back ( (TH1F*) f->Get(name) ); vectNameBkg.push_back ("H-125"); vectColourBkg.push_back(633); vectSystBkg.push_back(0.00); name = Form("%sVV%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHBkg.push_back ( (TH1F*) f->Get(name) ); vectNameBkg.push_back ("WZ/ZZ"); vectColourBkg.push_back(858); vectSystBkg.push_back(0.00); name = Form("%sWJets%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHBkg.push_back ( (TH1F*) f->Get(name) ); vectNameBkg.push_back ("W+jets"); vectColourBkg.push_back(921); vectSystBkg.push_back(0.36); name = Form("%sTop%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHBkg.push_back ( (TH1F*) f->Get(name) ); vectNameBkg.push_back ("top"); vectColourBkg.push_back(400); vectSystBkg.push_back(0.00); name = Form("%sZJets%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHBkg.push_back ( (TH1F*) f->Get(name) ); vectNameBkg.push_back ("DY+jets"); vectColourBkg.push_back(418); vectSystBkg.push_back(0.00); name = Form("%sWW%s",cutNameBefore.Data(),cutNameAfter.Data()); vectTHBkg.push_back ( (TH1F*) f->Get(name) ); vectNameBkg.push_back ("WW"); vectColourBkg.push_back(851); vectSystBkg.push_back(0.00); ///==== background (end) ==== hs->set_vectTHBkg (vectTHBkg); hs->set_vectNameBkg (vectNameBkg); hs->set_vectColourBkg (vectColourBkg); hs->set_vectSystBkg (vectSystBkg); hs->set_vectTHSig (vectTHSig); hs->set_vectNameSig (vectNameSig); hs->set_vectColourSig (vectColourSig); // hs->set_vectSystSig (vectSystSig); hs->set_addSignal (0); //---- stack signal = 1, no stack signal = 0 hs->prepare(); ///==== draw ==== hs->Draw(c1,1,true); c1->Print("07Sep_Susy_4/MR2j.pdf"); c1->Print("07Sep_Susy_4/MR2j.png"); c1->SetLogy(); hs->Draw(c1,1,true); c1->Print("07Sep_Susy_4/MR2j_logy.pdf"); c1->Print("07Sep_Susy_4/MR2j_logy.png"); }
void muJetVariable(std::string inputFile, std::string outputFile){ // read the ntuples (in pcncu) TreeReader data(inputFile.data()); // Declare the histogram TFile* f = new TFile(inputFile.data()); TH1D* h_totalEvents = (TH1D*)f->Get("h_totalEv"); TH1D* h_nVtx = new TH1D("h_nVtx", "nVtx", 30, -0.5, 29.5); TH1D* h_FATjetPt = new TH1D("h_FATjetPt", "FATjetPt", 20, 100, 1000); TH1D* h_FATjetEta = new TH1D("h_FATjetEta", "FATjetEta", 20, -4, 4); TH1D* h_FATjetCISVV2 = new TH1D("h_FATjetCISVV2", "FATjetCISVV2", 20, 0, 1.2); TH1D* h_FATjetSDmass = new TH1D("h_FATjetSDmass", "FATjetSDmass", 20, 0, 200); TH1D* h_FATjetPRmass = new TH1D("h_FATjetPRmass", "FATjetPRmass", 20, 0, 200); TH1D* h_FATjetPRmassCorr = new TH1D("h_FATjetPRmassCorr", "FATjetPRmassCorr", 20, 0, 200); TH1D* h_FATjetTau1 = new TH1D("h_FATjetTau1", "FATjetTau1", 20, 0, 1); TH1D* h_FATjetTau2 = new TH1D("h_FATjetTau2", "FATjetTau2", 20, 0, 1); TH1D* h_FATjetTau2dvTau1 = new TH1D("h_FATjetTau2dvTau1", "FATjetTau2dvTau1", 20, 0, 1); TH1D* h_FATsubjetPt = new TH1D("h_FATsubjetPt", "FATsubjetPt", 20, 0, 800); TH1D* h_FATsubjetEta = new TH1D("h_FATsubjetEta", "FATsubjetEta", 20, -4, 4); TH1D* h_FATsubjetSDCSV = new TH1D("h_FATsubjetSDCSV", "FATsubjetSDCSV", 20, 0, 1.2); h_nVtx ->Sumw2(); h_FATjetPt ->Sumw2(); h_FATjetEta ->Sumw2(); h_FATjetCISVV2 ->Sumw2(); h_FATjetSDmass ->Sumw2(); h_FATjetPRmass ->Sumw2(); h_FATjetPRmassCorr->Sumw2(); h_FATjetTau1 ->Sumw2(); h_FATjetTau2 ->Sumw2(); h_FATjetTau2dvTau1->Sumw2(); h_FATsubjetPt ->Sumw2(); h_FATsubjetEta ->Sumw2(); h_FATsubjetSDCSV ->Sumw2(); h_nVtx ->GetXaxis()->SetTitle("nVtx"); h_FATjetPt ->GetXaxis()->SetTitle("FATjetPt"); h_FATjetEta ->GetXaxis()->SetTitle("FATjetEta"); h_FATjetCISVV2 ->GetXaxis()->SetTitle("FATjetCISVV2"); h_FATjetSDmass ->GetXaxis()->SetTitle("FATjetSDmass"); h_FATjetPRmass ->GetXaxis()->SetTitle("FATjetPRmass"); h_FATjetPRmassCorr->GetXaxis()->SetTitle("FATjetPRmassL2L3Corr"); h_FATjetTau1 ->GetXaxis()->SetTitle("FATjetTau1"); h_FATjetTau2 ->GetXaxis()->SetTitle("FATjetTau2"); h_FATjetTau2dvTau1->GetXaxis()->SetTitle("FATjetTau2dvTau1"); h_FATsubjetPt ->GetXaxis()->SetTitle("FATsubjetPt"); h_FATsubjetEta ->GetXaxis()->SetTitle("FATsubjetEta"); h_FATsubjetSDCSV ->GetXaxis()->SetTitle("FATsubjetSDCSV"); // begin of event loop for( Long64_t ev = 0; ev < data.GetEntriesFast(); ev++ ){ if( ev % 1000000 == 0 ) fprintf(stderr, "Processing event %lli of %lli\n", ev + 1, data.GetEntriesFast()); data.GetEntry(ev); Int_t nVtx = data.GetInt("nVtx"); Float_t eventWeight = data.GetFloat("ev_weight"); TClonesArray* muP4 = (TClonesArray*) data.GetPtrTObject("muP4"); Int_t FATnJet = data.GetInt("FATnJet"); Int_t* FATnSubSDJet = data.GetPtrInt("FATnSubSDJet"); Float_t* FATjetCISVV2 = data.GetPtrFloat("FATjetCISVV2"); Float_t* FATjetSDmass = data.GetPtrFloat("FATjetSDmass"); Float_t* FATjetPRmass = data.GetPtrFloat("FATjetPRmass"); Float_t* FATjetPRmassCorr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); Float_t* FATjetTau1 = data.GetPtrFloat("FATjetTau1"); Float_t* FATjetTau2 = data.GetPtrFloat("FATjetTau2"); TClonesArray* FATjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); vector<bool>& FATjetPassIDLoose = *((vector<bool>*) data.GetPtr("FATjetPassIDLoose")); vector<float>* FATsubjetSDPx = data.GetPtrVectorFloat("FATsubjetSDPx", FATnJet); vector<float>* FATsubjetSDPy = data.GetPtrVectorFloat("FATsubjetSDPy", FATnJet); vector<float>* FATsubjetSDPz = data.GetPtrVectorFloat("FATsubjetSDPz", FATnJet); vector<float>* FATsubjetSDE = data.GetPtrVectorFloat("FATsubjetSDE", FATnJet); vector<float>* FATsubjetSDCSV = data.GetPtrVectorFloat("FATsubjetSDCSV", FATnJet); // select good muons vector<Int_t> goodMuID; if( !isPassZmumu(data, goodMuID) ) continue; TLorentzVector* thisMu = (TLorentzVector*)muP4->At(goodMuID[0]); TLorentzVector* thatMu = (TLorentzVector*)muP4->At(goodMuID[1]); // select good FATjet Int_t goodFATJetID = -1; TLorentzVector* thisJet = NULL; for(Int_t ij = 0; ij < FATnJet; ij++){ thisJet = (TLorentzVector*)FATjetP4->At(ij); if( thisJet->Pt() < 200 ) continue; if( fabs(thisJet->Eta()) > 2.4 ) continue; if( !FATjetPassIDLoose[ij] ) continue; if( thisJet->DeltaR(*thisMu) < 0.8 || thisJet->DeltaR(*thatMu) < 0.8 ) continue; if( FATjetPRmassCorr[ij] > 65 && FATjetPRmassCorr[ij] < 145 ) continue; goodFATJetID = ij; break; } if( goodFATJetID < 0 ) continue; h_nVtx ->Fill(nVtx,eventWeight); h_FATjetPt ->Fill(thisJet->Pt(),eventWeight); h_FATjetEta ->Fill(thisJet->Eta(),eventWeight); h_FATjetCISVV2 ->Fill(FATjetCISVV2[goodFATJetID],eventWeight); h_FATjetSDmass ->Fill(FATjetSDmass[goodFATJetID],eventWeight); h_FATjetPRmass ->Fill(FATjetPRmass[goodFATJetID],eventWeight); h_FATjetPRmassCorr->Fill(FATjetPRmassCorr[goodFATJetID],eventWeight); h_FATjetTau1 ->Fill(FATjetTau1[goodFATJetID],eventWeight); h_FATjetTau2 ->Fill(FATjetTau2[goodFATJetID],eventWeight); h_FATjetTau2dvTau1->Fill(FATjetTau2[goodFATJetID]/FATjetTau1[goodFATJetID],eventWeight); for(Int_t is = 0; is < FATnSubSDJet[goodFATJetID]; is++){ TLorentzVector l4_subjet(0,0,0,0); l4_subjet.SetPxPyPzE(FATsubjetSDPx[goodFATJetID][is], FATsubjetSDPy[goodFATJetID][is], FATsubjetSDPz[goodFATJetID][is], FATsubjetSDE [goodFATJetID][is]); h_FATsubjetPt ->Fill(l4_subjet.Pt(),eventWeight); h_FATsubjetEta ->Fill(l4_subjet.Eta(),eventWeight); h_FATsubjetSDCSV->Fill(FATsubjetSDCSV[goodFATJetID][is],eventWeight); } } // end of event loop fprintf(stderr, "Processed all events\n"); TFile* outFile = new TFile(Form("%s_jetmumuVariable.root",outputFile.c_str()), "recreate"); h_nVtx ->Write("nVtx"); h_FATjetPt ->Write("FATjetPt"); h_FATjetEta ->Write("FATjetEta"); h_FATjetCISVV2 ->Write("FATjetCISVV2"); h_FATjetSDmass ->Write("FATjetSDmass"); h_FATjetPRmass ->Write("FATjetPRmass"); h_FATjetPRmassCorr->Write("FATjetPRmassCorr"); h_FATjetTau1 ->Write("FATjetTau1"); h_FATjetTau2 ->Write("FATjetTau2"); h_FATjetTau2dvTau1->Write("FATjetTau2dvTau1"); h_FATsubjetPt ->Write("FATsubjetPt"); h_FATsubjetEta ->Write("FATsubjetEta"); h_FATsubjetSDCSV ->Write("FATsubjetSDCSV"); h_totalEvents ->Write("totalEvents"); outFile->Write(); delete f; delete outFile; }
//// runCode // 0=merged, 1=1stRun, 2=2ndRun void draw_1D_bfrac_pt_ETHF(char* dirName = "6rap3pt", int runCode=1, bool isScale = false,bool isLog = false) { gROOT->Macro("./JpsiStyle.C"); //TCanvas *ctmp0 = new TCanvas("ctmp0","RFB vs ET",900,600); //ctmp0->Divide(3,2); TCanvas *ctmp0 = new TCanvas("ctmp0","ET 0-20",900,600); ctmp0->Divide(3,2); TCanvas *ctmp1 = new TCanvas("ctmp1","ET 20-30",900,600); ctmp1->Divide(3,2); TCanvas *ctmp2 = new TCanvas("ctmp2","ET30-120",900,600); ctmp2->Divide(3,2); // set info. const Double_t br = 0.0593 ; const Double_t brErr = 0.0006; Double_t lumi_nb; Double_t lumi_nb_err; Double_t lumi_mub; Double_t lumi_mub_err; string runstring; string lumistring; string cmsstring = "CMS preliminary"; string beamstring = "pPb #sqrt{s_{NN}} = 5.02 TeV"; if (runCode ==0) { runstring = "All"; lumi_nb =34.622; lumi_nb_err=1.2; } else if (runCode == 1) { runstring = "Pbp"; lumi_nb =20.7; lumi_nb_err=0.7; }//1stRun else if (runCode == 2) { runstring = "pPb"; lumi_nb = 14.0; lumi_nb_err=0.5; }//2ndRun else { cout << " *** Error!!! choose runCode 0, 1, or 2 " << endl; return ; } lumistring = Form("L_{int} = %.1f nb^{ -1}", lumi_nb); lumi_mub = lumi_nb * 1000; // (nb)^{-1} -> {#mub}^{-1} lumi_mub_err = lumi_nb_err * 1000; // (nb)^{-1} -> {#mub}^{-1} //rap array in yCM (from forward to backward) //Double_t rapArrNumFB[] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4, -2.87};// for pt dist. //Double_t rapArrNumBF[] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. Double_t rapArrNumFB[] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93};// for pt dist. //Double_t rapArrNumBF[] = {-1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. const Int_t nRap = sizeof(rapArrNumFB)/sizeof(Double_t)-1; cout << "nRap = " << nRap << endl; Double_t rapBinW[nRap]; for (Int_t iy=0; iy<nRap; iy++) { rapBinW[iy] = rapArrNumFB[iy]-rapArrNumFB[iy+1]; cout << iy <<"th rapBinW = " << rapBinW[iy] <<endl; } //pt array //Double_t ptArrNum[] = {0.0, 3.0, 4.0, 5.0, 6.5, 7.5, 8.5, 10., 14., 30.}; Double_t ptArrNum[] = {5.0, 6.5, 10., 30.}; //6rap3pt const Int_t nPt = sizeof(ptArrNum)/sizeof(Double_t)-1; cout << "nPt = " << nPt << endl; Double_t ptBinW[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { ptBinW[ipt] = ptArrNum[ipt+1]-ptArrNum[ipt]; cout << ipt <<"th ptBinW = " << ptBinW[ipt] <<endl; } //ethf array Double_t etArrNum[] = {0.0, 20.0, 30.0, 120.0}; const Int_t nEtBins = sizeof(etArrNum)/sizeof(double)-1; cout << "nEtBins=" << nEtBins << endl; // array string string rapArr[nRap]; for (Int_t iy=0; iy<nRap; iy++) { formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]); cout << iy <<"th rapArr = " << rapArr[iy] << endl; } string ptArr[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { formPtArr(ptArrNum[ipt], ptArrNum[ipt+1], &ptArr[ipt]); cout << ipt <<"th ptArr = " << ptArr[ipt] << endl; } string etArr[nEtBins]; for (Int_t i=0; i<nEtBins; i++){ formEtArr(etArrNum[i], etArrNum[i+1], &etArr[i]); cout << "etArr["<<i<<"] = "<< etArr[i].c_str() << endl; } // --- read-in file TFile * f2D = new TFile(Form("../total2Dhist_%s.root",dirName)); cout << "dirName = " << dirName << endl; cout << "runCode = " << runCode << ", runstring = " << runstring.c_str() << endl; // --- read-in 2D hist for corrected yield TH2D* h2D_corrY_Pbp[nEtBins]; TH2D* h2D_corrY_pPb[nEtBins]; for (int iet=0; iet<nEtBins; iet++){ h2D_corrY_Pbp[iet] = (TH2D*)f2D->Get(Form("otherFitInfo/h2D_fit_pt_y_bFrac_Pbp_%d",iet)); h2D_corrY_pPb[iet] = (TH2D*)f2D->Get(Form("otherFitInfo/h2D_fit_pt_y_bFrac_pPb_%d",iet)); cout << iet << "th h2D_corrY_Pbp = " << h2D_corrY_Pbp[iet] << endl; cout << iet << "th h2D_corrY_pPb = " << h2D_corrY_pPb[iet] << endl; } const int nbinsX = h2D_corrY_Pbp[0]->GetNbinsX(); const int nbinsY = h2D_corrY_Pbp[0]->GetNbinsY(); cout << "nbinsX = " << nbinsX << endl; cout << "nbinsY = " << nbinsY << endl; if (nbinsX != nRap) { cout << " *** Error!!! nbinsX != nRap"; return; }; if (nbinsY != nPt) { cout << " *** Error!!! nbinsY != nPt"; return; }; // --- projection to 1D hist TH1D* h1D_corrY_Pbp[nEtBins][nbinsX]; TH1D* h1D_corrY_pPb[nEtBins][nbinsX]; // iy=0 refers to forwards !!! (ordering here) for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_Pbp[iet][iy] = h2D_corrY_Pbp[iet]->ProjectionY(Form("h1D_corrY_Pbp_%d_%d",iet,iy),iy+1,iy+1); h1D_corrY_Pbp[iet][iy]->SetName(Form("h1D_corrY_Pbp_%d_%d",iet,iy)); //for 2nd run h1D_corrY_pPb[iet][iy] = h2D_corrY_pPb[iet]->ProjectionY(Form("h1D_corrY_pPb_%d_%d",iet,iy),nbinsX-iy,nbinsX-iy); h1D_corrY_pPb[iet][iy]->SetName(Form("h1D_corrY_pPb_%d_%d",iet,iy)); } } ////////////////////////////////////////////////////////////////////////////////////// // set values as zero for unused bins for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { if (iy>=1 && iy<=4) { h1D_corrY_Pbp[iet][iy]->SetBinContent(1,0); h1D_corrY_Pbp[iet][iy]->SetBinError(1,0); h1D_corrY_pPb[iet][iy]->SetBinContent(1,0); h1D_corrY_pPb[iet][iy]->SetBinError(1,0); } } } /* ////// after zero-bin setting, normalize! for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_Pbp[iet][iy]->Scale(1./h1D_corrY_Pbp[iet][iy]->Integral()); h1D_corrY_pPb[iet][iy]->Scale(1./h1D_corrY_pPb[iet][iy]->Integral()); h1D_corrY_Pbp[iet][iy]->Scale(1,"width"); h1D_corrY_pPb[iet][iy]->Scale(1,"width"); } } */ ////////////////////////////////////////////////////////////////// //// --- Draw histograms TLegend *legUR = new TLegend(0.45, 0.75, 0.86, 0.92); //upper left TLegend *legBL = new TLegend(0.18, 0.18, 0.59, 0.35); //upper left SetLegendStyle(legUR); SetLegendStyle(legBL); //latex box for beam, rapidity, pT info TLatex* latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextSize(0.04); for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { if (iet==0) { ctmp0->cd(iy+1);} else if (iet==1) { ctmp1->cd(iy+1); } else if (iet==2) { ctmp2->cd(iy+1); } SetHistStyle(h1D_corrY_Pbp[iet][iy],1,0); SetHistStyle(h1D_corrY_pPb[iet][iy],2,0); h1D_corrY_Pbp[iet][iy]->GetYaxis()->SetRangeUser(0,0.6); h1D_corrY_Pbp[iet][iy]->Draw("pe"); h1D_corrY_pPb[iet][iy]->Draw("pe same"); //h1D_corrY_pPb[iet][iy]->Draw("pe"); } } /* ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// // 1) merge Pbp+pPb corrected yield TH1D* h1D_corrY_tot[nEtBins][nbinsX]; for (Int_t iet=0; iet<nEtBins; iet++){ for (Int_t iy = 0; iy < nbinsX; iy++) { if (runCode ==0) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); h1D_corrY_tot[iet][iy]->Add(h1D_corrY_pPb[iet][iy]); } else if (runCode ==1) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_Pbp[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } else if (runCode ==2) { h1D_corrY_tot[iet][iy] = (TH1D*)h1D_corrY_pPb[iet][iy]->Clone(Form("h1D_corrY_tot_%d_%d",iet,iy)); } // if (iet==0) { ctmp0->cd(iy+1); h1D_corrY_tot[iet][iy]->Draw("pe"); } // if (iet==1) { ctmp1->cd(iy+1); h1D_corrY_tot[iet][iy]->Draw("pe"); } // if (iet==2) { ctmp2->cd(iy+1); h1D_corrY_tot[iet][iy]->Draw("pe"); } } } ////////////////////////////////////////////////////////////////// /////////// calculate RFB const int nRapRFB = 3; TH1D* h1D_RFB_tot_tmp[nEtBins][nbinsX]; // corrYield with merged pT TH1D* h1D_RFB_tot[nEtBins][nRapRFB]; // actual RFB vs pt // bin settingg string rapAbsArr[nRap]; for (Int_t iy=0; iy<nRapRFB; iy++) { formAbsRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapAbsArr[iy]); cout << iy <<"th rapAbsArr = " << rapAbsArr[iy] << endl; } Double_t ptArrRFBNum[] = {5.0, 6.5, 30.}; const Int_t nPtRFB = sizeof(ptArrRFBNum)/sizeof(Double_t)-1; cout << "nPtRFB = " << nPtRFB << endl; // merging pT bins (KYO - byHand) double tmpPRval01, tmpPRerr01, tmpPRval02, tmpPRerr02; double actPRval01, actPRerr01, actPRval02, actPRerr02; for (int iet=0; iet<nEtBins; iet++){ for (int iy=0; iy<nRapRFB*2; iy++){ h1D_RFB_tot_tmp[iet][iy]= new TH1D(Form("h1D_RFB_tot_tmp_%d_%d",iet,iy),Form("h1D_RFB_tot_tmp_%d_%d",iet,iy),nPtRFB,ptArrRFBNum); h1D_RFB_tot_tmp[iet][iy]->Sumw2(); actPRval01=0; actPRval02=0; actPRerr01=0; actPRerr02=0; // 1) pT 5-6.5 GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; if (iy==0 || iy==nRapRFB*2-1){ actPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(1); actPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(1); h1D_RFB_tot_tmp[iet][iy]->SetBinContent(1,actPRval01); h1D_RFB_tot_tmp[iet][iy]->SetBinError(1,actPRerr01); } else { h1D_RFB_tot_tmp[iet][iy]->SetBinContent(1,0.); h1D_RFB_tot_tmp[iet][iy]->SetBinError(1,0.); } // 2) pT 6.5-30. GeV tmpPRval01=0; tmpPRval02=0; tmpPRerr01=0; tmpPRerr02=0; tmpPRval01=h1D_corrY_tot[iet][iy]->GetBinContent(2); tmpPRerr01=h1D_corrY_tot[iet][iy]->GetBinError(2); tmpPRval02=h1D_corrY_tot[iet][iy]->GetBinContent(3); tmpPRerr02=h1D_corrY_tot[iet][iy]->GetBinError(3); actPRval02=tmpPRval01+tmpPRval02; actPRerr02=TMath::Sqrt( TMath::Power(tmpPRerr01,2) + TMath::Power(tmpPRerr02,2) ); h1D_RFB_tot_tmp[iet][iy]->SetBinContent(2,actPRval02); h1D_RFB_tot_tmp[iet][iy]->SetBinError(2,actPRerr02); //cout << iet<<"th,"<<iy<<"th h1D_RFB_tot_tmp = "<<h1D_RFB_tot_tmp[iet][iy]<<endl; // if (iet==0) { ctmp0->cd(iy+1); h1D_RFB_tot_tmp[iet][iy]->Draw("pe"); } // if (iet==1) { ctmp1->cd(iy+1); h1D_RFB_tot_tmp[iet][iy]->Draw("pe"); } // if (iet==2) { ctmp2->cd(iy+1); h1D_RFB_tot_tmp[iet][iy]->Draw("pe"); } } } // actual RFB calculation vs pT!! for (int iet=0; iet<nEtBins; iet++){ for (int iy=0; iy<nRapRFB; iy++){ h1D_RFB_tot[iet][iy] = (TH1D*)h1D_RFB_tot_tmp[iet][iy]->Clone(Form("h1D_RFB_tot_%d_%d",iet,iy)); h1D_RFB_tot[iet][iy]->Divide(h1D_RFB_tot_tmp[iet][2*nRapRFB-iy-1]); cout << iet<<"th, "<<iy<<"th h1D_RFB_tot = "<<h1D_RFB_tot[iet][iy]<<endl; //if (iet==0) { ctmp0->cd(iy+1); h1D_RFB_tot[iet][iy]->Draw("pe"); } //if (iet==1) { ctmp1->cd(iy+1); h1D_RFB_tot[iet][iy]->Draw("pe"); } //if (iet==2) { ctmp2->cd(iy+1); h1D_RFB_tot[iet][iy]->Draw("pe"); } } } /////////////////////////////////////////////// //////// --- RFB vs ETHF : 4 histograms //in=0 : pT 5-6.5, rap 1.5-1.93 //in=1 : pT 6.5-30, rap 1.5-1.93 //in=2 : pT 6.5-30, rap 0.9-1.5 //in=3 : pT 6.5-30, rap 0.0-0.9 const int nHist=4; double tmpRFBval01, tmpRFBerr01, tmpRFBval02, tmpRFBerr02, tmpRFBval03, tmpRFBerr03; TH1D* h1D_RFB_ETHF_tot[nHist]; for (int in=0; in< nHist; in++){ h1D_RFB_ETHF_tot[in]= new TH1D(Form("h1D_RFB_ETHF_tot_%d",in),Form("h1D_RFB_ETHF_tot_%d",in),nEtBins,etArrNum); h1D_RFB_ETHF_tot[in]->Sumw2(); tmpRFBval01=0;tmpRFBerr01=0;tmpRFBval02=0;tmpRFBerr02=0;tmpRFBval03=0;tmpRFBerr03=0; for (int iet=0; iet<nEtBins;iet++){ if (in==0) { tmpRFBval01=h1D_RFB_tot[iet][0]->GetBinContent(1); tmpRFBerr01=h1D_RFB_tot[iet][0]->GetBinError(1); h1D_RFB_ETHF_tot[in]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF_tot[in]->SetBinError(iet+1,tmpRFBerr01); } else { tmpRFBval01=h1D_RFB_tot[iet][in-1]->GetBinContent(2); tmpRFBerr01=h1D_RFB_tot[iet][in-1]->GetBinError(2); h1D_RFB_ETHF_tot[in]->SetBinContent(iet+1,tmpRFBval01); h1D_RFB_ETHF_tot[in]->SetBinError(iet+1,tmpRFBerr01); } } h1D_RFB_ETHF_tot[in]->SetMinimum(0.0); h1D_RFB_ETHF_tot[in]->SetMaximum(1.4); ctmp0->cd(in+1); h1D_RFB_ETHF_tot[in]->Draw("pe"); dashedLine(0.,1.,120.,1.,1,1); } */ // convert to TGraphAsymErrors /* // root file //TFile *fOut = new TFile(Form("1Dhist_%s/tmp_crossSection_pt.root",dirName),"RECREATE"); TFile *fOut = new TFile(Form("1Dhist_%s/crossSection_pt_%s.root",dirName,runstring.c_str()),"RECREATE"); fOut->cd(); for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_corrY_NP_Pbp[iy]->Write(); h1D_corrY_NP_pPb[iy]->Write(); h1D_corrY_NP_tot[iy]->Write(); } //tRap->Write(); fOut->Close(); */ return; } // end of main func.
//============================================================================= // Standard constructor, initializes variables //============================================================================= void maketracksplots(TString layeropt="double", const int nhpc = 4, const int ncanvases=4, TString outputlocation = "output/"+layeropt+"tracksplots/", TString plotfilename = layeropt+"tracksplots.pdf" ) { //layeropt="BD", "MCdata" gROOT->SetBatch(kTRUE); TString tuplelocation = "/afs/cern.ch/work/m/mwilkins/b_b-bar_cross-section/"; TString data2011tuple = tuplelocation+"Strp20r1_SL_D0andDp_MD.root"; TString MC2011tuple = tuplelocation+"MC_2011_Bu_D0Xmunu_cocktail_12873441_MC2011_S20r1_noPID_Tuples.root"; TString data2015tuple = tuplelocation+"B2DMuNuX_tuples_05082015.root"; TString MC2015tuple = tuplelocation+"MC_2015_Bu_D0Xmunu_cocktail_12873441_MC2015_S22_noPID_Tuples.root"; TFile *f[4]; f[0] = TFile::Open(data2011tuple); f[1] = TFile::Open(MC2011tuple); f[2] = TFile::Open(data2015tuple); f[3] = TFile::Open(MC2015tuple); cout<<"files opened"<<endl; //nhpc = 4; //number of histograms per canvas //ncanvases = 4; const int nstacks = ncanvases; THStack *hs[nstacks]; TCanvas *c[ncanvases]; TH1F *h[ncanvases][nhpc]; TLegend *leg[ncanvases]; //TString outputlocation = "output/"+layeropt+"tracksplots/"; //TString plotfilename = layeropt+"tracksplots.pdf"; TCanvas *cf = new TCanvas("cf","combined");//canvas to hold everything float sqnc = sqrt(ncanvases), sqncu = ceil(sqnc), sqncd = floor(sqnc); while(sqncu*sqncd<ncanvases) sqncu++; cf->Divide(sqncu,sqncd);//divide canvas based on number of plots TLegend *legf = new TLegend(0.84, 0.84, .99, .95); TString placeholder; //to avoid adding strings within functions; assign immediately before use TString placeholder2; cout<<"starting canvas loop..."<<endl; for(int ci =0; ci<ncanvases; ci++){ //loop over canvases //create indicators and strings: int year; if(ci<(ncanvases/2)){//2011 for 1st half canvases, 2015 for 2nd half year = 2011; }else year = 2015; TString yearstring = Form("%d",year); //assign what will change every 3rd plot bool condition = (int)floor(ci/2)%2 ==0; if(layeropt=="BD"){ if(condition){ B0=0; Bdecay = "B^{-}->(D^{0}->K^{-} #pi^{+})#mu^{-}"; if((filetype=="data")&&(year==2011)){ branch="tupleb2D0Mu/tupleb2D0Mu"; }else branch="Tuple_b2D0MuX/DecayTree"; }else{ B0=1; Bdecay = "B^{0}->(D^{-}->K^{+} #pi^{-} #pi^{-})#mu^{+}"; if((filetype=="data")&&(year==2011)){ branch="tupleb2DpMu/tupleb2DpMu"; } else branch="Tuple_b2DpMuX/DecayTree"; } } if(layeropt=="MCdata"){ if(condition){ filetype = "data"; }else filetype = "MC"; } int file_num=-1000;//assign file_num based on combinations of data and MC if(year==2011){ if(filetype=="data") file_num=0; if(filetype=="MC") file_num=1; } if(year==2015){ if(filetype=="data") file_num=2; if(filetype=="MC") file_num=3; } TString tracktype; if(ci%2==0){//every other canvas tracktype = "nTracks"; } else tracktype = "nLongTracks"; int B0; TString Bdecay; TString branch; TString cistring = Form("%d",ci); cout<<"loop "<<ci<<" indicators and strings created:"<<endl<<"year: "<<year<<endl; cout<<"file: "<<file_num<<endl; //create the plots placeholder = "c"+cistring; placeholder2=yearstring+tracktype; c[ci] = new TCanvas(placeholder,placeholder2,1200,800); //create the canvases c[ci]->cd(); gStyle->SetOptStat(""); leg[ci] = new TLegend(0.7, 0.7, .97, .93);//declare legend placeholder = "hs"+cistring; hs[ci] = new THStack(placeholder,""); if(layeropt=="MCdata"){ cout<<"starting histogram loop..."<<endl; for(int hi=0;hi<nhpc;hi++){ //loop over histograms in a canvas; if(layeropt=="BD"||"double"){ if(layeropt=="BD") condition = ((int)floor(hi)%2 ==0);//every other histogram if(layeropt=="double") condition = ((int)floor(hi/2)%2 ==0);//every third histogram if(condition){//alternate sets of 2 histograms B0=0; Bdecay = "B^{-}->(D^{0}->K^{-} #pi^{+})#mu^{-}"; branch="Tuple_b2D0MuX/DecayTree"; } else{ B0=1; Bdecay = "B^{0}->(D^{-}->K^{+} #pi^{-} #pi^{-})#mu^{+}"; branch="Tuple_b2DpMuX/DecayTree"; } } if(layeropt=="MCdata"){ if(hi%2==0){//true every other histogram filetype = "data"; }else filetype = "MC"; } //create convenient strings TString histring = Form("%d",hi); TString hname = "h"+cistring+histring; //create histograms if(tracktype=="nTracks") h[ci][hi] = new TH1F(hname,tracktype,104,0,1144); if(tracktype=="nLongTracks") h[ci][hi] = new TH1F(hname,tracktype,131,0,262); cout<<"histogram loop "<<hi<<" strings and histograms created"<<endl; //-----I have edited up to here-----// //navigate files cout<<"navigating file..."<<endl; TTree *MyTree; int MC; if((hi%2)==0){//alternate data and MC MC=0; //indicates data } else MC=1; //indicates MC if(MC==0){ if(file_data==0){ if(B0==0) f[file_data]->GetObject("tupleb2D0Mu/tupleb2D0Mu",MyTree); if(B0==1) f[file_data]->GetObject("tupleb2DpMu/tupleb2DpMu",MyTree); } else f[file_data]->GetObject(branch,MyTree); } else f[file_MC]->GetObject(branch,MyTree); //draw histograms cout<<"drawing histogram "<<hi<<"..."<<endl; h[ci][hi]->SetLineColor(hi+1); placeholder = tracktype+">>"+hname; MyTree->Draw(placeholder,"","norm"); cout<<"stacking histogram "<<hi<<"..."<<endl; hs[ci]->Add(h[ci][hi]);//stack histograms if(MC==0) placeholder = Bdecay+", data"; if(MC==1) placeholder = Bdecay+", MC"; leg->AddEntry(h[ci][hi],placeholder,"l");//fill legend } //draw stacked histograms cout<<"drawing stack "<<ci<<"..."<<endl; placeholder = yearstring+": "+tracktype; hs[ci]->SetTitle(placeholder); hs[ci]->Draw("nostack"); leg->Draw(); //save stuff: cout<<"saving files..."<<endl; if(ci==ncanvases-1){//if final canvas c[ci]->Print("output/doublestackedtracksplots/doublestackedtracksplots.pdf)"); } else{ c[ci]->Print("output/doublestackedtracksplots/doublestackedtracksplots.pdf("); } placeholder = "output/doublestackedtracksplots/c"+cistring+".C"; c[ci]->SaveAs(placeholder); cout<<endl; } gROOT->SetBatch(kFALSE); cout<<"done"<<endl; }
int main( int argc, char* argv[] ) { DrawTools::setStyle(); std::string tag = "V00"; std::string config = "SiPM2015Config"; if( argc>1 ) { std::string tag_str(argv[1]); tag = tag_str; if( argc>2 ) { std::string config_str(argv[2]); config=config_str; } } else { std::cout << "Usage:" << std::endl; std::cout << "./plotterMaps ([tag]) ([config])" << std::endl; exit(12345); } std::cout<<config<<std::endl; theConfiguration_=readConfiguration(config); std::string constDirName = "plots_maps_"; constDirName+=theConfiguration_.setup; if(theConfiguration_.addTagFileName){ constDirName+="_"; constDirName+=theConfiguration_.tagFileName; } system(Form("mkdir -p %s", constDirName.c_str())); TString dir(constDirName); std::vector<int> runs; std::vector<float> energies; for (int i=0;i<theConfiguration_.runs.size()+1;++i){//+1 for all the run together if(i<theConfiguration_.runs.size()){ runs.push_back(theConfiguration_.runs[i]); energies.push_back(theConfiguration_.energies[i]); } TString filename= "plots_timing_"+theConfiguration_.setup+"/timingStudiesSiPM_"+tag+"_"; if(i<theConfiguration_.runs.size()){ filename+=runs[i]; }else{ filename+="total"; } filename+=".root"; TFile* file = TFile::Open(filename.Data()); TH2F* timing_map_total=(TH2F*)file->Get("timing_map_channel"); TH2F* amplitude_map_total=(TH2F*)file->Get("amplitude_map_channel"); TH2F* amplitude_map_fibre2=(TH2F*)file->Get("amplitude_map_fibre2"); TH2F* timing_map_sel_channel=(TH2F*)file->Get("timing_map_sel_channel"); TH2F* amplitude_map_sel_channel=(TH2F*)file->Get("amplitude_map_sel_channel"); TH2F* timing_map_sel_fibre=(TH2F*)file->Get("timing_map_sel_fibre"); TH2F* amplitude_map_sel_fibre=(TH2F*)file->Get("amplitude_map_sel_fibre"); TH1F* maxAmpl_sel_fibre=(TH1F*)file->Get("maxAmpl_sel_fibre"); TH1F* maxAmpl_sel_channel=(TH1F*)file->Get("maxAmpl_sel_channel"); TString runString; if(i<theConfiguration_.runs.size()){ runString+=runs[i]; }else{ runString+="total"; //for total we do normalized plots float max= amplitude_map_total->GetMaximum(); amplitude_map_total->Scale(1./max); amplitude_map_total->SetAxisRange(0,1,"Z"); max= amplitude_map_fibre2->GetMaximum(); amplitude_map_fibre2->Scale(1./max); amplitude_map_fibre2->SetAxisRange(0,1,"Z"); max= amplitude_map_sel_channel->GetMaximum(); amplitude_map_sel_channel->Scale(1./max); amplitude_map_sel_channel->SetAxisRange(0,1,"Z"); max= amplitude_map_sel_fibre->GetMaximum(); amplitude_map_sel_fibre->Scale(1./max); amplitude_map_sel_fibre->SetAxisRange(0,1,"Z"); //timing should be scaled for number of files after hadd timing_map_total->Scale(1./runs.size()); timing_map_total->SetAxisRange(-0.1,0.9,"Z"); timing_map_sel_channel->Scale(1./runs.size()); timing_map_sel_channel->SetAxisRange(-0.1,0.9,"Z"); timing_map_sel_fibre->Scale(1./runs.size()); timing_map_sel_fibre->SetAxisRange(-0.1,0.6,"Z"); } gStyle->SetPadRightMargin(0.17);//for the palette TCanvas c1; amplitude_map_total->Draw("colz"); c1.SaveAs(dir+"/amplitude_map_"+runString+".pdf"); c1.SaveAs(dir+"/amplitude_map_"+runString+".png"); c1.Clear(); amplitude_map_fibre2->Draw("colz"); c1.SaveAs(dir+"/amplitude_map_fibre2_"+runString+".pdf"); c1.SaveAs(dir+"/amplitude_map_fibre2_"+runString+".png"); c1.Clear(); timing_map_total->Draw("colz"); c1.SaveAs(dir+"/timing_map_"+runString+".pdf"); c1.SaveAs(dir+"/timing_map_"+runString+".png"); c1.Clear(); amplitude_map_sel_channel->Draw("colz"); c1.SaveAs(dir+"/amplitude_map_sel_channel"+runString+".pdf"); c1.SaveAs(dir+"/amplitude_map_sel_channel"+runString+".png"); c1.Clear(); timing_map_sel_channel->Draw("colz"); c1.SaveAs(dir+"/timing_map_sel_channel"+runString+".pdf"); c1.SaveAs(dir+"/timing_map_sel_channel"+runString+".png"); c1.Clear(); amplitude_map_sel_fibre->Draw("colz"); c1.SaveAs(dir+"/amplitude_map_sel_fibre"+runString+".pdf"); c1.SaveAs(dir+"/amplitude_map_sel_fibre"+runString+".png"); c1.Clear(); timing_map_sel_fibre->Draw("colz"); c1.SaveAs(dir+"/timing_map_sel_fibre"+runString+".pdf"); c1.SaveAs(dir+"/timing_map_sel_fibre"+runString+".png"); gStyle->SetPadRightMargin(0.10); TCanvas c2; maxAmpl_sel_channel->GetXaxis()->SetRangeUser(0,800.); maxAmpl_sel_channel->SetLineWidth(2); maxAmpl_sel_fibre->SetLineWidth(2); maxAmpl_sel_channel->DrawNormalized(); maxAmpl_sel_fibre->DrawNormalized("same"); if(i<theConfiguration_.runs.size()){ std::string energy(Form("%.0f",energies[i])); TPaveText* pave = DrawTools::getLabelTop_expOnXaxis(energy+" GeV Electron Beam"); pave->Draw("same"); }else{ std::string energy(Form("%.0f",energies[i])); TPaveText* pave = DrawTools::getLabelTop_expOnXaxis("Electron Beam"); pave->Draw("same"); } c2.SaveAs(dir+"/maxAmpl_comparison_"+runString+".pdf"); c2.SaveAs(dir+"/maxAmpl_comparison_"+runString+".png"); } }
void getXMax(TString sample) { // sample name = cut string TString cutstring; if (sample.Contains("doublemu",TString::kExact)) { cutstring = "((hltdoublemu > 0) && (mu1pt > 20) && (mu1id == 1) && (zmass < 120.) && (zmass > 60.) && (mu1pid == -mu2pid)) && (cflagcsctight == 1 && cflaghbhenoise == 1)"; } else if (sample.Contains("doubleel",TString::kExact)) { cutstring = "((hltdoubleel > 0) && (el1pt > 20) && (el1id == 1) && (zeemass < 120.) && (zeemass > 60.) && (el1pid == -el2pid)) && (cflagcsctight == 1 && cflaghbhenoise == 1)"; } else if (sample.Contains("singlephoton",TString::kExact)) { cutstring = "((hltphoton165 == 1) || (hltphoton175 == 1)) && (nphotons == 1) && (phpt>200.)"; } else if (sample.Contains("singlemu",TString::kExact)) { cutstring = "((hltsinglemu == 1) && (nmuons == 1) && (mu1pt > 30) && (mu1id == 1)) && (cflagcsctight == 1 && cflaghbhenoise == 1)"; } else { std::cout << sample.Data() << std::endl; exit(1); } // open the file TString filestring = Form("root://eoscms//eos/cms/store/user/kmcdermo/MonoJ/Trees/Data/%s/treewithwgt.root",sample.Data()); TFile * file = TFile::Open(filestring.Data()); // CheckValidFile(file,filestring); // open the tree TTree * tree = (TTree*)file->Get("tree/tree"); // CheckValidTree(tree,"tree/tree",filestring); // this is temp th1d that is big for now TH1D * h1 = new TH1D("h1","h1",500,0.,5000.); // variable string std::vector<TString> vars; // pt variables vars.push_back("mu1pt"); vars.push_back("mu2pt"); vars.push_back("el1pt"); vars.push_back("el2pt"); vars.push_back("zpt"); vars.push_back("zeept"); vars.push_back("emupt"); vars.push_back("signaljetpt"); vars.push_back("secondjetpt"); vars.push_back("ht"); vars.push_back("phpt"); // vars.push_back("phpt_nj_lte2"); vars.push_back("pfmet"); vars.push_back("t1pfmet"); vars.push_back("mumet"); vars.push_back("t1mumet"); vars.push_back("mht"); std::vector<Double_t> xmaxes(vars.size()); // make size as variables for (UInt_t ivar = 0; ivar < vars.size(); ivar++) { // Fill h1 tree->Draw(Form("%s >> h1",vars[ivar].Data()),cutstring.Data(),"goff"); // Get max x bin per variable Double_t xmax = -1; for (Int_t ibin = 0; ibin <= h1->GetNbinsX(); ibin++) { if ( h1->GetBinContent(ibin) > 0 ){ xmax = (ibin-1) * 10.; } } // set x maximum per variables xmaxes[ivar] = xmax; } std::cout << "Sample: " << sample.Data() << std::endl << "=========================================" << std::endl; for (UInt_t ivar = 0; ivar < vars.size(); ivar++) { std::cout << "Variable: " << vars[ivar] << " xmax: " << xmaxes[ivar] << std::endl; } std::cout << std::endl << "--------------------------------------------------" << std::endl; for (UInt_t ivar = 0; ivar < vars.size(); ivar++) { std::cout << vars[ivar] << std::endl; } std::cout << std::endl << "--------------------------------------------------" << std::endl; for (UInt_t ivar = 0; ivar < vars.size(); ivar++) { std::cout << xmaxes[ivar] << std::endl; } }
void plot_xtalE(){ gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetTitleSize(0.08,"t"); // a list of runs corresponding to xtal0 to xtal53 int runlist[54] = {3295,3296,3297,3369,3300,3301,3302,3303,3368, 3244,3245,3246,3247,3248,3249,3250,3251,3252, 3240,3239,3238,3237,3236,3235,3232,3234,3233, 3267,3266,3265,3263,3258,3257,3256,3254,3253, 3268,3272,3274,3275,3276,3277,3278,3281,3283, 3294,3293,3292,3289,3288,3287,3286,3285,3284}; // for(int i=0;i<54;i++){ // runlist[i] = 3305; // } ofstream outfile("energycalibration.fcl"); TCanvas *c1 = new TCanvas("c1","c1",1800,1200); TH2D *xtalEnergy = new TH2D("xtalEnergy","xtalEnergy",9,0,9,6,0,6); outfile << "// constants from runs" <<endl;; for(int i=0;i<54;i++){ outfile << runlist[i] << " "; if(i%9==8 && i!=53) { outfile << endl; outfile << "// ";} } outfile << "\nBEGIN_PROLOG" << endl; outfile << "xtal_energy_response: {" << endl; double mean[54]; double rms[54]; double norm[54]; double index[54]; c1->Divide(9,6); for(int i=0;i<54;i++){ index[i]=i; c1->cd(54-i); c1->cd(54-i)->SetLogz(); //if(i==3 || i==8 || i==9) continue; // these are runs where the beams are at the wrong place TFile *file = new TFile(Form("run%d.root",runlist[i])); TH2D *beamEnergy2D = (TH2D*)file->Get("beamEnergy2D"); beamEnergy2D->Draw("colz text"); beamEnergy2D->SetMarkerSize(1); beamEnergy2D->SetMaximum(3000); beamEnergy2D->SetMinimum(1); beamEnergy2D->SetTitle(Form("Run %d",runlist[i])); double maxE = beamEnergy2D->GetMaximum(); int maxBin = beamEnergy2D->GetMaximumBin(); int x,y,z; beamEnergy2D->GetBinXYZ(maxBin,x,y,z); cout<<x<<" "<<y<<" "<<z<<" "<<(y-1)*9+9-x<<endl; int xtalNum = (y-1)*9+9-x; TH1D *beamEnergy = (TH1D*)file->Get(Form("beamEnergy%02d",xtalNum)); TH1D *beamTime = (TH1D*)file->Get(Form("beamTime%02d",xtalNum)); TH1D *beamTimeEnergy = (TH1D*)file->Get(Form("beamTimeEnergy%02d",xtalNum)); TH1D *syncEnergy = (TH1D*)file->Get(Form("syncEnergy%02d",xtalNum)); beamEnergy->Draw(); TF1 *fit = new TF1("fit","gaus(0)",1500,2800); fit->SetParLimits(1,1700,2500); fit->SetParLimits(2,50,150); fit->SetParameters(100,2100,100); beamEnergy->Fit("fit","REM"); norm[i]=fit->GetParameter(0); mean[i]=fit->GetParameter(1); rms[i]=fit->GetParameter(2); TF1 *refit = new TF1("refit","gaus(0)",mean[i]-2*rms[i], mean[i]+2*rms[i]); refit->SetParameters(norm[i],mean[i],rms[i]); beamEnergy->Fit("refit","REM"); norm[i]=refit->GetParameter(0); mean[i]=refit->GetParameter(1); rms[i]=refit->GetParameter(2); outfile << Form("xtal%d : %f",i,mean[i]) << endl; xtalEnergy->Fill(8-i%9,i/9,mean[i]); TText *text = new TText(0.15,0.75,Form("E%d=%.1f",xtalNum,mean[i])); text->SetTextSize(0.09); text->SetTextColor(2); text->SetNDC(); beamEnergy->GetListOfFunctions()->Add(text); } outfile << "}" << endl; outfile << "END_PROLOG" << endl; TCanvas *c2 = new TCanvas("c2","c2",900,600); xtalEnergy->Draw("colz text"); xtalEnergy->SetMarkerSize(1.5); xtalEnergy->SetMaximum(2500); xtalEnergy->SetMinimum(1700); TCanvas *c3 = new TCanvas("c3","c3",900,600); TGraph *g1 = new TGraph(54,index,mean); g1->SetMarkerStyle(20); g1->Draw("AP"); double avg=0; for(int i=0;i<54;i++){ if(mean[i]>0){ avg += mean[i]/54.; } } cout<<avg<<endl; TLine *linem5 = new TLine(0,0.95*avg,54,0.95*avg); TLine *linep5 = new TLine(0,1.05*avg,54,1.05*avg); linem5->SetLineWidth(2); linem5->SetLineStyle(7); linem5->SetLineColor(2); linep5->SetLineWidth(2); linep5->SetLineColor(2); linep5->SetLineStyle(7); linem5->Draw("same"); linep5->Draw("same"); TLine *line1 = new TLine(0,0.9*avg,54,0.9*avg); line1->SetLineWidth(2); line1->SetLineColor(4); line1->Draw("same"); TLine *line2 = new TLine(0,1.1*avg,54,1.1*avg); line2->SetLineWidth(2); line2->SetLineColor(4); line2->Draw("same"); TLegend *leg = new TLegend(0.7,0.1,0.9,0.3); leg->AddEntry(linem5,"#pm 5%","l"); leg->AddEntry(line1,"#pm 10%","l"); leg->Draw(); }
void TWC_for_draft() { //define variables //NoF: Number of File const Int_t NoF = 2; //want to divide charge from 80 to 160 for left, from 70 to 150 for right by 80 sectors const Int_t VTD_sector = 70; const Int_t CFD_sector = 80; Int_t start_time[NoF][2] = {{70, 50}, {80, 70}}; Double_t Tl[NoF]; Double_t Tr[NoF]; Double_t Al[NoF]; Double_t Ar[NoF]; /* Double_t slope[NoF][2] = {{0.}}; Double_t intercept[NoF][2] = {{0.}}; */ const char* file_name[NoF] = {"VTD_data_to_tree_t4.root", "CFD_data_to_tree_t4.root"}; const char* xtitle[2] = {"Q_{L} (Ch.)", "Q_{R} (Ch.)"}; const char* ytitle[2] = {"t_{L} (ns)", "t_{R} (ns)"}; const char* logoname[NoF][2] = {{"(a)", "(b)"}, {"(c)", "(d)"}}; const char* discname[NoF] = {"VTD", "CFD"}; Double_t VTD_mean[2][VTD_sector] = {{0.}}; Double_t VTD_entry[2][VTD_sector] = {{0.}}; Double_t VTD_variance[2][VTD_sector] = {{0.}}; Double_t CFD_mean[2][CFD_sector] = {{0.}}; Double_t CFD_entry[2][CFD_sector] = {{0.}}; Double_t CFD_variance[2][CFD_sector] = {{0.}}; Double_t VTD_xl[VTD_sector] = {0.}; Double_t VTD_yl[VTD_sector] = {0.}; Double_t VTD_xlE[VTD_sector] = {0.}; Double_t VTD_ylE[VTD_sector] = {0.}; Double_t VTD_xr[VTD_sector] = {0.}; Double_t VTD_yr[VTD_sector] = {0.}; Double_t VTD_xrE[VTD_sector] = {0.}; Double_t VTD_yrE[VTD_sector] = {0.}; Double_t CFD_xl[CFD_sector] = {0.}; Double_t CFD_yl[CFD_sector] = {0.}; Double_t CFD_xlE[CFD_sector] = {0.}; Double_t CFD_ylE[CFD_sector] = {0.}; Double_t CFD_xr[CFD_sector] = {0.}; Double_t CFD_yr[CFD_sector] = {0.}; Double_t CFD_xrE[CFD_sector] = {0.}; Double_t CFD_yrE[CFD_sector] = {0.}; //define input and output TFile* fin[NoF]; TTree* treein[NoF]; TCanvas* c[NoF][2]; TCanvas* cfit[NoF][2]; // cfit->Divide(2, 2, 0.005, 0.005); TH1F* VTD_h[2][VTD_sector]; TH1F* CFD_h[2][CFD_sector]; TGraphErrors* ge[NoF][2]; TLegend* logoleg[NoF][2]; TLegend* discleg[NoF][2]; for(Int_t i = 0; i < NoF; i ++) { fin[i] = new TFile(file_name[i]); treein[i] = (TTree*) fin[i]->Get("50cm"); treein[i]->SetBranchAddress("Tl", &Tl[i]); treein[i]->SetBranchAddress("Tr", &Tr[i]); treein[i]->SetBranchAddress("Al", &Al[i]); treein[i]->SetBranchAddress("Ar", &Ar[i]); for(Int_t j = 0; j < 2; j++) { c[i][j] = new TCanvas(Form("c_%d_%d", i, j), "", 100, 0, 1800, 1800); c[i][j]->Divide(8, 9); cfit[i][j] = new TCanvas(Form("cfit_%d_%d", i, j), "", 100, 0, 600, 600); logoleg[i][j] = new TLegend(0.25, 0.75, 0.35, 0.85); logoleg[i][j]->SetFillStyle(0); logoleg[i][j]->SetFillColor(0); logoleg[i][j]->SetBorderSize(0); logoleg[i][j]->SetTextSize(0.07); logoleg[i][j]->SetMargin(0); discleg[i][j] = new TLegend(0.75, 0.2, 0.95, 0.3); discleg[i][j]->SetFillStyle(0); discleg[i][j]->SetFillColor(0); discleg[i][j]->SetBorderSize(0); discleg[i][j]->SetTextSize(0.075); discleg[i][j]->SetMargin(0); // discleg[i][j]->SetTextAngle(-90); //i == 0: VTD, i == 1: CFD if(i == 0) { for(Int_t k = 0; k < VTD_sector; k++) { //define histogram VTD_h[j][k] = new TH1F(Form("VTD_h_%d_%d", j, k), "", 30, 5, 20); //fill tree to histogram and draw //j == 0: left, j == 1: right if(j == 0) { treein[i]->Project(Form("VTD_h_%d_%d", j, k), "Tl", Form("Al>%d&&Al<=%d&&Tl<50", start_time[i][j]+k, start_time[i][j]+k+1)); } else { treein[i]->Project(Form("VTD_h_%d_%d", j, k), "Tr", Form("Ar>%d&&Ar<=%d&&Tr<50", start_time[i][j]+k, start_time[i][j]+k+1)); } c[i][j]->cd(k+1); VTD_h[j][k]->Draw(); VTD_mean[j][k] = VTD_h[j][k]->GetMean(); VTD_entry[j][k] = VTD_h[j][k]->GetEntries(); for(Int_t l = 0; l < 4000; l++) { treein[i]->GetEntry(l); if(j == 0) { if(Al[i]>start_time[i][j]+k && Al[i]<=start_time[i][j]+k+1) { VTD_variance[j][k] = VTD_variance[j][k]+(Tl[i]-VTD_mean[j][k])*(Tl[i]-VTD_mean[j][k])/VTD_entry[j][k]; } } else { if(Ar[i]>start_time[i][j]+k && Ar[i]<=start_time[i][j]+k+1) { VTD_variance[j][k] = VTD_variance[j][k]+(Tr[i]-VTD_mean[j][k])*(Tr[i]-VTD_mean[j][k])/VTD_entry[j][k]; } } } if(j == 0) { VTD_xl[k] = (double)start_time[i][j]+(double)k+0.5; VTD_yl[k] = VTD_mean[j][k]; VTD_ylE[k] = TMath::Sqrt(VTD_variance[j][k]/(VTD_entry[j][k]-1)); } else { VTD_xr[k] = (double)start_time[i][j]+(double)k+0.5; VTD_yr[k] = VTD_mean[j][k]; VTD_yrE[k] = TMath::Sqrt(VTD_variance[j][k]/(VTD_entry[j][k]-1)); } } //end of k loop if(j == 0) ge[i][j] = new TGraphErrors(VTD_sector, VTD_xl, VTD_yl, VTD_xlE, VTD_ylE); else ge[i][j] = new TGraphErrors(VTD_sector, VTD_xr, VTD_yr, VTD_xrE, VTD_yrE); } else { for(Int_t k = 0; k < CFD_sector; k++) { CFD_h[j][k] = new TH1F(Form("CFD_h_%d_%d", j, k), "", 30, 5, 20); if(j == 0) { treein[i]->Project(Form("CFD_h_%d_%d", j, k), "Tl", Form("Al>%d&&Al<=%d&&Tl<50", start_time[i][j]+k, start_time[i][j]+k+1)); } else { treein[i]->Project(Form("CFD_h_%d_%d", j, k), "Tr", Form("Ar>%d&&Ar<=%d&&Tr<50", start_time[i][j]+k, start_time[i][j]+k+1)); } c[i][j]->cd(k+1); CFD_h[j][k]->Draw(); CFD_mean[j][k] = CFD_h[j][k]->GetMean(); CFD_entry[j][k] = CFD_h[j][k]->GetEntries(); for(Int_t l = 0; l < 4000; l++) { treein[i]->GetEntry(l); if(j == 0) { if(Al[i]>start_time[i][j]+k && Al[i]<=start_time[i][j]+k+1) { CFD_variance[j][k] = CFD_variance[j][k]+(Tl[i]-CFD_mean[j][k])*(Tl[i]-CFD_mean[j][k])/CFD_entry[j][k]; } } else { if(Ar[i]>start_time[i][j]+k && Ar[i]<=start_time[i][j]+k+1) { CFD_variance[j][k] = CFD_variance[j][k]+(Tr[i]-CFD_mean[j][k])*(Tr[i]-CFD_mean[j][k])/CFD_entry[j][k]; } } } if(j == 0) { CFD_xl[k] = (double)start_time[i][j]+(double)k+0.5; CFD_yl[k] = CFD_mean[j][k]; CFD_ylE[k] = TMath::Sqrt(CFD_variance[j][k]/(CFD_entry[j][k]-1)); } else { CFD_xr[k] = (double)start_time[i][j]+(double)k+0.5; CFD_yr[k] = CFD_mean[j][k]; CFD_yrE[k] = TMath::Sqrt(CFD_variance[j][k]/(CFD_entry[j][k]-1)); } } //end of k loop if(j == 0) ge[i][j] = new TGraphErrors(CFD_sector, CFD_xl, CFD_yl, CFD_xlE, CFD_ylE); else ge[i][j] = new TGraphErrors(CFD_sector, CFD_xr, CFD_yr, CFD_xrE, CFD_yrE); } //draw histogram and get mean and entry from the histogram //calculate variance //put values for TgraphErrors // cfit->cd(i*2+j+1); cfit[i][j]->cd(); cfit[i][j]->SetMargin(0.12, 0.05, 0.13, 0.05); /* cfit[i][j]->SetLeftMargin(0.15); cfit[i][j]->SetBottomMargin(0.15); */ ge[i][j]->SetTitle(""); ge[i][j]->GetYaxis()->SetRangeUser(0, 25); ge[i][j]->GetXaxis()->SetTitle(xtitle[j]); ge[i][j]->GetYaxis()->SetTitle(ytitle[j]); ge[i][j]->GetXaxis()->SetTitleSize(0.06); ge[i][j]->GetYaxis()->SetTitleSize(0.06); ge[i][j]->GetXaxis()->SetTitleOffset(0.9); ge[i][j]->GetYaxis()->SetTitleOffset(0.85); ge[i][j]->GetXaxis()->CenterTitle(); ge[i][j]->GetYaxis()->CenterTitle(); ge[i][j]->GetXaxis()->SetLabelSize(0.055); ge[i][j]->GetYaxis()->SetLabelSize(0.055); ge[i][j]->Draw("AP"); ge[i][j]->Fit("pol1"); /* slope[j] = ge[j]->GetFunction("pol1")->GetParameter(1); intercept[j] = ge[j]->GetFunction("pol1")->GetParameter(0); TWCleg[j]->AddEntry(ge[j], Form("y = %.4fx+%.4f", slope[j], intercept[j]), "1"); TWCleg[j]->Draw(); */ logoleg[i][j]->AddEntry(ge[i][j], logoname[i][j], "1"); logoleg[i][j]->Draw(); discleg[i][j]->AddEntry(ge[i][j], discname[i], "1"); discleg[i][j]->Draw(); cfit[i][j]->SaveAs(Form("fig_04_%d_%d.pdf", i, j)); } //end of j loop } //end of i loop // cfit[j]->SaveAs(Form("TWC_VTD_%d.pdf", j)); }
void DrawTwoInPad(TVirtualPad* p, Int_t sub, TH1* h1, TH1* h2, Bool_t ratio, Bool_t logy=false, Bool_t legend=false) { TVirtualPad* pp = p->cd(sub); pp->SetRightMargin(0.02); pp->SetLeftMargin(0.10); TVirtualPad* ppp = pp; if (ratio) { pp->Divide(1,2,0,0); ppp = pp->cd(1); ppp->SetRightMargin(0.02); } if (logy) ppp->SetLogy(); TH1* hs[] = { h1, h2, 0 }; if (h1->GetMaximum() < h2->GetMaximum()) { hs[0] = h2; hs[1] = h1; } TH1** ph = hs; Double_t size = (ratio ? 0.1 : 0.05); Double_t off = (ratio ? 0.6 : 0.5); h1->SetFillStyle(3004); h2->SetFillStyle(3005); while (*ph) { TString opt("hist"); if (ph != hs) opt.Append(" same"); TH1* copy = (*ph)->DrawCopy(opt); copy->GetXaxis()->SetLabelSize(2*size); copy->GetYaxis()->SetLabelSize(size); copy->GetYaxis()->SetTitleSize(size); copy->GetYaxis()->SetTitleOffset(off); copy->SetYTitle(copy->GetTitle()); copy->SetTitle(""); copy->SetDirectory(0); ph++; } TString s1 = h1->GetYaxis()->GetTitle(); TString s2 = h2->GetYaxis()->GetTitle(); if (legend) { TLegend* l = new TLegend(0.6, 0.1, 0.9, 0.9); l->SetBorderSize(0); TLegendEntry* e = l->AddEntry("dummy", s1, "lf"); l->SetFillColor(kWhite); e->SetFillColor(kBlack); e->SetFillStyle(h1->GetFillStyle()); e = l->AddEntry("dummy", s2, "lf"); e->SetFillColor(kBlack); e->SetFillStyle(h2->GetFillStyle()); l->Draw(); } if (!ratio) return; ppp = pp->cd(2); ppp->SetRightMargin(0.02); TH1* r = static_cast<TH1*>(h1->Clone(Form("ratio%s", h1->GetName()))); r->SetDirectory(0); r->SetTitle(""); r->GetXaxis()->SetLabelSize(size); r->GetYaxis()->SetLabelSize(size); r->GetYaxis()->SetTitleSize(0.9*size); r->GetYaxis()->SetTitleOffset(0.9*off); r->SetMarkerStyle(20); r->SetMarkerColor(h1->GetFillColor()+1); r->SetFillStyle(3007); r->SetYTitle(Form("#frac{%s}{%s}", s1.Data(), s2.Data())); // r->Add(h2, -1); // r->Divide(h1); if (!r->IsA()->InheritsFrom(TProfile::Class())) { r->GetSumw2()->Set(0); // r->Sumw2(false); h2->GetSumw2()->Set(0); // h2->Sumw2(false); } r->Divide(h2); Printf("%s", r->GetName()); for (UShort_t bin = 1; bin <= r->GetNbinsX(); bin++) { Printf(" bin # %2d: Diff=%g+/-%g", bin, r->GetBinContent(bin), r->GetBinError(bin)); r->SetBinError(bin, 0); } r->GetSumw2()->Set(0); //r->Sumw2(false); r->SetMarkerSize(4); r->SetMaximum(r->GetMaximum()*1.2); r->SetMinimum(r->GetMinimum()*0.8); r->Draw("hist text30"); p->Modified(); p->Update(); p->cd(); }
void plotV2vstheta(){ TFile *f; int isSum=0; const int ntotbin=5; const int trkpointmin[ntotbin] = {120,150,185,220,260}; const int trkpointmax[ntotbin] = {150,185,220,260,300}; int trkbin=1; int xbin=0; c1 = new TCanvas("c1"," ",1200,700); makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetErrorX(0); TH1D *hFrame = new TH1D("","",100,0,2); hFrame->SetTitle(""); hFrame->GetXaxis()->SetTitle("#theta"); hFrame->GetYaxis()->SetTitle("reference V_{2}"); hFrame->GetYaxis()->SetTitleOffset(1.1); hFrame->GetXaxis()->SetTitleSize(0.04); hFrame->GetYaxis()->SetTitleSize(0.04); hFrame->GetXaxis()->SetRangeUser(0,1.5); hFrame->SetMinimum(0.030); hFrame->SetMaximum(0.065); for(int trkbin=0;trkbin<ntotbin; trkbin++){ if(isSum==0){ f = TFile::Open(Form("M%d%d/mergedV_Prod.root",trkpointmax[trkbin],trkpointmin[trkbin])); } else{ f = TFile::Open(Form("M%d%d/mergedV_Sum.root",trkpointmax[trkbin],trkpointmin[trkbin])); } TVectorD* vecVmean = (TVectorD*)f->Get(Form("D_%d/Vmean",xbin)); TVectorD* vecV = (TVectorD*)f->Get(Form("D_%d/D_0/V",xbin)); double Vmean = (*vecVmean)[0]; double *V = vecV->GetMatrixArray(); double theta[ntheta]; for(int itheta=0;itheta<ntheta;itheta++){ theta[itheta]=itheta*TMath::Pi()/ntheta/nn; } int maxper10 = findmaxper(V,ntheta,Vmean); double maxper = (double)(maxper10+1)/10; c1->cd(trkbin+1); hFrame->Draw(); TGraph *gV2theta = new TGraph(ntheta,theta,V); gV2theta->SetMarkerStyle(20); gV2theta->SetMarkerSize(1.3); gV2theta->SetMarkerColor(1); gV2theta->SetLineColor(1); gV2theta->Draw("Psame"); TLine *lup = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1+maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1+maxper)); TLine *ldown = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1-maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1-maxper)); TLine *l = new TLine(hFrame->GetXaxis()->GetXmin(),Vmean, hFrame->GetXaxis()->GetXmax(),Vmean); l->SetLineStyle(2); lup->SetLineStyle(2); ldown->SetLineStyle(2); l->SetLineWidth(1.2); lup->SetLineWidth(1.2); ldown->SetLineWidth(1.2); TLatex *tl = new TLatex(); // tl->SetNDC(); tl->SetTextFont(42); tl->SetTextSize(0.04); // tl->SetBorderStyle(0); tl->DrawLatex(0,Vmean*(1+maxper),Form("mean up %.f%%",maxper*100)); tl->DrawLatex(0,Vmean*(1-maxper),Form("mean down %.f%%",maxper*100)); tl->SetNDC(); tl->DrawLatex(0.7,0.85,Form("Multiplicity %d to %d",trkpointmin[trkbin],trkpointmax[trkbin])); l->Draw("same"); lup->Draw("same"); ldown->Draw("same"); } c1->cd(ntotbin+1); TLatex *tlx0 = new TLatex(0.12,0.3,Form("PF candi, use p_{T} weight")); TLatex *tlx1 = new TLatex(0.12,0.25,Form("%.1f<p_{T}<%.1f (GeV/c)",0.3,6.0)); tlx0->SetNDC(); tlx1->SetNDC(); tlx0->SetTextSize(0.045); tlx1->SetTextSize(0.045); hFrame->Draw(); tlx0->Draw("same"); tlx1->Draw("same"); if(isSum==0)c1->SaveAs("hV2theta_Prod.png"); else c1->SaveAs("hV2theta_Sum.png"); }
void fullPedestalAnalysis(string inputDIR, string outputDIR, string inputCablingMap, string outputFileName){ gROOT->ProcessLine("gErrorIgnoreLevel = 1"); // open the file and prepare the cluster tree, adding the other trees as frined --> memory consuming std::cout<<"##################################"<<std::endl; std::cout<<"###### fullPedestalAnalysis ######"<<std::endl; std::cout<<"##################################"<<std::endl; clock_t tStart = clock(); // prepare style and load macros setTDRStyle(); gROOT->SetBatch(kTRUE); system(("mkdir -p "+outputDIR).c_str()); ifstream file; std::cout<<"### Make input file list"<<std::endl; system(("find "+inputDIR+" -name \"*.root\" > file.temp").c_str()); std::ifstream infile; string line; vector<string> fileList; infile.open("file.temp",ifstream::in); if(infile.is_open()){ while(!infile.eof()){ getline(infile,line); if(line != "" and TString(line).Contains(".root") and line !="\n"){ fileList.push_back(line); } } } system("rm file.temp"); std::sort(fileList.begin(),fileList.end()); TFile* cablingFile = TFile::Open(inputCablingMap.c_str(),"READ"); cablingFile->cd(); TTree* readoutMap = (TTree*) cablingFile->FindObjectAny("readoutMap"); TTreeReader reader(readoutMap); TTreeReaderValue<uint32_t> detid (reader,"detid"); TTreeReaderValue<uint16_t> fecCrate (reader,"fecCrate"); TTreeReaderValue<uint16_t> fecSlot (reader,"fecSlot"); TTreeReaderValue<uint16_t> fecRing (reader,"fecRing"); TTreeReaderValue<uint16_t> ccuAdd (reader,"ccuAdd"); TTreeReaderValue<uint16_t> ccuChan (reader,"ccuChan"); TTreeReaderValue<uint16_t> lldChannel (reader,"lldChannel"); TTreeReaderValue<uint16_t> fedId (reader,"fedId"); TTreeReaderValue<uint16_t> fedCh (reader,"fedCh"); // output tree TFile* ouputTreeFile = new TFile((outputDIR+"/"+outputFileName).c_str(),"RECREATE"); ouputTreeFile->cd(); ouputTreeFile->SetCompressionLevel(0); TTree* outputTree = new TTree("pedestalFullNoise","pedestalFullNoise"); // branches uint32_t detid_,fedKey_; uint16_t fecCrate_,fecSlot_, fecRing_, ccuAdd_, ccuChan_, lldChannel_, fedId_, fedCh_, apvId_, stripId_; float noiseMean_,noiseRMS_, noiseSkewness_, noiseKurtosis_; float fitChi2_, fitChi2Probab_, fitStatus_; float fitGausMean_, fitGausSigma_, fitGausNormalization_; float fitGausMeanError_, fitGausSigmaError_, fitGausNormalizationError_; float noiseIntegral3Sigma_, noiseIntegral3SigmaFromFit_; float noiseIntegral4Sigma_, noiseIntegral4SigmaFromFit_; float noiseIntegral5Sigma_, noiseIntegral5SigmaFromFit_; float kSValue_, kSProbab_, jBValue_, jBProbab_, aDValue_, aDProbab_; vector<float> noiseDistribution_, noiseDistributionError_; float xMin_, xMax_, nBin_ ; outputTree->Branch("detid",&detid_,"detid/i"); outputTree->Branch("fedKey",&fedKey_,"fedKey/i"); outputTree->Branch("fecCrate",&fecCrate_,"fecCrate/s"); outputTree->Branch("fecSlot",&fecSlot_,"fecSlot/s"); outputTree->Branch("fecRing",&fecRing_,"fecRing/s"); outputTree->Branch("ccuAdd",&ccuAdd_,"ccuAdd/s"); outputTree->Branch("ccuChan",&ccuChan_,"ccuChan/s"); outputTree->Branch("lldChannel",&lldChannel_,"lldChannel/s"); outputTree->Branch("fedId",&fedId_,"fedId/s"); outputTree->Branch("fedCh",&fedCh_,"fedCh/s"); outputTree->Branch("apvId",&apvId_,"apvId/s"); outputTree->Branch("stripId",&stripId_,"stripId/s"); outputTree->Branch("noiseMean",&noiseMean_,"noiseMean/F"); outputTree->Branch("noiseRMS",&noiseRMS_,"noiseRMS/F"); outputTree->Branch("noiseSkewness",&noiseSkewness_,"noiseSkewness/F"); outputTree->Branch("noiseKurtosis",&noiseKurtosis_,"noiseKurtosis/F"); outputTree->Branch("fitGausNormalization",&fitGausNormalization_,"fitGausNormalization/F"); outputTree->Branch("fitGausMean",&fitGausMean_,"fitGausMean/F"); outputTree->Branch("fitGausSigma",&fitGausSigma_,"fitGausSigma/F"); outputTree->Branch("fitGausNormalizationError",&fitGausNormalizationError_,"fitGausNormalizationError/F"); outputTree->Branch("fitGausMeanError",&fitGausMeanError_,"fitGausMeanError/F"); outputTree->Branch("fitGausSigmaError",&fitGausSigmaError_,"fitGausSigmaError/F"); outputTree->Branch("fitChi2",&fitChi2_,"fitChi2/F"); outputTree->Branch("fitChi2Probab",&fitChi2Probab_,"fitChi2Probab/F"); outputTree->Branch("fitStatus",&fitStatus_,"fitStatus_F"); outputTree->Branch("noiseIntegral3Sigma",&noiseIntegral3Sigma_,"noiseIntegral3Sigma/F"); outputTree->Branch("noiseIntegral3SigmaFromFit",&noiseIntegral3SigmaFromFit_,"noiseIntegral3SigmaFromFit/F"); outputTree->Branch("noiseIntegral4Sigma",&noiseIntegral4Sigma_,"noiseIntegral4Sigma/F"); outputTree->Branch("noiseIntegral4SigmaFromFit",&noiseIntegral4SigmaFromFit_,"noiseIntegral4SigmaFromFit/F"); outputTree->Branch("noiseIntegral5Sigma",&noiseIntegral4Sigma_,"noiseIntegral5Sigma/F"); outputTree->Branch("noiseIntegral5SigmaFromFit",&noiseIntegral4SigmaFromFit_,"noiseIntegral5SigmaFromFit/F"); outputTree->Branch("kSValue",&kSValue_,"kSValue/F"); outputTree->Branch("jBValue",&jBValue_,"jBValue/F"); outputTree->Branch("aDValue",&aDValue_,"aDValue/F"); outputTree->Branch("kSProbab",&kSProbab_,"kSProbab/F"); outputTree->Branch("jBProbab",&jBProbab_,"jBProbab/F"); outputTree->Branch("aDProbab",&aDProbab_,"aDProbab/F"); outputTree->Branch("xMin",&xMin_,"xMin/F"); outputTree->Branch("xMax",&xMax_,"xMax/F"); outputTree->Branch("nBin",&nBin_,"nBin/F"); bool histoBranches = false; // Loop on the file list to extract each histogram 2D DQM histo with full noise distribution TH1F* histoNoiseStrip = NULL; TF1* fitFunc = NULL; TH1F* randomHisto = NULL; TFitResultPtr result; for(auto file : fileList){ cout<<"input file: "<<file<<endl; TFile* inputFile = TFile::Open(file.c_str(),"READ"); inputFile->cd(); // take into account that the DQM file structure for strips is always the same --> use cabling map to browse the histograms reader.SetEntry(0); TH2* histoNoise = NULL; long int iChannel = 0; int noFitResult = 0; while(reader.Next()){ cout.flush(); if(iChannel %10 == 0) cout<<"\r"<<"iChannel "<<100*double(iChannel)/(readoutMap->GetEntries()/reductionFactor)<<" % "; if(iChannel > double(readoutMap->GetEntries())/reductionFactor) break; iChannel++; TString objName; uint32_t fedKey = SiStripFedKey(*fedId,SiStripFedKey::feUnit(*fedCh),SiStripFedKey::feChan(*fedCh)).key(); std::stringstream stream; stream << std::hex << fedKey; string fedKeyStr = stream.str(); if(fedKeyStr.size() == 4) objName = Form("DQMData/SiStrip/ControlView/FecCrate%d/FecSlot%d/FecRing%d/CcuAddr%d/CcuChan%d/ExpertHisto_PedsFullNoise_FedKey0x0000%s_LldChannel%d_Noise2D",*fecCrate,*fecSlot,*fecRing,*ccuAdd,*ccuChan,fedKeyStr.c_str(),*lldChannel); else if(fedKeyStr.size() == 5) objName = Form("DQMData/SiStrip/ControlView/FecCrate%d/FecSlot%d/FecRing%d/CcuAddr%d/CcuChan%d/ExpertHisto_PedsFullNoise_FedKey0x000%s_LldChannel%d_Noise2D",*fecCrate,*fecSlot,*fecRing,*ccuAdd,*ccuChan,fedKeyStr.c_str(),*lldChannel); else cerr<<"hex number to short "<<fedKeyStr<<" --> please check "<<endl; inputFile->GetObject(objName.Data(),histoNoise); // extract single strip noise histogram --> loop on the y-axis uint16_t apvID = 0; uint16_t stripID = 0; if(histoNoiseStrip == 0 or histoNoiseStrip == NULL){ histoNoiseStrip = new TH1F ("histoNoiseStrip","",histoNoise->GetNbinsX(),histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax()); histoNoiseStrip->Sumw2(); } for(int iBinY = 0; iBinY < histoNoise->GetNbinsY(); iBinY++){ histoNoiseStrip->Reset(); histoNoiseStrip->SetDirectory(0); // two multiplexed APV per line if(iBinY < histoNoise->GetNbinsY()/2) apvID = 1; else apvID = 2; // strip id stripID++; if(stripID > 128) stripID = 1; // loop on x-axis bin for(int iBinX = 0; iBinX < histoNoise->GetNbinsX(); iBinX++){ histoNoiseStrip->SetBinContent(iBinX+1,histoNoise->GetBinContent(iBinX+1,iBinY+1)); histoNoiseStrip->SetBinError(iBinX+1,histoNoise->GetBinError(iBinX+1,iBinY+1)); } // to initialize branches detid_ = 0; fedKey_ = 0; fecCrate_ = 0; fecSlot_ = 0; fecRing_ = 0; ccuAdd_ = 0; ccuChan_ = 0; lldChannel_ = 0; fedId_ = 0; fedCh_ = 0; apvId_ = 0; stripId_ = 0; noiseMean_ = 0.; noiseRMS_ = 0.; noiseSkewness_ = 0.; noiseKurtosis_ = 0.; fitGausMean_ = 0.; fitGausSigma_ = 0.;fitGausNormalization_ = 0.; fitGausMeanError_ = 0.; fitGausSigmaError_ = 0.;fitGausNormalizationError_ = 0.; fitChi2_ = 0.; fitChi2Probab_ = 0.; fitStatus_ = -1.; noiseIntegral3Sigma_ = 0.; noiseIntegral3SigmaFromFit_ = 0.; noiseIntegral4Sigma_ = 0.; noiseIntegral4SigmaFromFit_ = 0.; noiseIntegral5Sigma_ = 0.; noiseIntegral5SigmaFromFit_ = 0.; kSProbab_ = 0.; jBProbab_ = 0.; kSValue_ = 0.; jBValue_ = 0.; aDValue_= 0.; aDProbab_ = 0.; nBin_ = 0.; xMin_ = 0.; xMax_ = 0.; // basic info detid_ = *detid; fedKey_ = fedKey; fecCrate_ = *fecCrate; fecSlot_ = *fecSlot; fecRing_ = *fecRing; ccuAdd_ = *ccuAdd; ccuChan_ = *ccuChan; lldChannel_ = *lldChannel; fedId_ = *fedId; fedCh_ = *fedCh; apvId_ = apvID; stripId_ = stripID; // basic info of nioise distribution noiseMean_ = histoNoiseStrip->GetMean(); noiseRMS_ = histoNoiseStrip->GetRMS(); noiseSkewness_ = histoNoiseStrip->GetSkewness(); noiseKurtosis_ = histoNoiseStrip->GetKurtosis(); float integral = histoNoiseStrip->Integral(); noiseIntegral3Sigma_ = (histoNoiseStrip->Integral(histoNoiseStrip->FindBin(noiseMean_+noiseRMS_*3),histoNoiseStrip->GetNbinsX()+1) + histoNoiseStrip->Integral(0,histoNoiseStrip->FindBin(noiseMean_-noiseRMS_*3)))/integral; noiseIntegral4Sigma_ = (histoNoiseStrip->Integral(histoNoiseStrip->FindBin(noiseMean_+noiseRMS_*4),histoNoiseStrip->GetNbinsX()+1) + histoNoiseStrip->Integral(0,histoNoiseStrip->FindBin(noiseMean_-noiseRMS_*4)))/integral; noiseIntegral5Sigma_ = (histoNoiseStrip->Integral(histoNoiseStrip->FindBin(noiseMean_+noiseRMS_*5),histoNoiseStrip->GetNbinsX()+1) + histoNoiseStrip->Integral(0,histoNoiseStrip->FindBin(noiseMean_-noiseRMS_*5)))/integral; // make a gaussian fit if(fitFunc == NULL or fitFunc == 0){ fitFunc = new TF1 ("fitFunc","gaus(0)",histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax()); } fitFunc->SetRange(histoNoise->GetXaxis()->GetXmin(),histoNoise->GetXaxis()->GetXmax()); fitFunc->SetParameters(histoNoiseStrip->Integral(),noiseMean_,noiseRMS_); result = histoNoiseStrip->Fit(fitFunc,"QSR"); if(result.Get()){ fitStatus_ = result->Status(); fitGausNormalization_ = fitFunc->GetParameter(0); fitGausMean_ = fitFunc->GetParameter(1); fitGausSigma_ = fitFunc->GetParameter(2); fitGausNormalizationError_ = fitFunc->GetParError(0); fitGausMeanError_ = fitFunc->GetParError(1); fitGausSigmaError_ = fitFunc->GetParError(2); fitChi2_ = result->Chi2(); fitChi2Probab_ = result->Prob(); noiseIntegral3SigmaFromFit_ = (histoNoiseStrip->Integral(histoNoiseStrip->FindBin(noiseMean_+fitGausSigma_*3),histoNoiseStrip->GetNbinsX()+1) + histoNoiseStrip->Integral(0,histoNoiseStrip->FindBin(noiseMean_-fitGausSigma_*3)))/histoNoiseStrip->Integral(); noiseIntegral4SigmaFromFit_ = (histoNoiseStrip->Integral(histoNoiseStrip->FindBin(noiseMean_+fitGausSigma_*4),histoNoiseStrip->GetNbinsX()+1) + histoNoiseStrip->Integral(0,histoNoiseStrip->FindBin(noiseMean_-fitGausSigma_*4)))/histoNoiseStrip->Integral(); noiseIntegral5SigmaFromFit_ = (histoNoiseStrip->Integral(histoNoiseStrip->FindBin(noiseMean_+fitGausSigma_*5),histoNoiseStrip->GetNbinsX()+1) + histoNoiseStrip->Integral(0,histoNoiseStrip->FindBin(noiseMean_-fitGausSigma_*5)))/histoNoiseStrip->Integral(); jBValue_ = (histoNoiseStrip->Integral()/6)*(noiseSkewness_*noiseSkewness_+(noiseKurtosis_*noiseKurtosis_)/4); jBProbab_ = ROOT::Math::chisquared_cdf_c(jBValue_,2); if(randomHisto == 0 or randomHisto == NULL) randomHisto = (TH1F*) histoNoiseStrip->Clone("randomHisto"); randomHisto->Reset(); randomHisto->SetDirectory(0); if(integral != 0){ if(generateRandomDistribution){ randomHisto->FillRandom("fitFunc",histoNoiseStrip->Integral()); kSValue_ = histoNoiseStrip->KolmogorovTest(randomHisto,"MN"); kSProbab_ = histoNoiseStrip->KolmogorovTest(randomHisto,"N"); aDValue_ = histoNoiseStrip->AndersonDarlingTest(randomHisto,"T"); aDProbab_ = histoNoiseStrip->AndersonDarlingTest(randomHisto); } else{ randomHisto->Add(fitFunc); kSValue_ = histoNoiseStrip->KolmogorovTest(randomHisto,"MN"); kSProbab_ = histoNoiseStrip->KolmogorovTest(randomHisto,"N"); // AD test ROOT::Fit::BinData data1; ROOT::Fit::BinData data2; ROOT::Fit::FillData(data1,histoNoiseStrip,0); data2.Initialize(randomHisto->GetNbinsX()+1,1); for(int ibin = 0; ibin < randomHisto->GetNbinsX(); ibin++){ if(histoNoiseStrip->GetBinContent(ibin+1) != 0 or randomHisto->GetBinContent(ibin+1) >= 1) data2.Add(randomHisto->GetBinCenter(ibin+1),randomHisto->GetBinContent(ibin+1),randomHisto->GetBinError(ibin+1)); } double probab; double value; ROOT::Math::GoFTest::AndersonDarling2SamplesTest(data1,data2,probab,value); aDValue_ = value; aDProbab_ = probab; } } } else noFitResult++; if(not histoBranches){ noiseDistribution_.clear(); noiseDistributionError_.clear(); outputTree->Branch("noiseDistribution","vector<float>",&noiseDistribution_); outputTree->Branch("noiseDistributionError","vector<float>",&noiseDistributionError_); histoBranches = true; } // set histogram noiseDistribution_.clear(); noiseDistributionError_.clear(); for(int iBin = 0; iBin < histoNoiseStrip->GetNbinsX(); iBin++){ noiseDistribution_.push_back(histoNoiseStrip->GetBinContent(iBin+1)); noiseDistributionError_.push_back(histoNoiseStrip->GetBinError(iBin+1)); } nBin_ = histoNoiseStrip->GetNbinsX(); xMin_ = histoNoise->GetXaxis()->GetBinLowEdge(1); xMax_ = histoNoise->GetXaxis()->GetBinLowEdge(histoNoise->GetNbinsX()+1); // fill all branches for each strip ouputTreeFile->cd(); outputTree->Fill(); } } inputFile->Close(); std::cout<<std::endl; cout<<"No fit results found for "<<100*double(noFitResult)/iChannel<<endl; } outputTree->BuildIndex("detid"); outputTree->Write(outputTree->GetName(),TObject::kOverwrite); ouputTreeFile->Close(); cablingFile->Close(); /* Do your stuff here */ cout<<"Time taken: "<<(double)(clock() - tStart)/CLOCKS_PER_SEC<<endl; }
void MUONChamberMaterialBudget(const char* geoFilename = "geometry.root", Int_t segmentationLevel = 1) { /// Draw the local chamber thickness over x0 (x/x0) used in the computation of Multiple Coulomb Scattering effets. /// Compute <x> and <x/x0> in a limited area (displayed on the histograms) to avoid edge effets. /// The resolution can be changed by changing the sementation level: resolution = 1 cm / segmentationLevel. const char* chamberName[10] = {"SC01", "SC02", "SC03", "SC04", "SC05", "SC06", "SC07", "SC08", "SC09", "SC10"}; Double_t OneOverX0MeanCh[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; Double_t totalLengthCh[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; Double_t OneOverX0Mean = 0.; Double_t totalLength = 0.; // Import TGeo geometry if (!gGeoManager) { TGeoManager::Import(geoFilename); if (!gGeoManager) { cout<<"getting geometry from file geometry.root failed"<<endl; return; } } // z intervals where to find the stations Double_t zIn[5] = {-510., -600., -800., -1150., -1350.}; Double_t zOut[5] = {-600., -800., -1150., -1350., -1470.}; // transverse area where to compute locally x and x/x0 Double_t xIn0[5] = {0., 0., 0., 0., 0.}; Double_t yIn0[5] = {0., 0., 0., 0., 0.}; Int_t ixMax[5] = {90, 120, 165, 250, 260}; Int_t iyMax[5] = {90, 120, 180, 250, 270}; // transverse area where to compute <x> and <x/x0> for each chamber Double_t xIn0ForMean[5] = { 5., 5., 35., 40., 40.}; Double_t yIn0ForMean[5] = {20., 25., 0., 0., 0.}; Int_t ixMaxForMean[5] = { 50, 65, 85, 120, 160 }; Int_t iyMaxForMean[5] = { 60, 70, 110, 150, 150 }; // define output histograms gStyle->SetPalette(1); TFile *f = TFile::Open("MaterialBudget.root","RECREATE"); TH2F* hXOverX0[10]; TBox* bXOverX0[10]; for (Int_t i=0; i<10; i++) { Int_t st = i/2; hXOverX0[i] = new TH2F(Form("hXOverX0_%d",i+1), Form("x/x0 on ch %d (%%)",i+1), segmentationLevel*ixMax[st], xIn0[st], xIn0[st]+ixMax[st], segmentationLevel*iyMax[st], yIn0[st], yIn0[st]+iyMax[st]); hXOverX0[i]->SetOption("COLZ"); hXOverX0[i]->SetStats(kFALSE); bXOverX0[i] = new TBox(xIn0ForMean[st], yIn0ForMean[st], xIn0ForMean[st]+ixMaxForMean[st], yIn0ForMean[st]+iyMaxForMean[st]); bXOverX0[i]->SetLineStyle(2); bXOverX0[i]->SetLineWidth(2); bXOverX0[i]->SetFillStyle(0); hXOverX0[i]->GetListOfFunctions()->Add(bXOverX0[i]); } // loop over stations for (Int_t ist=0; ist<5; ist++) { Int_t nPoints = 0; // loop over position in non bending direction (by step of 1cm) for (Int_t ix=0; ix<segmentationLevel*ixMax[ist]; ix++) { Double_t xIn = xIn0[ist] + ((Double_t)ix+0.5) / ((Double_t)segmentationLevel); // loop over position in bending direction (by step of 1cm) for (Int_t iy=0; iy<segmentationLevel*iyMax[ist]; iy++) { Int_t permilDone = 1000 * (ix * segmentationLevel*iyMax[ist] + iy + 1) / (segmentationLevel*segmentationLevel*ixMax[ist]*iyMax[ist]); if (permilDone%10 == 0) cout<<"\rStation "<<ist+1<<": processing... "<<permilDone/10<<"%"<<flush; Double_t yIn = yIn0[ist] + ((Double_t)iy+0.5) / ((Double_t)segmentationLevel); // Initialize starting point and direction Double_t trackXYZIn[3] = {xIn, yIn, zIn[ist]}; Double_t trackXYZOut[3] = {1.000001*xIn, 1.000001*yIn, zOut[ist]}; Double_t pathLength = TMath::Sqrt((trackXYZOut[0] - trackXYZIn[0])*(trackXYZOut[0] - trackXYZIn[0])+ (trackXYZOut[1] - trackXYZIn[1])*(trackXYZOut[1] - trackXYZIn[1])+ (trackXYZOut[2] - trackXYZIn[2])*(trackXYZOut[2] - trackXYZIn[2])); Double_t b[3]; b[0] = (trackXYZOut[0] - trackXYZIn[0]) / pathLength; b[1] = (trackXYZOut[1] - trackXYZIn[1]) / pathLength; b[2] = (trackXYZOut[2] - trackXYZIn[2]) / pathLength; TGeoNode *currentnode = gGeoManager->InitTrack(trackXYZIn, b); if (!currentnode) break; Bool_t OK = kTRUE; Double_t x0 = 0.; // radiation-length (cm-1) Double_t localOneOverX0MeanCh[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; Double_t localTotalLengthCh[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; Double_t localPathLength = 0.; Double_t remainingPathLength = pathLength; do { // Get material properties TGeoMaterial *material = currentnode->GetVolume()->GetMedium()->GetMaterial(); TString currentNodePath(gGeoManager->GetPath()); x0 = material->GetRadLen(); // Get path length within this material gGeoManager->FindNextBoundary(remainingPathLength); localPathLength = gGeoManager->GetStep() + 1.e-6; // Check if boundary within remaining path length. // If so, make sure to cross the boundary to prepare the next step if (localPathLength >= remainingPathLength) localPathLength = remainingPathLength; else { currentnode = gGeoManager->Step(); if (!currentnode) { OK = kFALSE; break; } if (!gGeoManager->IsEntering()) { // make another small step to try to enter in new slice gGeoManager->SetStep(0.001); currentnode = gGeoManager->Step(); if (!gGeoManager->IsEntering() || !currentnode) { OK = kFALSE; break; } localPathLength += 0.001; } } remainingPathLength -= localPathLength; // check if entering a chamber of the current station or go to next step Int_t chId; if (currentNodePath.Contains(chamberName[2*ist])) chId = 2*ist; else if (currentNodePath.Contains(chamberName[2*ist+1])) chId = 2*ist+1; else continue; // add current material budget localOneOverX0MeanCh[chId] += localPathLength / x0; localTotalLengthCh[chId] += localPathLength; } while (remainingPathLength > TGeoShape::Tolerance()); // account for the local material characteristic if computed successfully if (OK) { // fill histograms in the full space hXOverX0[2*ist]->Fill(xIn,yIn,100.*localOneOverX0MeanCh[2*ist]); hXOverX0[2*ist+1]->Fill(xIn,yIn,100.*localOneOverX0MeanCh[2*ist+1]); // computation of <x> and <x/x0> in a limited chamber region if (xIn > xIn0ForMean[ist] && xIn < xIn0ForMean[ist]+1.*ixMaxForMean[ist] && yIn > yIn0ForMean[ist] && yIn < yIn0ForMean[ist]+1.*iyMaxForMean[ist]) { nPoints++; OneOverX0MeanCh[2*ist] += localOneOverX0MeanCh[2*ist]; OneOverX0MeanCh[2*ist+1] += localOneOverX0MeanCh[2*ist+1]; totalLengthCh[2*ist] += localTotalLengthCh[2*ist]; totalLengthCh[2*ist+1] += localTotalLengthCh[2*ist+1]; } } } } cout<<"\rStation "<<ist+1<<": processing... 100%"<<endl; // normalize <x> and <x/x0> to the number of data points for (Int_t i=2*ist; i<=2*ist+1; i++) { OneOverX0MeanCh[i] /= (Double_t) nPoints; totalLengthCh[i] /= (Double_t) nPoints; } } // print results cout<<endl<<endl; cout<<"chamber thickness (cm) x/x0 (%)"<<endl; cout<<"------------------------------------"<<endl; for (Int_t i=0; i<10; i++) { printf(" %2d %4.2f %4.2f\n",i+1,totalLengthCh[i],100.*OneOverX0MeanCh[i]); totalLength += totalLengthCh[i]; OneOverX0Mean += OneOverX0MeanCh[i]; } cout<<"------------------------------------"<<endl; printf(" tot %4.1f %4.1f\n",totalLength,100.*OneOverX0Mean); cout<<endl; // save histograms f->Write(); f->Close(); }
void getResv2(){ ifstream f_("merged.root"); if(!f_.good()){ system("hadd merged.root /scratch/xuq7/flow/EPAnalyzer/pPbDataV205m100/Varmults5b5/AnaEP_*.root"); } TFile *fmerged = TFile::Open("merged.root"); TH1D* hEPPhip[nbin][neta]; TH1D* hEPPhin[nbin][neta]; TH1D* hEPPhic[nbin][neta]; for(int ibin=0;ibin<nbin;ibin++){ for(int ieta=0;ieta<neta;ieta++){ hEPPhip[ibin][ieta] = (TH1D*)fmerged->Get(Form("hEPPhip_%d_%d",ibin,ieta)); hEPPhin[ibin][ieta] = (TH1D*)fmerged->Get(Form("hEPPhin_%d_%d",ibin,ieta)); hEPPhic[ibin][ieta] = (TH1D*)fmerged->Get(Form("hEPPhic_%d_%d",ibin,ieta)); } } ofstream fstrV; fstrV.open("v2.txt"); TFile *f[nFileAll]; TVectorD Nevent; Nevent.ResizeTo(nbin); Nevent.Zero(); TVectorD totmultall; totmultall.ResizeTo(nbin); totmultall.Zero(); TVectorD EPR[nbin], EPRpc[nbin], EPRpm[nbin], EPRcm[nbin]; for(int ibin=0;ibin<nbin;ibin++){ EPR[ibin].ResizeTo(neta); EPR[ibin].Zero(); EPRpc[ibin].ResizeTo(neta); EPRpc[ibin].Zero(); EPRpm[ibin].ResizeTo(neta); EPRpm[ibin].Zero(); EPRcm[ibin].ResizeTo(neta); EPRcm[ibin].Zero(); } TVectorD avgmult; avgmult.ResizeTo(nbin); TVectorD totmult[nbin], totpt[nbin], avgpt[nbin]; TVectorD Vobs[nbin][neta], Vcorr[nbin][neta], Vcorr3[nbin][neta]; TVectorD totmultp[nbin][neta], totmultn[nbin][neta], totmultc[nbin][neta]; for(int ibin=0;ibin<nbin;ibin++){ totmult[ibin].ResizeTo(npt); totmult[ibin].Zero(); totpt[ibin].ResizeTo(npt); totpt[ibin].Zero(); avgpt[ibin].ResizeTo(npt); avgpt[ibin].Zero(); for(int ieta=0;ieta<neta;ieta++){ Vobs[ibin][ieta].ResizeTo(npt); Vobs[ibin][ieta].Zero(); totmultp[ibin][ieta].ResizeTo(npt); totmultp[ibin][ieta].Zero(); totmultn[ibin][ieta].ResizeTo(npt); totmultn[ibin][ieta].Zero(); totmultc[ibin][ieta].ResizeTo(npt); totmultc[ibin][ieta].Zero(); Vcorr[ibin][ieta].ResizeTo(npt); Vcorr[ibin][ieta].Zero(); Vcorr3[ibin][ieta].ResizeTo(npt); Vcorr3[ibin][ieta].Zero(); } } for(int ifile=0; ifile<nFileAll; ifile++){ f[ifile] = TFile::Open(Form("/scratch/xuq7/flow/EPAnalyzer/pPbDataV205m100/Varmults5b5/AnaEP_%d.root",ifile)); TVectorD* Nevent_t = (TVectorD*)f[ifile]->Get(Form("Nevent")); TVectorD* totmultall_t = (TVectorD*)f[ifile]->Get(Form("totmultall")); for(int ibin=0;ibin<nbin;ibin++){ TVectorD* EPR_t = (TVectorD*)f[ifile]->Get(Form("EPR_%d",ibin)); TVectorD* EPRpc_t = (TVectorD*)f[ifile]->Get(Form("EPRpc_%d",ibin)); TVectorD* EPRpm_t = (TVectorD*)f[ifile]->Get(Form("EPRpm_%d",ibin)); TVectorD* EPRcm_t = (TVectorD*)f[ifile]->Get(Form("EPRcm_%d",ibin)); TVectorD* totmult_t = (TVectorD*)f[ifile]->Get(Form("totmult_%d",ibin)); TVectorD* totpt_t = (TVectorD*)f[ifile]->Get(Form("totpt_%d",ibin)); Nevent[ibin] += (*Nevent_t)[ibin]; totmultall[ibin] += (*totmultall_t)[ibin]; for(int iptbin=0;iptbin<npt;iptbin++){ totmult[ibin][iptbin] += (*totmult_t)[iptbin]; totpt[ibin][iptbin] += (*totpt_t)[iptbin]; } for(int ieta=0;ieta<neta;ieta++){ EPR[ibin][ieta] += (*EPR_t)[ieta]; EPRpc[ibin][ieta] += (*EPRpc_t)[ieta]; EPRpm[ibin][ieta] += (*EPRpm_t)[ieta]; EPRcm[ibin][ieta] += (*EPRcm_t)[ieta]; TVectorD* Vobs_t = (TVectorD*)f[ifile]->Get(Form("v2obs_%d_%d",ibin,ieta)); TVectorD* totmultp_t = (TVectorD*)f[ifile]->Get(Form("totmultp_%d_%d",ibin,ieta)); TVectorD* totmultn_t = (TVectorD*)f[ifile]->Get(Form("totmultn_%d_%d",ibin,ieta)); TVectorD* totmultc_t = (TVectorD*)f[ifile]->Get(Form("totmultc_%d_%d",ibin,ieta)); for(int iptbin=0;iptbin<npt;iptbin++){ Vobs[ibin][ieta][iptbin] += (*Vobs_t)[iptbin]; totmultp[ibin][ieta][iptbin] += (*totmultp_t)[iptbin]; totmultn[ibin][ieta][iptbin] += (*totmultn_t)[iptbin]; totmultc[ibin][ieta][iptbin] += (*totmultc_t)[iptbin]; } } } f[ifile]->Close(); } TFile *outf = new TFile("mergedVobs.root","Recreate"); Nevent.Write("Nevent"); totmultall.Write("totmultall"); for(int ibin=0;ibin<nbin;ibin++){ for(int ieta=0;ieta<neta;ieta++){ hEPPhip[ibin][ieta]->Write(); hEPPhin[ibin][ieta]->Write(); hEPPhic[ibin][ieta]->Write(); } } fstrV<<setprecision(4)<<fixed; fstrV<<"ibin"<<"\t"<<"ieta"<<"\t"<<"iptbin"<<"\t"<<"avgpt"<<"\t"<<"v2obs"<<"\t"<<"v2corr"<<"\t"<<"v2corr3"<<"\t"<<"R"<<"\t"<<"R3"<<endl; for(int ibin=0;ibin<nbin;ibin++){ avgmult[ibin]=(double)totmultall[ibin]/Nevent[ibin]; for(int iptbin=0;iptbin<npt;iptbin++){ avgpt[ibin][iptbin]=totpt[ibin][iptbin]/totmult[ibin][iptbin]; } for(int ieta=0;ieta<neta;ieta++){ //EPR[ibin][ieta]=EPR[ibin][ieta]/Nevent[ibin]; EPR[ibin][ieta]=sqrt(EPR[ibin][ieta]/Nevent[ibin]); EPRpc[ibin][ieta]=EPRpc[ibin][ieta]/Nevent[ibin]; EPRcm[ibin][ieta]=EPRcm[ibin][ieta]/Nevent[ibin]; EPRpm[ibin][ieta]=EPRpm[ibin][ieta]/Nevent[ibin]; for(int iptbin=0;iptbin<npt;iptbin++){ Vobs[ibin][ieta][iptbin]/=totmultc[ibin][ieta][iptbin]; Vcorr[ibin][ieta][iptbin]=Vobs[ibin][ieta][iptbin]/EPR[ibin][ieta]; Vcorr3[ibin][ieta][iptbin]=Vobs[ibin][ieta][iptbin]/sqrt(EPRpc[ibin][ieta]*EPRpm[ibin][ieta]/EPRcm[ibin][ieta]); fstrV<<trkbin[ibin+1]<<"-"<<trkbin[ibin]<<"\t"<<etap[ieta]<<"-"<<etan[ieta]<<"\t"<<ptbin[iptbin]<<"-"<<ptbin[iptbin+1]<<"\t"<<avgpt[ibin][iptbin]<<"\t"<<Vobs[ibin][ieta][iptbin]<<"\t"<<Vcorr[ibin][ieta][iptbin]<<"\t"<<Vcorr3[ibin][ieta][iptbin]<<"\t"<<EPR[ibin][ieta]<<"\t"<<sqrt(EPRpc[ibin][ieta]*EPRpm[ibin][ieta]/EPRcm[ibin][ieta])<<endl; } fstrV<<endl; } TDirectory *dir0 = outf->mkdir(Form("D_%d",ibin)); dir0->cd(); totmult[ibin].Write("totmult"); avgpt[ibin].Write("avgpt"); EPR[ibin].Write("EPR"); EPRpc[ibin].Write("EPRpc"); EPRpm[ibin].Write("EPRpm"); EPRcm[ibin].Write("EPRcm"); for(int ieta=0;ieta<neta;ieta++){ TDirectory *dir1 = dir0->mkdir(Form("E_%d",ieta)); dir1->cd(); Vobs[ibin][ieta].Write("v2obs"); totmultp[ibin][ieta].Write("totmultp"); totmultn[ibin][ieta].Write("totmultn"); totmultc[ibin][ieta].Write("totmultc"); Vcorr[ibin][ieta].Write("v2"); Vcorr3[ibin][ieta].Write("v23sub"); } } outf->cd(); avgmult.Write("avgmult"); outf->Close(); remove("merged.root"); }
int main( int argc, char* argv[] ) { if( argc<2 ) { std::cout << "USAGE: ./drawMuonScaleSyst [configFileName]" << std::endl; std::cout << "Exiting." << std::endl; exit(11); } ZGDrawTools::setStyle(); std::string configFileName(argv[1]); ZGConfig cfg(configFileName); std::string dir = cfg.getEventYieldDir() + "/muonScaleSyst"; TFile* file = TFile::Open( Form("%s/muonScaleSyst.root", dir.c_str()) ); TGraph* gr_muScale = (TGraph*)file->Get("gr_muScaleSyst" ); TGraph* gr_egmScale = (TGraph*)file->Get("gr_egmScaleSyst"); TCanvas* c1 = new TCanvas( "c1", "", 600, 600 ); c1->cd(); TH2D* h2_axes = new TH2D("axes", "", 10, 200., 2100., 10, 0., 0.07); h2_axes->SetXTitle( "Generated Signal Mass [GeV]" ); h2_axes->SetYTitle( "Muon Scale Systematic Uncertainty" ); h2_axes->Draw(); gr_muScale->SetMarkerStyle(20); gr_muScale->SetMarkerSize(1.5); gr_muScale->SetMarkerColor(kBlack); gr_muScale->Draw("psame"); ZGDrawTools::addLabels(c1, -1., "CMS Simulation"); gPad->RedrawAxis(); c1->SaveAs( Form("%s/muonScaleSyst.eps", dir.c_str()) ); c1->SaveAs( Form("%s/muonScaleSyst.pdf", dir.c_str()) ); c1->Clear(); h2_axes->SetYTitle("Photon Scale Systematic Uncertainty"); h2_axes->Draw(); gr_egmScale->SetMarkerStyle(20); gr_egmScale->SetMarkerSize(1.5); gr_egmScale->SetMarkerColor(kBlack); TF1* f1 = new TF1("line", "[0]", 200, 2100); f1->SetLineColor(kRed); gr_egmScale->Fit( f1, "QR" ); gr_egmScale->Draw("Psame"); ZGDrawTools::addLabels(c1, -1., "CMS Simulation"); gPad->RedrawAxis(); c1->SaveAs( Form("%s/muEgmScaleSyst.eps", dir.c_str())); c1->SaveAs( Form("%s/muEgmScaleSyst.pdf", dir.c_str())); return 0; }
void plot_ch1() { TFile* hfile=TFile::Open("Histo_ch1.root"); gStyle->SetPadTopMargin(0.10); gStyle->SetOptStat(0); gStyle->SetTitleSize(.5,"XYZ"); TLatex* tt=new TLatex(); tt->SetTextSize(0.05); if (false) { TString hNames[13]={"hMbc","hDeltaE","hMinvEta","hMinvEtaP","hMinvK0S","hPIDpi","hD0pi","hZ0pi","hNPxdHitspi","hVtxPValueK0S","hVtxPValueEta","hVtxPValueEtaP","hVtxPValueB0"}; bool hLog[13]={false,false,false,false,true,true,true,true,false,true,true,true,true}; float hCutLow[13] ={5.25,-0.1,0.45,0.93,0.48,0.2,-0.08,-0.1,1,1E-3,1E-3,1E-3,1E-3}; float hCutHigh[13]={5.29, 0.1,0.57,0.98,0.52,1.0,+0.08,+0.1,4,1E-3,1E-3,1E-3,1E-3}; TLine* tl=new TLine(); tl->SetLineWidth(2); tl->SetLineColor(kRed+2); TCanvas* c1=new TCanvas("c1","Before Cuts"); c1->Divide(4,4); for (int i=0; i<13; ++i) { c1->cd(i+1); hfile->cd("AllCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]); if (htmp) htmp->DrawCopy(); float ymin=0; if (hLog[i]) { gPad->SetLogy(); ymin=1; } hfile->cd("AllCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kYellow); htmp_is->DrawCopy("same"); } hfile->cd("AllGoodCandidates"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_good"); if (htmp_is) { htmp_is->SetFillColor(kBlue); htmp_is->DrawCopy("same"); } hfile->cd("AllGoodCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_is_good"); if (htmp_is) { htmp_is->SetFillColor(kGreen); htmp_is->DrawCopy("same"); } hfile->cd("BestCandidates"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_best"); if (htmp_is) { htmp_is->SetLineColor(kRed); htmp_is->DrawCopy("same"); } hfile->cd("BestCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_is_best"); if (htmp_is) { htmp_is->SetLineColor(kViolet); htmp_is->DrawCopy("same"); } tl->DrawLine(hCutLow[i],ymin,hCutLow[i],htmp->GetMaximum()*1.05); tl->DrawLine(hCutHigh[i],ymin,hCutHigh[i],htmp->GetMaximum()*1.05); } c1->cd(16); TH1* htmp=(TH1F*)hfile->Get("hNCands"); if (htmp) htmp->DrawCopy(); tt->DrawLatexNDC(0.3,0.6,Form("All cands #e: %3.2f",htmp->GetEntries()/10000.)); tt->DrawLatexNDC(0.3,0.5,Form("All cands multiplicity: %3.2f",htmp->GetMean())); //c1->cd(16); htmp=(TH1F*)hfile->Get("hNGoodCands"); if (htmp) { htmp->SetFillColor(kGreen); htmp->DrawCopy("same"); tt->DrawLatexNDC(0.3,0.4,Form("All cands #e: %3.2f",htmp->GetEntries()/10000.)); tt->DrawLatexNDC(0.3,0.3,Form("Good cands multiplicity: %3.2f",htmp->GetMean())); } c1->cd(15); channel(c1,0.3,0.3); hfile->cd(); } if(true) { TString hNames[6]={"hMbc","hDeltaE","hMinvEta","hMinvEtaP","hMinvK0S","hPIDpi"}; bool hLog[6]={false,false,false,false,true,true}; float hCutLow[6] ={5.25,-0.1,0.45,0.93,0.48,0.2}; float hCutHigh[6]={5.29, 0.1,0.57,0.98,0.52,1.0}; TLine* tl=new TLine(); tl->SetLineWidth(2); tl->SetLineColor(kRed+2); TCanvas* c1=new TCanvas("c1","Before Cuts",900,600); c1->Divide(3,2); TLegend* tleg=new TLegend(0.2,0.4,0.6,0.89); tleg->SetFillStyle(0); for (int i=0; i<6; ++i) { c1->cd(i+1); hfile->cd("AllCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]); if (htmp) { htmp->GetXaxis()->SetTitleOffset(.7); htmp->GetXaxis()->SetTitleSize(0.08); htmp->DrawCopy(); if (i==0)tleg->AddEntry(htmp,"All cands","l"); } float ymin=0; if (hLog[i]) { gPad->SetLogy(); ymin=1; } hfile->cd("AllCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kYellow); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is,"MC match","f"); } hfile->cd("AllGoodCandidates"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kBlue); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is,"Good cands","f"); } hfile->cd("AllGoodCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kGreen); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is," \" MC match","f"); } tl->DrawLine(hCutLow[i],ymin,hCutLow[i],htmp->GetMaximum()*1.05); tl->DrawLine(hCutHigh[i],ymin,hCutHigh[i],htmp->GetMaximum()*1.05); if (i==0) tleg->Draw(); } channel(c1); c1->Print("Ch1_distr.pdf"); c1->Print("Ch1_distr.png"); TCanvas* c2=new TCanvas("c2","Before Cuts",900,600); c2->Divide(3,2); TLegend* tleg=new TLegend(0.2,0.6,0.6,0.89); for (int i=0; i<6; ++i) { c2->cd(i+1); hfile->cd("BestCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]); float ymin=0; if (hLog[i]) { gPad->SetLogy(); ymin=1; } if (htmp) { htmp->GetXaxis()->SetTitleOffset(.7); htmp->GetXaxis()->SetTitleSize(0.08); htmp->SetMinimum(ymin); htmp->SetFillColor(kBlue); htmp->DrawCopy(); if (i==0)tleg->AddEntry(htmp,"Best cands","f"); } hfile->cd("BestCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kGreen); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is," \" MC match","f"); } hfile->cd("BestCandidatesIsNotSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetLineColor(kBlack); htmp_is->SetLineStyle(2); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is," \" SXF","l"); } tl->DrawLine(hCutLow[i],ymin,hCutLow[i],htmp->GetMaximum()*1.05); tl->DrawLine(hCutHigh[i],ymin,hCutHigh[i],htmp->GetMaximum()*1.05); if (i==0) tleg->Draw(); } channel(c2); c2->Print("Ch1_best_distr.pdf"); c2->Print("Ch1_best_distr.png"); } if (true) { hfile->cd(); TCanvas* cEvents=new TCanvas("cEvents","",600,300); cEvents->Divide(2); cEvents->cd(1); TH1* htmp=(TH1F*)hfile->Get("hNCands"); if (htmp) htmp->DrawCopy(); tt->DrawLatexNDC(0.3,0.6,Form("All cands multiplicity: %3.2f",htmp->GetMean())); tt->DrawLatexNDC(0.3,0.5,Form("All cands #epsilon: %3.3f",htmp->GetEntries()/10000.)); cEvents->cd(2); htmp=(TH1F*)hfile->Get("hNGoodCands"); if (htmp) { htmp->SetFillColor(kBlue); htmp->DrawCopy(); tt->DrawLatexNDC(0.3,0.5,Form("Good cands #epsilon: %3.3f",htmp->GetEntries()/10000.)); tt->DrawLatexNDC(0.3,0.6,Form("Good cands multiplicity: %3.2f",htmp->GetMean())); } hfile->cd(); // Statistics TH1* hEvents=(TH1F*)hfile->Get("hEvents"); cout << "Total number of events: " << hEvents->GetBinContent(1) << " " << hEvents->GetBinContent(10)<< endl; cout << "Total number of events passed: " << hEvents->GetBinContent(2) << " " << hEvents->GetBinContent(11)<< endl; cout << "Total number of signal events passed: " << hEvents->GetBinContent(3) << " " << hEvents->GetBinContent(12)<< endl; channel(cEvents,0.5,0.93); cEvents->Print("Ch1_events.pdf"); cEvents->Print("Ch1_events.png"); } hfile->cd("BestCandidatesDeltaT"); // MC DT TH1* hTrueDT_best=(TH1F*)gDirectory->Get("hTrueDT_best"); TH1* hTrueDT_TrueB0_best=(TH1F*)gDirectory->Get("hTrueDT_TrueB0_best"); hTrueDT_TrueB0_best->SetLineColor(kRed); TH1* hTrueDT_TrueB0bar_best=(TH1F*)gDirectory->Get("hTrueDT_TrueB0bar_best"); hTrueDT_TrueB0bar_best->SetLineColor(kBlue); TH1* hTrueDT_TagB0_best=(TH1F*)gDirectory->Get("hTrueDT_TagB0_best"); hTrueDT_TagB0_best->SetLineColor(kRed); TH1* hTrueDT_TagB0bar_best=(TH1F*)gDirectory->Get("hTrueDT_TagB0bar_best"); hTrueDT_TagB0bar_best->SetLineColor(kBlue); // Reco DT TH1* hDT_best=(TH1F*)gDirectory->Get("hDT_best"); TH1* hDT_TrueB0_best=(TH1F*)gDirectory->Get("hDT_TrueB0_best"); hDT_TrueB0_best->SetLineColor(kRed); TH1* hDT_TrueB0bar_best=(TH1F*)gDirectory->Get("hDT_TrueB0bar_best"); hDT_TrueB0bar_best->SetLineColor(kBlue); TH1* hDT_TagB0_best=(TH1F*)gDirectory->Get("hDT_TagB0_best"); hDT_TagB0_best->SetLineColor(kRed); TH1* hDT_TagB0bar_best=(TH1F*)gDirectory->Get("hDT_TagB0bar_best"); hDT_TagB0bar_best->SetLineColor(kBlue); // define the number of parameters and fit range for the function fitFunc. Int_t npar = 9; Double_t min_range = -20.0; Double_t max_range = 20.0; TF1 * myFitFunc = new TF1("fitFunc", fitFunc, min_range, max_range, npar); myFitFunc->SetParName(0, "norm"); myFitFunc->SetParName(1, "Bias_{C}"); myFitFunc->SetParName(2, "#sigma_{C}"); myFitFunc->SetParName(3, "Bias_{T}"); myFitFunc->SetParName(4, "#sigma_{T}"); myFitFunc->SetParName(5, "Bias_{O}"); myFitFunc->SetParName(6, "#sigma_{O}"); myFitFunc->SetParName(7, "f_{C}"); myFitFunc->SetParName(8, "f_{T}"); myFitFunc->SetParameters(1500.0, 0., 1., 0., 1.5, 0, 3., 0.4, 0.3); myFitFunc->SetParLimits(0, 0.0, 2500.0); // norm myFitFunc->SetParLimits(1, -2.0, 2.0); // mu1 myFitFunc->SetParLimits(2, 0.1, 1.); // sigma1 myFitFunc->SetParLimits(3, -4.0, +4.0); // mu2 myFitFunc->SetParLimits(4, 1., 3.); // sigma2 myFitFunc->SetParLimits(5, -4.0, +4.0); // mu3 myFitFunc->SetParLimits(6, 2., 20.); // sigma3 myFitFunc->SetParLimits(7, 0.0, 1.0); // frac1 myFitFunc->SetParLimits(8, 0.0, 1.0); // frac2 myFitFunc->SetLineWidth(2); if (false) { TCanvas* cDtAll=new TCanvas("cDtAll"); cDtAll->Divide(3,2); cDtAll->cd(1); //hTrueDT_best->Draw(); hTrueDT_best->Fit("fitFunc", "LE"); hTrueDT_best->Draw("e"); TF1 *gC = new TF1("gC","gaus",min_range, max_range); TF1 *gT = new TF1("gT","gaus",min_range, max_range); TF1 *gO = new TF1("gO","gaus",min_range, max_range); double* fitParams=myFitFunc->GetParameters(); gC->SetLineColor(kRed); gC->SetLineStyle(2); gC->SetParameter(0,fitParams[0]*fitParams[7]); gC->SetParameter(1,fitParams[1]); gC->SetParameter(2,fitParams[2]); cout << "Core " << gC->GetParameter(0) << " " << gC->GetParameter(1) << " " << gC->GetParameter(2)<< endl; gT->SetLineColor(kGreen); gT->SetLineStyle(2); gT->SetParameter(0,fitParams[0]*fitParams[8]); gT->SetParameter(1,fitParams[3]); gT->SetParameter(2,fitParams[4]); cout << "Tail " << gT->GetParameter(0) << " " << gT->GetParameter(1) << " " << gT->GetParameter(2)<< endl; gO->SetLineColor(kBlue); gO->SetLineStyle(2); gO->SetParameter(0,fitParams[0]*(1-fitParams[7]-fitParams[8])); gO->SetParameter(1,fitParams[5]); gO->SetParameter(2,fitParams[6]); cout << "Outlier " << gO->GetParameter(0) << " " << gO->GetParameter(1) << " " << gO->GetParameter(2)<< endl; gC->Draw("same"); gT->Draw("same"); gO->Draw("same"); //return; cDtAll->cd(2); hTrueDT_TrueB0_best->Draw(); hTrueDT_TrueB0bar_best->Draw("same"); cDtAll->cd(3); hTrueDT_TagB0_best->Draw(); hTrueDT_TagB0bar_best->Draw("same"); cDtAll->cd(4); //hDT_best->Draw(); hDT_best->Fit("fitFunc", "LE"); hDT_best->Draw("e"); TF1 *gC = new TF1("gC","gaus",min_range, max_range); TF1 *gT = new TF1("gT","gaus",min_range, max_range); TF1 *gO = new TF1("gO","gaus",min_range, max_range); double* fitParams=myFitFunc->GetParameters(); gC->SetLineColor(kRed); gC->SetLineStyle(2); gC->SetParameter(0,fitParams[0]*fitParams[7]); gC->SetParameter(1,fitParams[1]); gC->SetParameter(2,fitParams[2]); cout << "Core " << gC->GetParameter(0) << " " << gC->GetParameter(1) << " " << gC->GetParameter(2)<< endl; gT->SetLineColor(kGreen); gT->SetLineStyle(2); gT->SetParameter(0,fitParams[0]*fitParams[8]); gT->SetParameter(1,fitParams[3]); gT->SetParameter(2,fitParams[4]); cout << "Tail " << gT->GetParameter(0) << " " << gT->GetParameter(1) << " " << gT->GetParameter(2)<< endl; gO->SetLineColor(kBlue); gO->SetLineStyle(2); gO->SetParameter(0,fitParams[0]*(1-fitParams[7]-fitParams[8])); gO->SetParameter(1,fitParams[5]); gO->SetParameter(2,fitParams[6]); cout << "Outlier " << gO->GetParameter(0) << " " << gO->GetParameter(1) << " " << gO->GetParameter(2)<< endl; gC->Draw("same"); gT->Draw("same"); gO->Draw("same"); cDtAll->cd(5); hDT_TrueB0_best->Draw(); hDT_TrueB0bar_best->Draw("same"); cDtAll->cd(6); hDT_TagB0_best->Draw(); hDT_TagB0bar_best->Draw("same"); } gStyle->SetOptStat(0); gStyle->SetFitFormat("4.3g"); gStyle->SetStatFontSize(0.05); gStyle->SetStatFont(62); gStyle->SetStatH(0.15); gStyle->SetStatW(0.18); TCanvas* cDt=new TCanvas("cDt"); //hDT_best->Draw(); hDT_best->Fit("fitFunc", "LE"); hDT_best->Draw("e"); TF1 *gC = new TF1("gC","gaus",min_range, max_range); TF1 *gT = new TF1("gT","gaus",min_range, max_range); TF1 *gO = new TF1("gO","gaus",min_range, max_range); double* fitParams=myFitFunc->GetParameters(); gC->SetLineColor(kRed); gC->SetLineStyle(2); gC->SetParameter(0,fitParams[0]*fitParams[7]); gC->SetParameter(1,fitParams[1]); gC->SetParameter(2,fitParams[2]); cout << "Core " << gC->GetParameter(0) << " " << gC->GetParameter(1) << " " << gC->GetParameter(2)<< endl; gT->SetLineColor(kGreen); gT->SetLineStyle(2); gT->SetParameter(0,fitParams[0]*fitParams[8]); gT->SetParameter(1,fitParams[3]); gT->SetParameter(2,fitParams[4]); cout << "Tail " << gT->GetParameter(0) << " " << gT->GetParameter(1) << " " << gT->GetParameter(2)<< endl; gO->SetLineColor(kBlue); gO->SetLineStyle(2); gO->SetParameter(0,fitParams[0]*(1-fitParams[7]-fitParams[8])); gO->SetParameter(1,fitParams[5]); gO->SetParameter(2,fitParams[6]); cout << "Outlier " << gO->GetParameter(0) << " " << gO->GetParameter(1) << " " << gO->GetParameter(2)<< endl; gC->Draw("same"); gT->Draw("same"); gO->Draw("same"); double resoDt=(gC->GetParameter(2)*gC->GetParameter(0))+(gO->GetParameter(2)*gO->GetParameter(0))+(gT->GetParameter(2)*gT->GetParameter(0)); double sumW=gC->GetParameter(0)+gO->GetParameter(0)+gT->GetParameter(0); cout << "Mean(DT) = " << resoDt/sumW << endl; TLegend* tleg=new TLegend(0.2,.6,0.4,0.89,"Fit","NDC"); tleg->AddEntry(gC,"Core","l"); tleg->AddEntry(gT,"Tail","l"); tleg->AddEntry(gO,"Outlier","l"); tleg->Draw(); tt->DrawLatexNDC(0.65,0.35,Form("<#Deltat>: %3.2f ps",resoDt/sumW)); channel(cDt,0.3,0.96); cDt->Print("Ch1_Dt.pdf"); cDt->Print("Ch1_Dt.png"); TCanvas* cAsym=new TCanvas("cAsym"); TPad *pad1 = new TPad("pad1", "The pad 80% of the height",0.0,0.3,1.0,1.0,0); TPad *pad2 = new TPad("pad2", "The pad 20% of the height",0.0,0.0,1.0,0.3,0); pad1->Draw(); pad2->Draw(); pad1->cd(); hDT_TagB0_best->SetMarkerStyle(24); hDT_TagB0_best->SetMarkerColor(kBlue); hDT_TagB0_best->SetLineColor(kBlue); hDT_TagB0_best->Draw("histoe"); hDT_TagB0bar_best->SetMarkerStyle(20); hDT_TagB0bar_best->SetMarkerColor(kRed); hDT_TagB0bar_best->SetLineColor(kRed); hDT_TagB0bar_best->Draw("histo e same"); TLegend* tleg=new TLegend(0.2,.6,0.4,0.89,"Flavour","NDC"); tleg->AddEntry(hDT_TagB0_best,"B_{0}","l"); tleg->AddEntry(hDT_TagB0bar_best,"#bar{B_{0}}","l"); tleg->Draw(); pad2->cd(); TH1* hDT_Tag_best_num=hDT_TagB0_best->Clone(); hDT_Tag_best_num->Add(hDT_TagB0bar_best,-1.); TH1* hDT_Tag_best_den=hDT_TagB0_best->Clone(); hDT_Tag_best_den->Add(hDT_TagB0bar_best,+1.); TH1* hDT_Tag_best_asym=hDT_Tag_best_num->Clone(); hDT_Tag_best_asym->Divide(hDT_Tag_best_den); hDT_Tag_best_asym->SetMaximum(+1.05); hDT_Tag_best_asym->SetMinimum(-1.05); hDT_Tag_best_asym->SetLineColor(kBlack); hDT_Tag_best_asym->SetMarkerColor(kBlack); hDT_Tag_best_asym->SetMarkerStyle(20); gPad->SetGridy(); hDT_Tag_best_asym->Draw("e"); hDT_Tag_best_asym->GetYaxis()->SetNdivisions(503); hDT_Tag_best_asym->GetYaxis()->SetTitle("Asymmetry"); hDT_Tag_best_asym->GetYaxis()->SetTitleOffset(0.3); hDT_Tag_best_asym->GetYaxis()->SetTitleSize(0.1); hDT_Tag_best_asym->GetYaxis()->SetLabelSize(0.1); hDT_Tag_best_asym->GetXaxis()->SetLabelSize(0.1); hDT_Tag_best_asym->GetXaxis()->SetTitleSize(0.1); hDT_Tag_best_asym->Draw("e"); // TF1* mysin=new TF1("mysin","[0]*sin([1]*x)",-10,10); // mysin->SetParameter(0,0.2); // mysin->SetParameter(1,0.2); // hDT_Tag_best_asym->Fit("mysin","R"); channel(cAsym,0.5,0.96); cAsym->Print("Ch1_Asym.pdf"); cAsym->Print("Ch1_Asym.png"); }
void fPostSlatId_db( const char* opt = "", const char* year = "17sim", const char* input = "fPostSlatId.txt") { // storeTime is beginning time for validity range in case of WRITING DB TString option(opt), yr(year), storeTime; int date, time; // time for READING DB std::cout <<"year = " <<year <<std::endl; if (yr.Contains("17sim")) { storeTime = "2016-12-10 00:00:00"; date = 20161210; time = 0; } else if (yr.Contains("17ofl")) { storeTime = "2016-12-20 00:00:01"; date = 20161220; time = 1; } else { std::cout << "Please specify valid year tag\n"; exit; } std::cout << "Opt =" << opt << "\n"; std::cout << "write = " << option.Contains("writedb") << "\n"; std::cout << "storetime = " << storeTime << "\n"; std::cout << "date, time = " << date <<" "<< time << "\n"; gROOT->Macro("./loadlib.C"); //------------------------------------------- const Int_t MAX_DB_INDEX = 241; fpostSlatId_st in[MAX_DB_INDEX]; FILE *FP = fopen(input, "r"); if (!FP) { printf("Could not open %s\n", input); exit; } printf("\nReading %s\n", input); char line[1000]; int n = 0; while (fgets(line, 1000, FP) != NULL) { sscanf(line,"%d %d %d %d ", &in[n].slatid, &in[n].quad, &in[n].layer, &in[n].slat); printf("slatId=%3d quad=%2d layer=%2d slat=%2d\n", in[n].slatid, in[n].quad, in[n].layer, in[n].slat); n++; } printf("Found %d entries\n", n); //------------------------------------------- if (option.Contains("writedb")) { gSystem->Setenv("DB_ACCESS_MODE", "write"); StDbManager* mgr = StDbManager::Instance(); StDbConfigNode* node = mgr->initConfig("Geometry_fps"); StDbTable* dbtable = node->addDbTable("fpostSlatId"); mgr->setStoreTime(storeTime.Data()); dbtable->SetTable((char*)&in, MAX_DB_INDEX); if (yr.Contains("sim")) dbtable->setFlavor("sim"); mgr->storeDbTable(dbtable); std::cout << "INFO: table saved to database" << std::endl; } //------------------------------------------- if (option.Contains("readdb")) { std::cout << "INFO: Reading database" << std::endl; gSystem->Unsetenv("DB_ACCESS_MODE"); //gSystem->Unsetenv("DB_SERVER_LOCAL_CONFIG"); St_db_Maker* dbMk = new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb"); dbMk->SetDebug(); dbMk->SetDateTime(date, time); // event or run start time, set to your liking if (yr.Contains("ofl")) { dbMk->SetFlavor("ofl"); } else if (yr.Contains("sim")) { dbMk->SetFlavor("sim"); } dbMk->Init(); dbMk->Make(); TDataSet *DB = 0; DB = dbMk->GetDataBase("Geometry/fps/fpostSlatId"); if (!DB) std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl; St_fpostSlatId *dataset = 0; dataset = (St_fpostSlatId*) DB->Find("fpostSlatId"); if (!dataset) { std::cout << "ERROR: dataset does not contain requested table" << std::endl; return; } Int_t rows = dataset->GetNRows(); if (rows > 1) std::cout << "INFO: found INDEXED table with " << rows << " rows" << std::endl; TDatime val[2]; dbMk->GetValidity((TTable*)dataset, val); std::cout << "Dataset validity range: [ " << val[0].GetDate() << "." << val[0].GetTime() << " - " << val[1].GetDate() << "." << val[1].GetTime() << " ] " << std::endl; fpostSlatId_st *table = (fpostSlatId_st*)dataset->GetTable(); for (Int_t i = 0; i < rows; i++) { std::cout << Form("Row=%3d slatid=%3d quad=%2d layer=%2d slat=%2d\n", i, table[i].slatid, table[i].quad, table[i].layer, table[i].slat); } } return; }//Main
/******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ void run_hits_sep( Int_t ifile, TString mcEngine="TGeant3" ) { // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 0; // just forget about it, for the moment // Input file (MC events) TString inFile = Form("pixel_f%d_",ifile); inFile = inFile + mcEngine + ".digi.root"; // Parameter file TString parFile = "pixel_"; parFile = parFile + mcEngine + ".params.root"; // Digitization parameter file TString dir = getenv("VMCWORKDIR"); TString tutdir = dir + "/MQ/9-PixelDetector"; TString digParFile = tutdir + "/param/pixel_digi.par"; // Output file TString outFile = Form("pixel_f%d_",ifile); outFile = outFile + mcEngine + ".hits.root"; // ----- Timer -------------------------------------------------------- TStopwatch timer; // ----- Reconstruction run ------------------------------------------- FairRunAna *fRun= new FairRunAna(); fRun->SetInputFile(inFile); fRun->SetOutputFile(outFile); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(digParFile.Data(),"in"); rtdb->setFirstInput(parInput1); rtdb->setSecondInput(parIo1); // ----- TorinoDetector hit producers --------------------------------- PixelFindHits* hitFinderTask = new PixelFindHits(); fRun->AddTask(hitFinderTask); fRun->Init(); timer.Start(); fRun->Run(); // ----- Finish ------------------------------------------------------- cout << endl << endl; // Extract the maximal used memory an add is as Dart measurement // This line is filtered by CTest and the value send to CDash FairSystemInfo sysInfo; Float_t maxMemory=sysInfo.GetMaxMemory(); cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; cout << maxMemory; cout << "</DartMeasurement>" << endl; timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); Float_t cpuUsage=ctime/rtime; cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; cout << cpuUsage; cout << "</DartMeasurement>" << endl; cout << endl << endl; cout << "Output file is " << outFile << endl; cout << "Parameter file is " << parFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl; cout << "Macro finished successfully." << endl; cout << "DATE MARKER" << flush; gSystem->Exec("date"); // ------------------------------------------------------------------------ }
// print the yields void CreateCrossSectionTable ( const std::string& label, const std::string& hist_name = "h_reco_full_yield", const std::string& output_file = "", bool print_latex = false ) { const double lumi = 0.082; // fb^-1 // map of samples and yields const dy::YieldVector yields = dy::GetYieldVector(label, hist_name); const dy::Yield y_data = yields[dy::Sample::data]; const dy::Yield y_bk_pred = dy::GetBackgroundPred(label, hist_name); const dy::Yield y_dy_pred = yields[dy::Sample::dyll]; const dy::Yield y_mc_pred = y_dy_pred + y_bk_pred; const dy::Yield y_den_acc = dy::GetYieldFromLabel(dy::Sample::dyll, label, "h_acc_gen_den"); const dy::Yield y_num_acc = dy::GetYieldFromLabel(dy::Sample::dyll, label, "h_acc_rec_num"); const dy::Yield y_acc = dy::GetYieldFromLabel(dy::Sample::dyll, label, "h_acc_rec"); const dy::Yield y_nsig = y_data - y_bk_pred; // xsec = (Nobs - Nbkg)/(lumi * acc) dy::Yield xsec = y_nsig/(lumi * y_acc); xsec = xsec * (1e-6); // fb --> nb std::string result; if (print_latex) { string latex("\\begin{table}[ht!]\n" ); latex.append("\\begin{center}\n" ); latex.append("\\begin{tabular}{l|ccc} \\hline\\hline\n" ); latex.append("source & $ee$ & $\\mu\\mu$ \\\\\n" ); latex.append("\\hline\n" ); latex.append(Form("%s \\\\\n", GetLatex("$N_{obs}$" , y_data).c_str())); latex.append(Form("%s \\\\\n", GetLatex("$N_{mc}$" , y_mc_pred).c_str())); latex.append(Form("%s \\\\\n", GetLatex("$N_{dyll}$", y_dy_pred).c_str())); latex.append(Form("%s \\\\\n", GetLatex("$N_{bkgd}$", y_bk_pred).c_str())); latex.append(Form("%s \\\\\n", GetLatex("$N_{sig}$" , y_nsig).c_str())); latex.append(Form("%s \\\\\n", GetLatex("Acc" , y_acc).c_str())); latex.append("\\hline\\hline\n"); latex.append(Form("%s \\\\\n", GetLatex("Sigma (nb)", xsec).c_str())); latex.append("\\hline\\hline\n" ); latex.append("\\end{tabular}\n" ); latex.append("\\caption{Drell-Yan Exercise Cross-Section}\n" ); latex.append("\\end{center}\n" ); latex.append("\\end{table}" ); result = latex; } else { // make the table CTable t_yields; t_yields.useTitle(); t_yields.setTitle("Cross-Sectoin for Drell-Yan Exercise"); t_yields.setTable() ( "ee", "mm") ("N_obs" , y_data.ee.pm("4.0"), y_data.mm.pm("4.0")) ("N_mc" , y_mc_pred.ee.pm("4.1"), y_mc_pred.mm.pm("4.1")) ("N_dyll" , y_dy_pred.ee.pm("4.1"), y_dy_pred.mm.pm("4.1")) ("N_bkgd" , y_bk_pred.ee.pm("4.1"), y_bk_pred.mm.pm("4.1")) ("N_sig" , y_nsig.ee.pm("4.1"), y_nsig.mm.pm("4.1")) ("Num Acc" , y_num_acc.ee.pm("4.3"), y_num_acc.mm.pm("4.3")) ("Den Acc" , y_den_acc.ee.pm("4.3"), y_den_acc.mm.pm("4.3")) ("Acc" , y_acc.ee.pm("4.3"), y_acc.mm.pm("4.3")) ("Sigma (nb)" , xsec.ee.pm("4.3"), xsec.mm.pm("4.3")) ; // print it std::ostringstream os; os << t_yields; result = os.str(); } // output if (output_file.empty()) { std::cout << result << std::endl; } else { std::ofstream fout(output_file); fout << result << std::endl; } }
// input: - Input file (result from TMVA), // - use of colors or grey scale // - use of TMVA plotting TStyle void correlations( TString fin = "TMVA.root", Bool_t isRegression = kFALSE, Bool_t greyScale = kTRUE, Bool_t useTMVAStyle = kFALSE ) { // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); // signal and background or regression problem Int_t ncls = (isRegression ? 1 : 2 ); TString hName[2] = { "CorrelationMatrixS", "CorrelationMatrixB" }; if (isRegression) hName[0]= "CorrelationMatrix"; const Int_t width = 1400; for (Int_t ic=0; ic<ncls; ic++) { TH2* h2 = file->Get( hName[ic] ); if(!h2) { cout << "Did not find histogram " << hName[ic] << " in " << fin << endl; continue; } TCanvas* c = new TCanvas( hName[ic], Form("Correlations between MVA input variables (%s)", (isRegression ? "" : (ic==0 ? "signal" : "background"))), ic*(width+5)+200, 0, width, 800 ); Float_t newMargin1 = 0.13; Float_t newMargin2 = 0.15; if (TMVAGlob::UsePaperStyle) newMargin2 = 0.13; // c->SetGrid(); // c->SetTicks(); c->SetLeftMargin ( newMargin2 ); c->SetBottomMargin( newMargin2 ); c->SetRightMargin ( newMargin1 ); c->SetTopMargin ( newMargin1 ); //an attempt to make my own color palette // Double_t Red[3] = { 1.00, 0.00, 0.00}; // Double_t Green[3] = { 0.00, 1.00, 0.00}; // Double_t Blue[3] = { 1.00, 0.00, 1.00}; // Double_t Length[3] = { 0.50, 0.50, 1.00 }; // Int_t nb=50; // TColor::CreateGradientColorTable(3,Length,Red,Green,Blue,nb); gStyle->SetPalette( 1, 0 ); gStyle->SetPaintTextFormat( "3g" ); h2->SetTitle(""); h2->SetMarkerSize( 1.5 ); h2->SetMarkerColor( kBlack ); Float_t labelSize = 0.03; h2->GetXaxis()->SetLabelSize( labelSize ); h2->GetYaxis()->SetLabelSize( labelSize ); h2->LabelsOption( "d" ); h2->SetLabelOffset( 0.011 );// label offset on x axis h2->Draw("colz"); // color pads c->Update(); // modify properties of paletteAxis TPaletteAxis* paletteAxis = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject( "palette" ); paletteAxis->SetLabelSize( 0.03 ); paletteAxis->SetX1NDC( paletteAxis->GetX1NDC() + 0.02 ); h2->Draw("textsame"); // add text // add comment TText* t = new TText( 0.53, 0.88, "Linear correlation coefficients in %" ); t->SetNDC(); t->SetTextSize( 0.04 ); t->AppendPad(); // TMVAGlob::plot_logo( ); c->Update(); TString fname = "plots/"; fname += hName[ic]; TMVAGlob::imgconv( c, fname ); } }
int main( int argc, char* argv[] ) { std::string batchProd = "postFreezeNLO_v2"; if( argc>1 ) { std::string batchProd_str(argv[1]); batchProd = batchProd_str; } DrawBase* db = new DrawBase("rocs_and_shit"); //std::string fileName = "../histograms_CMS-HGG_btag.root"; std::string fileName = "../batchOutput_" + batchProd + "/histograms_CMS-HGG.root"; TFile* file = TFile::Open(fileName.c_str()); //TFile* file = TFile::Open("../batchOutput_provaLD6_withBDT2/histograms_CMS-HGG.root"); db->add_mcFile( file, "thefile", "tHq", kBlack, 0); TFile* fileBG = TFile::Open(Form("../batchOutput_%s/histograms_CMS-HGG.root", batchProd.c_str())); db->add_mcFile( fileBG, "thefileBG", "diphoton", kBlack, 0); std::string outputdir = "RoCs_andShit_" + batchProd; db->set_outputdir(outputdir); //// hadronic channel (12) //compareSingleVariable( db, 12, "njets_InsideEtaCut", 9, -0.5, 8.5, "Central Jet Multiplicity (|#eta|<2)", "" ); //compareSingleVariable( db, 12, "njets", 9, -0.5, 8.5, "Jet Multiplicity", "" ); //compareSingleVariable( db, 12, "qJetPt", 50, 20., 120., "qJet p_{T}", "GeV" ); //compareSingleVariable( db, 12, "qJetEta", 30, 0., 5., "qJet |#eta|", "" ); //compareSingleVariable( db, 12, "topM", 50, 0., 1000., "Top Transverse Mass", "GeV" ); //compareSingleVariable( db, 12, "deltaEta_bJet_qJet", 35, 0., 7., "|#Delta#eta| (bJet-qJet)", "" ); //compareSingleVariable( db, 12, "deltaPhi_top_higgs", 30, 0., 3.15, "#Delta#phi(top-diphoton)", "rad" ); // leptonic channel (11) compareSingleVariable( db, 11, "njets_InsideEtaCut", 9, -0.5, 8.5, "Central Jet Multiplicity (|#eta|<1)", "" ); compareSingleVariable( db, 11, "njets_InsideEtaCut", 9, -0.5, 8.5, "Central Jet Multiplicity (|#eta|<1)", "", "thqLD_lept>0.25", "LDcut" ); compareSingleVariable( db, 11, "njets_OutsideEtaCut", 9, -0.5, 8.5, "Forward Jet Multiplicity (|#eta|>1)", "" ); compareSingleVariable( db, 11, "njets", 9, -0.5, 8.5, "Jet Multiplicity", "" ); compareSingleVariable( db, 11, "nbjets_loose", 9, -0.5, 8.5, "CSVL b-Jet Multiplicity", "" ); compareSingleVariable( db, 11, "nbjets_medium", 9, -0.5, 8.5, "CSVM b-Jet Multiplicity", "" ); compareSingleVariable( db, 11, "bJetPt", 50, 20., 320., "bJet p_{T}", "GeV" ); compareSingleVariable( db, 11, "qJetPt", 50, 20., 320., "qJet p_{T}", "GeV" ); compareSingleVariable( db, 11, "qJetEta", 30, 0., 5., "qJet |#eta|", "" ); compareSingleVariable( db, 11, "topMt", 50, 0., 1000., "Top Transverse Mass", "GeV" ); compareSingleVariable( db, 11, "lept_charge", 3, -1.5, 1.5, "Lepton Charge", "" ); compareSingleVariable( db, 11, "deltaEta_lept_qJet", 35, 0., 7., "|#Delta#eta| (lepton-qJet)", "" ); compareSingleVariable( db, 11, "deltaPhi_top_higgs", 30, 0., 3.15, "#Delta#phi(top-diphoton)", "rad" ); compareSingleVariable( db, 11, "deltaPhi_top_higgs", 30, 0., 3.15, "#Delta#phi(top-diphoton)", "rad", "thqLD_lept>0.25", "LDcut" ); compareSingleVariable( db, 11, "thqLD_lept", 25, 0., 1.0001, "tHq Leptonic LD" ); //compareSingleVariable( db, 11, "thqLD_lept_2", 25, 0., 1.0001, "tHq Leptonic LD" ); //compareSingleVariable( db, 11, "thqLD_lept_2_central", 25, 0., 1.0001, "tHq Leptonic LD (central jets)" ); compareSingleVariable( db, 11, "thqBDT_lept", 25, -1., 1.0001, "tHq Leptonic BDT" ); compareSingleVariable( db, 11, "thqBDT_lept_2", 25, -1., 1.0001, "tHq Leptonic BDT (6 vars)" ); //compareTaggersLeptonic( db, "thqLD_lept", "thqLD_lept_2_central", "Old LD", "New LD" ); //compareTaggersLeptonic( db, "thqBDT_lept", "thqBDT_lept_2", "BDT 5 vars", "BDT 6 vars", 25, -1., 1. ); drawRoc(db); return 0; }
void makeWorkspace(RooWorkspace& ws, int ChooseSample,float muonEtaMin, float muonEtaMax, float muonPtMin, float muonPtMax, float upsRapMin, float upsRapMax, float upsPtMin,float upsPtMax, int upsCentralityStart, int upsCentralityEnd ){ double mass_l = 7.0; double mass_h = 14.0; cout<< "You're in makeWorkspace!" << endl; std::string finput; switch (ChooseSample) { case 1: // pp @ 7TeV - dimuon0-v1 finput = "../dimuonTree_upsiMiniTree_pp7tev_dimu0v1_Runa_trigBit1_allTriggers0_pt4.root"; mass_l = 8.5; mass_h = 11.5; binw=0.05; break; case 2://pp @ 7TeV - non dimuon0-v1 (GG) finput = "../dimuonTree_upsiMiniTree_pp7tev_glbglb_Runa_trigBit1_allTriggers0_pt4.root"; mass_l = 8.5; mass_h = 11.5; binw=0.05; break; case 3://PbPb @ 2.76TeV pp reco trk-trk // finput = "../dimuonTree_upsiMiniTree_aa276tev_50100ppreco__Runa_trigBit1_allTriggers0_pt4.root"; // break; finput = "../dimuonTree_upsiMiniTree_aa276tevC50100_ppofficial_trktrk_ptmu4_Runa_trigBit1_allTriggers0.root"; break; case 4://PbPb @ 2.76TeV pp reco glbglb finput = "../dimuonTree_upsiMiniTree_aa276tev_50100ppreco_glbglb_Runa_trigBit1_allTriggers0_pt4.root"; break; case 5://PbPb @ 2.76TeV Zhen's tree glbglb //finput = "../dimuonTree_upsiMiniTree_AA276tevC0100_regit_ptmu4_Run210498-211631_trigBit1_allTriggers0.root"; finput = "../dimuonTree_HI2011_fulldataset_trkRot.root"; break; case 6://PbPb @ 2.76TeV regit gROOT->LoadMacro("bkgTable_PbPb.h"); if(muonPtMin<3.7){ gROOT->LoadMacro("bkgTable_PbPb_loose.h");} if(muonPtMin>3.7){ gROOT->LoadMacro("bkgTable_PbPb_tight.h");} // finput = "../dimuonTree_upsiMiniTree_aa276tev_regitreco_glbglb_Runa_trigBit1_allTriggers0_pt4.root"; // cent 0-40 "cm" but doesnt have all the muons! // finput = "../dimuonTree_upsiMiniTree_AA2p76tev_ptmu3_july09_Run2011-2011_trigBit1_allTriggers0.root";// cent0-40 "td" // finput = "../dimuonTree_upsiMiniTree_AA276tevC0100_regit_ptmu4_Run210498-211631_trigBit1_allTriggers0.root"; // cent0-40 "nf" finput = "../dimuonTree_upsiMiniTree_AA2p76tev_ptmuSpecial_nov25_2013_trigBit1_allTriggers1_testNoCut.root"; // no cuts , so it has all the muons. // finput = "../dimuonTree_upsiMiniTree_AA2p76tev_WithIDCuts_RunHIN-15-001_trigBit1_allTriggers0.root";//bold as can be : my tree! break; case 7://pp @ 2.76TeV gROOT->LoadMacro("bkgTable_pp.h"); if(muonPtMin<3.7){ gROOT->LoadMacro("bkgTable_pp_loose.h");} if(muonPtMin>3.7){ gROOT->LoadMacro("bkgTable_pp_tight.h");} // finput = "../dimuonTree_upsiMiniTree_pp276tev_5p41_Run211739-211831_trigBit1_allTriggers0_pt4.root"; //trk muons! // finput = "../dimuonTree_upsiMiniTree_pp276tev_5p41_ptmu2_Run211739-211831_GlbGlb_trigBit1_allTriggers0.root"; // Glb muons, all above 2! ///finput = "../upsiMiniTree_ppData_QQtrigbit1_Trig_analysisOK_noSingleMu.root"; // new tree (2014, I did it...and there are nore events !?) //finput = "../dimuonTree_upsiMiniTree_pp276tev_5p41_ptmu2_Run211739-211831_GlbGlb_trigBit1_allTriggers0.root";} // Glb muons, all above 2 GeV, HLT_PAL1DoubleMuOpen //finput = "../dimuonTree_upsiMiniTree_pp276tev_5p41_ptmu3_Run211739-211831_trigBit2_allTriggers0_testNoCut.root"; }// HLT_PAL1DoubleMu0HighQ triggered events //finput = "../upsiMiniTree_ppData_GLBGLB_QQtrigbit2_Trig_analysisOK_20140729_cuts10-006.root"; //HLT_PAL1DoubleMu0_HighQ triggered events AND GlbGlb muons pairs matched to it! finput ="../dimuonTree_upsiMiniTree_pp2p76tev_noIDVars_GlbGlb_RunHIN-15-001_trigBit2_allTriggers0.root"; // if(isPA) { finput = "../dimuonTree_upsiMiniTree_pA5tev_18p4nb__Run210498-211256_trigBit1_allTriggers0_pt4.root";} //// pPb break; case 8: // finput = "../upsiMiniTree_pythia1S_QQtrigbit1_Trig_analysisOK_20140729_cuts10-006.root"; finput = "~/Project/ups2013/upsiMiniTree_Pyquen1S_QQtrigbit1_Trig_Unfolding_postCut_deltaRmatched_withCentrality.root"; mass_l = 8.; mass_h = 10.5; binw=0.05; break; case 9: gROOT->LoadMacro("bkgTable_pp.h"); finput = "../dimuonTree_upsiMiniTree_pA5tev_18p4nb__Run210498-211256_trigBit1_allTriggers0_pt4.root"; isPA=true; break; default: cout<<"You don't know what you are doing! Pick one of the available datasets in the choseSampleCases[] array"<<endl; break; } cout << finput << endl; // TFile f(finput,"read"); TFile *f = new TFile(finput.c_str()); TTree* theTree = (TTree*)gROOT->FindObject("UpsilonTree"); // OS --- all mass // //RooWorkspace* ws = new RooWorkspace("ws","Upsilon Mass Fitting"); //ws.var("invariantMass"); RooRealVar* mass = new RooRealVar("invariantMass","#mu#mu mass",mass_l,mass_h,"GeV/c^{2}"); // ws.import(*mass); RooRealVar* upsPt = new RooRealVar("upsPt","p_{T}(#Upsilon)",0,60,"GeV/c"); RooRealVar* upsRapidity= new RooRealVar("upsRapidity", "upsRapidity",-2.4, 2.4); RooRealVar* vProb = new RooRealVar("vProb", "vProb" ,0.01,1.00); RooRealVar* QQsign = new RooRealVar("QQsign", "QQsign" ,-1,5); RooRealVar* Centrality = new RooRealVar("Centrality","Centrality",0,100); RooRealVar* muPlusPt = new RooRealVar("muPlusPt","muPlusPt",muonPtMin,1000); RooRealVar* muMinusPt = new RooRealVar("muMinusPt","muMinusPt",muonPtMin,1000); RooRealVar* muPlusEta = new RooRealVar("muPlusEta","muPlusEta", muonEtaMin,muonEtaMax); RooRealVar* muMinusEta = new RooRealVar("muMinusEta","muMinusEta",muonEtaMin,muonEtaMax); RooDataSet* data0, *data; RooArgSet cols(*mass,*upsPt,*upsRapidity,*Centrality,*muPlusPt,*muMinusPt,*muPlusEta,*muMinusEta); data0 = new RooDataSet("data","data",theTree,cols); data0->Print(); // // } // //data = ( RooDataSet*) data0->reduce(EventRange(0,100000));//,Cut("invariantMass<11")); TString cut_ap(Form("(%d<=Centrality && Centrality<%d) && (%.2f<muPlusEta && muPlusEta < %.2f) && (%.2f<muMinusEta && muMinusEta < %.2f) && (%.2f<upsPt && upsPt<%.2f) &&(abs(upsRapidity)>%.2f && abs(upsRapidity)<%.2f) &&((muPlusPt > %.2f && muMinusPt > %.2f) || (muPlusPt > %.2f && muMinusPt > %.2f))",upsCentralityStart,upsCentralityEnd,muonEtaMin,muonEtaMax,muonEtaMin,muonEtaMax,upsPtMin,upsPtMax,upsRapMin,upsRapMax,muonPtMin,muonPtMax,muonPtMax,muonPtMin)); cout << cut_ap << endl; data = ( RooDataSet*) data0->reduce(Cut(cut_ap)); ws.import(*data); data->Print(); f->Close(); }
void Config() { // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00 // Theta range given through pseudorapidity limits 22/6/2001 // Set Random Number seed //gRandom->SetSeed(123456); // Set 0 to use the current time AliLog::Message(AliLog::kInfo, Form("Seed for random number generation = %d",gRandom->GetSeed()), "Config.C", "Config.C", "Config()","Config.C", __LINE__); // Load Pythia libraries LoadPythia(); // Libraries required by geant321 Bool_t isFluka = kTRUE; if (isFluka) { gSystem->Load("libGeom"); cout << "\t* Loading TFluka..." << endl; gSystem->Load("libfluka"); cout << "\t* Instantiating TFluka..." << endl; new TFluka("C++ Interface to Fluka", 0/*verbositylevel*/); } else { cout << "\t* Loading Geant3..." << endl; gSystem->Load("libgeant321"); cout << "\t* Instantiating Geant3TGeo..." << endl; new TGeant3TGeo("C++ Interface to Geant3"); } AliRunLoader* rl=0x0; AliLog::Message(AliLog::kInfo, "Creating Run Loader", "Config.C", "Config.C", "Config()"," Config.C", __LINE__); rl = AliRunLoader::Open("galice.root", AliConfig::GetDefaultEventFolderName(), "recreate"); if (rl == 0x0) { gAlice->Fatal("Config.C","Can not instatiate the Run Loader"); return; } rl->SetCompressionLevel(2); rl->SetNumberOfEventsPerFile(3); gAlice->SetRunLoader(rl); // gAlice->SetGeometryFromFile("geometry.root"); // Uncomment if you want to load geometry from OCDB! >>>> /* if(!AliCDBManager::Instance()->IsDefaultStorageSet()){ cout << "#####################################################" << endl; cout << "# #" << endl; cout << "# WARNING: CDB DEFAULT STORAGE NOT SET !!! #" << endl; cout << "# SETTING IT TO local://$ALICE_ROOT/OCDB !!! #" << endl; cout << "# #" << endl; cout << "#####################################################" << endl; AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); } if(AliCDBManager::Instance()->GetRun() < 0){ cout << "#####################################################" << endl; cout << "# #" << endl; cout << "# WARNING: RUN NUMBER NOT SET !!! #" << endl; cout << "# SETTING IT TO 0 !!! #" << endl; cout << "# #" << endl; cout << "#####################################################" << endl; AliCDBManager::Instance()->SetRun(0); } gAlice->SetGeometryFromCDB(); */ // Uncomment if you want to load geometry from OCDB! <<<< // Set the trigger configuration AliSimulation::Instance()->SetTriggerConfig("Pb-Pb"); cout<<"Trigger configuration is set to Pb-Pb"<<endl; // // Set External decayer TVirtualMCDecayer *decayer = new AliDecayerPythia(); decayer->SetForceDecay(kAll); decayer->Init(); gMC->SetExternalDecayer(decayer); //======================================================================= // ************* STEERING parameters FOR ALICE SIMULATION ************** // --- Specify event type to be tracked through the ALICE setup // --- All positions are in cm, angles in degrees, and P and E in GeV gMC->SetProcess("DCAY",1); gMC->SetProcess("PAIR",1); gMC->SetProcess("COMP",1); gMC->SetProcess("PHOT",1); gMC->SetProcess("PFIS",0); gMC->SetProcess("DRAY",0); gMC->SetProcess("ANNI",1); gMC->SetProcess("BREM",1); gMC->SetProcess("MUNU",1); gMC->SetProcess("CKOV",1); gMC->SetProcess("HADR",1); gMC->SetProcess("LOSS",2); gMC->SetProcess("MULS",1); gMC->SetProcess("RAYL",1); Float_t cut = 1.e-3; // 1MeV cut by default Float_t tofmax = 1.e10; gMC->SetCut("CUTGAM", cut); gMC->SetCut("CUTELE", cut); gMC->SetCut("CUTNEU", cut); gMC->SetCut("CUTHAD", cut); gMC->SetCut("CUTMUO", cut); gMC->SetCut("BCUTE", cut); gMC->SetCut("BCUTM", cut); gMC->SetCut("DCUTE", cut); gMC->SetCut("DCUTM", cut); gMC->SetCut("PPCUTM", cut); gMC->SetCut("TOFMAX", tofmax); int nParticles = 100; if (gSystem->Getenv("CONFIG_NPARTICLES")) { nParticles = atoi(gSystem->Getenv("CONFIG_NPARTICLES")); } AliGenCocktail *gener = new AliGenCocktail(); gener->SetPhiRange(0, 360); // Set pseudorapidity range from -8 to 8. Float_t thmin = EtaToTheta(8); // theta min. <---> eta max Float_t thmax = EtaToTheta(-8); // theta max. <---> eta min gener->SetThetaRange(thmin,thmax); gener->SetOrigin(0, 0, 0); //vertex position gener->SetSigma(0, 0, 0); //Sigma in (X,Y,Z) (cm) on IP position AliGenHIJINGpara *hijingparam = new AliGenHIJINGpara(nParticles); hijingparam->SetMomentumRange(0.2, 999); gener->AddGenerator(hijingparam,"HIJING PARAM",1); // AliGenBox *genbox = new AliGenBox(nParticles); // genbox->SetPart(kGamma); // genbox->SetPtRange(0.3, 10.00); // gener->AddGenerator(genbox,"GENBOX GAMMA for PHOS",1); gener->Init(); // // Activate this line if you want the vertex smearing to happen // track by track // //gener->SetVertexSmear(perTrack); // Field (L3 0.4 T) TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG)); Int_t iABSO = 1; Int_t iDIPO = 1; Int_t iFMD = 1; Int_t iFRAME = 1; Int_t iHALL = 1; Int_t iITS = 1; Int_t iMAG = 1; Int_t iMUON = 1; Int_t iPHOS = 1; Int_t iPIPE = 1; Int_t iPMD = 1; Int_t iHMPID = 1; Int_t iSHIL = 1; Int_t iT0 = 1; Int_t iTOF = 1; Int_t iTPC = 1; Int_t iTRD = 1; Int_t iZDC = 1; Int_t iEMCAL = 1; Int_t iACORDE = 1; Int_t iVZERO = 1; rl->CdGAFile(); //=================== Alice BODY parameters ============================= AliBODY *BODY = new AliBODY("BODY", "Alice envelop"); if (iMAG) { //=================== MAG parameters ============================ // --- Start with Magnet since detector layouts may be depending --- // --- on the selected Magnet dimensions --- AliMAG *MAG = new AliMAG("MAG", "Magnet"); } if (iABSO) { //=================== ABSO parameters ============================ AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber"); } if (iDIPO) { //=================== DIPO parameters ============================ AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3"); } if (iHALL) { //=================== HALL parameters ============================ AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall"); } if (iFRAME) { //=================== FRAME parameters ============================ AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame"); FRAME->SetHoles(1); } if (iSHIL) { //=================== SHIL parameters ============================ AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3"); } if (iPIPE) { //=================== PIPE parameters ============================ AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe"); } if (iITS) { //=================== ITS parameters ============================ AliITS *ITS = new AliITSv11("ITS","ITS v11"); } if (iTPC) { //============================ TPC parameters =================== AliTPC *TPC = new AliTPCv2("TPC", "Default"); TPC->SetPrimaryIonisation(); } if (iTOF) { //=================== TOF parameters ============================ AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF"); } if (iHMPID) { //=================== HMPID parameters =========================== AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID"); } if (iZDC) { //=================== ZDC parameters ============================ AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC"); } if (iTRD) { //=================== TRD parameters ============================ AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator"); } if (iFMD) { //=================== FMD parameters ============================ AliFMD *FMD = new AliFMDv1("FMD", "normal FMD"); } if (iMUON) { //=================== MUON parameters =========================== // New MUONv1 version (geometry defined via builders) AliMUON *MUON = new AliMUONv1("MUON", "default"); } //=================== PHOS parameters =========================== if (iPHOS) { AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP"); } if (iPMD) { //=================== PMD parameters ============================ AliPMD *PMD = new AliPMDv1("PMD", "normal PMD"); } if (iT0) { //=================== T0 parameters ============================ AliT0 *T0 = new AliT0v1("T0", "T0 Detector"); } if (iEMCAL) { //=================== EMCAL parameters ============================ AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETE"); } if (iACORDE) { //=================== ACORDE parameters ============================ AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE"); } if (iVZERO) { //=================== VZERO parameters ============================ AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO"); } AliLog::Message(AliLog::kInfo, "End of Config", "Config.C", "Config.C", "Config()"," Config.C", __LINE__); }