From 08d1eafc6734ae906de71a4380e5afad927998c0 Mon Sep 17 00:00:00 2001 From: Victor Schwan Date: Fri, 29 May 2026 13:22:02 +0200 Subject: [PATCH 1/5] Add .clang-format copied from key4hep --- .clang-format | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..c788190 --- /dev/null +++ b/.clang-format @@ -0,0 +1,236 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterAttributes: Never +BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLinesAtEOF: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... + From 81b289e17e7d3776b68c4b8656e9ce522f58b9ab Mon Sep 17 00:00:00 2001 From: Victor Schwan Date: Fri, 29 May 2026 13:23:02 +0200 Subject: [PATCH 2/5] Format all cpp,h,C files --- PID/include/PIDTree.h | 117 ++- PID/macros/PIDHelper.h | 10 +- PID/macros/plotPIDEfficiency.C | 802 +++++++++--------- PID/macros/plotPIDLike.C | 206 ++--- PID/macros/plotPIDPurity.C | 384 ++++----- PID/macros/plotPIDs.C | 297 ++++--- PID/macros/plotdEdx.C | 216 ++--- PID/macros/rootlogon.C | 164 ++-- .../plotting/draw_tof_singleparticle.cpp | 266 +++--- .../macros/plotting/draw_tof_ttbar.cpp | 262 +++--- TimeOfFlight/macros/plotting/tof_helpers.cpp | 229 ++--- .../macros/reading_config/read_config.cpp | 154 ++-- .../processor/include/EventInformation.h | 120 ++- .../processor/include/StandardIncludes.h | 21 +- .../processor/include/VpairFinder.h | 135 ++- .../processor/include/WWZZProcessor.h | 160 ++-- dEdX/include/ILDStyle_Standalone.h | 166 ++-- dEdX/include/dEdxAnalyser.h | 275 +++--- kinfit/macros/WW5CFit_compare.C | 105 ++- kinfit/macros/ZH5CFit_compare.C | 221 ++--- kinfit/macros/ZHWW5CFit_compare.C | 168 ++-- kinfit/macros/rootlogon.C | 164 ++-- pi0/include/pi0Tree.h | 126 ++- pi0/macros/plotERes.C | 92 +- pi0/macros/plotEffi.C | 72 +- pi0/macros/rootlogon.C | 164 ++-- .../include/validateDST_SinglePhoton.h | 80 +- trackerHitCtr/include/TrackerHitCounter.h | 162 ++-- tracking/include/DDDiagnostics.h | 201 +++-- tracking/include/Residuals.h | 121 ++- tracking/include/Skim.h | 48 +- tracking/macros/BadTracks.C | 13 +- tracking/macros/ComparePulls.C | 82 +- tracking/macros/CompareResiduals.C | 45 +- tracking/macros/D0Resolution.C | 229 +++-- tracking/macros/D0ResolutionL5.C | 284 +++---- tracking/macros/D0Resolution_comp.C | 482 +++++------ tracking/macros/Efficiency.C | 10 +- tracking/macros/EfficiencyL5.C | 53 +- tracking/macros/PResolution.C | 280 +++--- tracking/macros/PResolutionL5.C | 320 ++++--- tracking/macros/PResolution_comp.C | 523 ++++++------ tracking/macros/PatRec.C | 15 +- tracking/macros/Plots.C | 19 +- tracking/macros/Pulls.C | 32 +- tracking/macros/Residuals.C | 9 +- tracking/macros/eff_comp.C | 62 +- tracking/macros/mean.C | 535 ++++++------ tracking/macros/meanL5.C | 584 ++++++------- tracking/macros/rootlogon.C | 164 ++-- tracking/macros/sigma.C | 535 ++++++------ tracking/macros/sigmaL5.C | 589 ++++++------- validateSim/include/valStruct.h | 18 +- validateSim/include/validateAuto.h | 96 +-- validateSim/include/validatePilot.h | 63 +- validateSim/test/plotauto.C | 278 +++--- 56 files changed, 5362 insertions(+), 5666 deletions(-) diff --git a/PID/include/PIDTree.h b/PID/include/PIDTree.h index 96bf4a0..dce646f 100644 --- a/PID/include/PIDTree.h +++ b/PID/include/PIDTree.h @@ -3,40 +3,36 @@ #include +#include "UTIL/LCIterator.h" +#include "UTIL/LCRelationNavigator.h" +#include "UTIL/LCTrackerConf.h" +#include "UTIL/Operators.h" #include -#include #include #include +#include #include -#include "UTIL/LCRelationNavigator.h" -#include "UTIL/LCIterator.h" -#include "UTIL/Operators.h" #include -#include "UTIL/LCTrackerConf.h" #include - #include - /** PIDTree processor * fills a ROOT tree with mcparticle - reco / PID info * which can be used in order to produce hermeticity plots * authors: Jenny List -*/ + */ class PIDTree : public marlin::Processor { - - public: - - PIDTree(const PIDTree&) = delete ; - PIDTree& operator=(const PIDTree&) = delete ; - - virtual Processor* newProcessor() { return new PIDTree ; } - - - PIDTree() ; - + +public: + PIDTree(const PIDTree&) = delete; + PIDTree& operator=(const PIDTree&) = delete; + + virtual Processor* newProcessor() { return new PIDTree; } + + PIDTree(); + /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ @@ -44,65 +40,57 @@ class PIDTree : public marlin::Processor { /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; - + virtual void processRunHeader(LCRunHeader* run); + /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; - - - virtual void check( LCEvent * evt ) ; - - - /** Called after data processing for clean up. - */ - virtual void end() ; + virtual void processEvent(LCEvent* evt); - + virtual void check(LCEvent* evt); + /** Called after data processing for clean up. + */ + virtual void end(); - protected: - +protected: /** Input collection name. */ - std::string _trueToReco {}; - std::string _trueToTrack {}; - std::string _recoToTrue {}; - std::string _mcParticleCollectionName {}; - std::string _trackColName {}; - std::string _BCALParticleCollectionName {}; - std::string _BCALClusterCollectionName {}; - std::string _pandoraPFOs {}; + std::string _trueToReco{}; + std::string _trueToTrack{}; + std::string _recoToTrue{}; + std::string _mcParticleCollectionName{}; + std::string _trackColName{}; + std::string _BCALParticleCollectionName{}; + std::string _BCALClusterCollectionName{}; + std::string _pandoraPFOs{}; int nEvt = 0; float _bField = 0.; - - private: - +private: // declaration of trees - TTree *hermTree = nullptr ; - int nMCParticles = 0; - + TTree* hermTree = nullptr; + int nMCParticles = 0; + std::vector trueP{}; std::vector trueMass{}; - std::vector truePt {}; - std::vector trueTheta {}; - std::vector truePhi {}; + std::vector truePt{}; + std::vector trueTheta{}; + std::vector truePhi{}; std::vector trueCharge{}; - std::vector truePDG{}; - std::vector trueMother{}; - std::vector isTrue{}; // store max weight of reco -> truth - std::vector isSeen{}; // store max weight of truth -> reco - std::vector isSeenDEdx {}; // store max weight of truth -> track + std::vector truePDG{}; + std::vector trueMother{}; + std::vector isTrue{}; // store max weight of reco -> truth + std::vector isSeen{}; // store max weight of truth -> reco + std::vector isSeenDEdx{}; // store max weight of truth -> track std::vector seenP{}; - std::vector seenPt {}; - std::vector seenTheta {}; - std::vector seenPhi {}; - std::vector seenDEdx {}; - std::vector seenDEdxErr {}; - std::vector seenCharge {}; + std::vector seenPt{}; + std::vector seenTheta{}; + std::vector seenPhi{}; + std::vector seenDEdx{}; + std::vector seenDEdxErr{}; + std::vector seenCharge{}; std::vector basicPDG{}; std::vector dEdxPDG{}; std::vector showerPDG{}; @@ -126,11 +114,6 @@ class PIDTree : public marlin::Processor { std::vector dedxPDG_pi{}; std::vector dedxPDG_ka{}; std::vector dedxPDG_pr{}; - -} ; - +}; #endif - - - diff --git a/PID/macros/PIDHelper.h b/PID/macros/PIDHelper.h index 629bcbf..da95bf5 100644 --- a/PID/macros/PIDHelper.h +++ b/PID/macros/PIDHelper.h @@ -12,13 +12,13 @@ std::string getPathPrefix(const std::string& fileName) { char sep = '/'; - - std::string path = "./" ; + + std::string path = "./"; size_t i = fileName.rfind(sep, fileName.length()); if (i != std::string::npos) { - path = fileName.substr(0, i+1 ) ; + path = fileName.substr(0, i + 1); } - - return path ; + + return path; } diff --git a/PID/macros/plotPIDEfficiency.C b/PID/macros/plotPIDEfficiency.C index 354dadd..e6de9f1 100644 --- a/PID/macros/plotPIDEfficiency.C +++ b/PID/macros/plotPIDEfficiency.C @@ -1,77 +1,76 @@ -#include #include +#include -#include "TTree.h" #include "TFile.h" #include "TH1F.h" #include "TString.h" +#include "TTree.h" #include "PIDHelper.h" using namespace std; -void make_plots(const char* filename, const char* pidName, int pdgCode, const TString& pdfFile ) ; +void make_plots(const char* filename, const char* pidName, int pdgCode, const TString& pdfFile); -/// plot the PID efficiency and fake rate for a given particle type for various PID algorithms as function of momentum and polar angle +/// plot the PID efficiency and fake rate for a given particle type for various PID algorithms as function of momentum +/// and polar angle void plotPIDEfficiency(const char* filename) { - TString pdfFile = getPathPrefix( filename ) ; - pdfFile += "PID_efficiencies_all.pdf" ; - - make_plots( filename, "basicPDG", 11 , pdfFile+"(" ); // first plot - make_plots( filename, "basicPDG", 13 , pdfFile ); - make_plots( filename, "basicPDG", 211 , pdfFile ); - make_plots( filename, "basicPDG", 321 , pdfFile ); - make_plots( filename, "basicPDG", 2212, pdfFile ); - - make_plots( filename, "dEdxPDG", 11 , pdfFile ); - make_plots( filename, "dEdxPDG", 13 , pdfFile ); - make_plots( filename, "dEdxPDG", 211 , pdfFile ); - make_plots( filename, "dEdxPDG", 321 , pdfFile ); - make_plots( filename, "dEdxPDG", 2212, pdfFile ); - - make_plots( filename, "showerPDG", 11 , pdfFile ); - make_plots( filename, "showerPDG", 13 , pdfFile ); - make_plots( filename, "showerPDG", 211 , pdfFile ); - make_plots( filename, "showerPDG", 321 , pdfFile ); - make_plots( filename, "showerPDG", 2212, pdfFile ); - - make_plots( filename, "likeliPDG", 11 , pdfFile ); - make_plots( filename, "likeliPDG", 13 , pdfFile ); - make_plots( filename, "likeliPDG", 211 , pdfFile ); - make_plots( filename, "likeliPDG", 321 , pdfFile ); - make_plots( filename, "likeliPDG", 2212, pdfFile ); - - make_plots( filename, "lowmomPDG", 11 , pdfFile ); - make_plots( filename, "lowmomPDG", 13 , pdfFile ); - make_plots( filename, "lowmomPDG", 211 , pdfFile ); - make_plots( filename, "lowmomPDG", 321 , pdfFile ); - make_plots( filename, "lowmomPDG", 2212, pdfFile+")" ); // last plot + TString pdfFile = getPathPrefix(filename); + pdfFile += "PID_efficiencies_all.pdf"; + + make_plots(filename, "basicPDG", 11, pdfFile + "("); // first plot + make_plots(filename, "basicPDG", 13, pdfFile); + make_plots(filename, "basicPDG", 211, pdfFile); + make_plots(filename, "basicPDG", 321, pdfFile); + make_plots(filename, "basicPDG", 2212, pdfFile); + + make_plots(filename, "dEdxPDG", 11, pdfFile); + make_plots(filename, "dEdxPDG", 13, pdfFile); + make_plots(filename, "dEdxPDG", 211, pdfFile); + make_plots(filename, "dEdxPDG", 321, pdfFile); + make_plots(filename, "dEdxPDG", 2212, pdfFile); + + make_plots(filename, "showerPDG", 11, pdfFile); + make_plots(filename, "showerPDG", 13, pdfFile); + make_plots(filename, "showerPDG", 211, pdfFile); + make_plots(filename, "showerPDG", 321, pdfFile); + make_plots(filename, "showerPDG", 2212, pdfFile); + + make_plots(filename, "likeliPDG", 11, pdfFile); + make_plots(filename, "likeliPDG", 13, pdfFile); + make_plots(filename, "likeliPDG", 211, pdfFile); + make_plots(filename, "likeliPDG", 321, pdfFile); + make_plots(filename, "likeliPDG", 2212, pdfFile); + + make_plots(filename, "lowmomPDG", 11, pdfFile); + make_plots(filename, "lowmomPDG", 13, pdfFile); + make_plots(filename, "lowmomPDG", 211, pdfFile); + make_plots(filename, "lowmomPDG", 321, pdfFile); + make_plots(filename, "lowmomPDG", 2212, pdfFile + ")"); // last plot } - void make_plots(const char* filename, const char* pidName, int pdgCode, const TString& pdfFile) { - std::string pName("unknown") ; - switch( pdgCode ){ + std::string pName("unknown"); + switch (pdgCode) { case 11: - pName = "electrons" ; - break ; + pName = "electrons"; + break; case 13: - pName = "muons" ; - break ; + pName = "muons"; + break; case 211: - pName = "pions" ; - break ; + pName = "pions"; + break; case 321: - pName = "kaons" ; - break ; + pName = "kaons"; + break; case 2212: - pName = "protons" ; - break ; + pName = "protons"; + break; } - gROOT->SetStyle("ildStyle"); ildStyle->SetOptTitle(1); ildStyle->SetHistLineWidth(2); @@ -82,402 +81,381 @@ void make_plots(const char* filename, const char* pidName, int pdgCode, const TS ildStyle->SetCanvasColor(0); ildStyle->SetTitleColor(1); ildStyle->SetStatColor(0); -// ildStyle->SetOptStat(1110010); + // ildStyle->SetOptStat(1110010); ildStyle->SetOptStat(10); - //ildStyle->SetOptFit(10); - ildStyle->SetPadBottomMargin(0.15); + // ildStyle->SetOptFit(10); + ildStyle->SetPadBottomMargin(0.15); ildStyle->SetPadTopMargin(0.10); ildStyle->SetPadRightMargin(0.025); ildStyle->SetPadLeftMargin(0.2); - + ildStyle->SetMarkerStyle(20); ildStyle->SetMarkerSize(0.625); - // --- open the file ----- - TFile *treefile = new TFile(filename); - TTree *tree = (TTree*) treefile->Get("hermTree"); - + TFile* treefile = new TFile(filename); + TTree* tree = (TTree*)treefile->Get("hermTree"); //************** create some histograms ************** + const int nBins = 9; // made edit to creat histograms- i.e. define variable + double bins[nBins + 1] = {0.1, 0.5, 1.0, 2., 5.0, 10., 20., 50., 100., 300.}; + // const int nBins = 13 ; //made edit to creat histograms- i.e. define variable + // double bins[nBins+1] = { 0.01, 0.1, 0.2, 0.3, 0.5 , 0.7 , 1.0 , 2., 5.0 , 10. , 20. , 50. , 100. , 300. } ; - - const int nBins = 9 ; //made edit to creat histograms- i.e. define variable - double bins[nBins+1] = { 0.1, 0.5 , 1.0 , 2., 5.0 , 10. , 20. , 50. , 100. , 300. } ; - // const int nBins = 13 ; //made edit to creat histograms- i.e. define variable - // double bins[nBins+1] = { 0.01, 0.1, 0.2, 0.3, 0.5 , 0.7 , 1.0 , 2., 5.0 , 10. , 20. , 50. , 100. , 300. } ; + TH1F* hist_p_t = new TH1F("hist_p_t", "P of true particles", nBins, bins); + TH1F* hist_Sp_t = new TH1F("hist_Sp_t", "P of observed particles", nBins, bins); + TH1F* hist_th_t = new TH1F("hist_th_t", "Cos theta of true particles", 11, -1., 1.); + TH1F* hist_Sth_t = new TH1F("hist_Sth_t", "Cos theta of observed particles", 11, -1., 1.); + TH1F* hist_p_tnot = new TH1F("hist_p_tnot", "P of true particles which are not of the type in question", nBins, bins); + TH1F* hist_th_tnot = + new TH1F("hist_th_tnot", "Cos theta of true particles which are not of the type in question", 11, -1., 1.); + TH1F* hist_Failed_p = new TH1F("hist_Failed_p", "Tagging of falsely identified particles (momentum)", nBins, bins); - TH1F* hist_p_t = new TH1F( "hist_p_t", "P of true particles", nBins , bins ) ; - TH1F* hist_Sp_t = new TH1F( "hist_Sp_t", "P of observed particles", nBins , bins ) ; - - TH1F* hist_th_t = new TH1F( "hist_th_t", "Cos theta of true particles", 11, -1., 1. ) ; - TH1F* hist_Sth_t = new TH1F( "hist_Sth_t", "Cos theta of observed particles", 11, -1., 1. ) ; - - TH1F* hist_p_tnot = new TH1F("hist_p_tnot", "P of true particles which are not of the type in question", nBins, bins ); - TH1F* hist_th_tnot = new TH1F("hist_th_tnot", "Cos theta of true particles which are not of the type in question", 11, -1., 1. ) ; + TH1F* hist_Failed_th = new TH1F("hist_Failed_th", "Tagging of falsely identified particles (cos theta)", 11, -1., 1.); - TH1F* hist_Failed_p = new TH1F( "hist_Failed_p", "Tagging of falsely identified particles (momentum)", nBins, bins ); - - TH1F* hist_Failed_th = new TH1F( "hist_Failed_th", "Tagging of falsely identified particles (cos theta)", 11, -1., 1. ); - - //********************************************************************************************** + //********************************************************************************************** // read branches int npart; - vector *truePDG = new vector ; - vector *isSeen = new vector ; - vector *thePDG = new vector ; - vector *trueCharge = new vector ; - vector *seenCharge = new vector ; - vector *trueP = new vector ; - vector *trueTheta = new vector ; - vector *seenTheta = new vector ; - vector *seenP = new vector ; - tree->SetBranchAddress("nMCParticles", &npart); - tree->SetBranchAddress("trueCharge", &trueCharge); - tree->SetBranchAddress("truePDG", &truePDG); - tree->SetBranchAddress("isSeen", &isSeen); - tree->SetBranchAddress("seenCharge", &seenCharge); - - tree->SetBranchAddress(pidName, &thePDG); + vector* truePDG = new vector; + vector* isSeen = new vector; + vector* thePDG = new vector; + vector* trueCharge = new vector; + vector* seenCharge = new vector; + vector* trueP = new vector; + vector* trueTheta = new vector; + vector* seenTheta = new vector; + vector* seenP = new vector; + tree->SetBranchAddress("nMCParticles", &npart); + tree->SetBranchAddress("trueCharge", &trueCharge); + tree->SetBranchAddress("truePDG", &truePDG); + tree->SetBranchAddress("isSeen", &isSeen); + tree->SetBranchAddress("seenCharge", &seenCharge); + + tree->SetBranchAddress(pidName, &thePDG); tree->SetBranchAddress("trueP", &trueP); tree->SetBranchAddress("trueTheta", &trueTheta); tree->SetBranchAddress("seenTheta", &seenTheta); tree->SetBranchAddress("seenP", &seenP); - - // ************************* loop over events and particles in tree ***************************** int nevts = tree->GetEntries(); - + for (int ievt = 0; ievt < nevts; ++ievt) { - + tree->GetEntry(ievt); - - for (int ipart = 0; ipart < npart; ipart++) { - - if ( isSeen->at(ipart ) < 0.5 ) continue ;// require MC-truth link weight to be > 0.5 - - if( seenCharge->at( ipart ) == 0 ) continue; // only look at charged - - if( std::abs( truePDG->at( ipart ) ) != pdgCode ) continue ; - - hist_p_t->Fill( trueP->at(ipart) ) ; - - hist_th_t->Fill( cos( trueTheta->at(ipart) ) ) ; - - if( std::abs( thePDG->at(ipart)) != pdgCode ) continue; - - hist_Sp_t->Fill( trueP->at(ipart) ); - - hist_Sth_t->Fill( cos( trueTheta->at(ipart))); - - } - - for (int ipart = 0; ipart < npart; ipart++) { - - if ( isSeen->at(ipart ) < 0.5 ) continue ;// require MC-truth link weight to be > 0.5 - - if( seenCharge->at( ipart ) == 0 ) continue; // only look at charged - - if( std::abs( truePDG->at( ipart ) ) == pdgCode ) continue ; - - hist_p_tnot->Fill( trueP->at(ipart) ) ; - - hist_th_tnot ->Fill( cos( trueTheta->at(ipart) ) ) ; - - if( std::abs( thePDG->at(ipart)) != pdgCode ) continue; - - hist_Failed_p->Fill( trueP->at(ipart) ); - - hist_Failed_th->Fill( cos( trueTheta->at(ipart))); - + + for (int ipart = 0; ipart < npart; ipart++) { + + if (isSeen->at(ipart) < 0.5) + continue; // require MC-truth link weight to be > 0.5 + + if (seenCharge->at(ipart) == 0) + continue; // only look at charged + + if (std::abs(truePDG->at(ipart)) != pdgCode) + continue; + + hist_p_t->Fill(trueP->at(ipart)); + + hist_th_t->Fill(cos(trueTheta->at(ipart))); + + if (std::abs(thePDG->at(ipart)) != pdgCode) + continue; + + hist_Sp_t->Fill(trueP->at(ipart)); + + hist_Sth_t->Fill(cos(trueTheta->at(ipart))); } + for (int ipart = 0; ipart < npart; ipart++) { + + if (isSeen->at(ipart) < 0.5) + continue; // require MC-truth link weight to be > 0.5 + + if (seenCharge->at(ipart) == 0) + continue; // only look at charged + + if (std::abs(truePDG->at(ipart)) == pdgCode) + continue; + + hist_p_tnot->Fill(trueP->at(ipart)); + + hist_th_tnot->Fill(cos(trueTheta->at(ipart))); + + if (std::abs(thePDG->at(ipart)) != pdgCode) + continue; + + hist_Failed_p->Fill(trueP->at(ipart)); + + hist_Failed_th->Fill(cos(trueTheta->at(ipart))); + } } - - - TCanvas* c = new TCanvas( " PID efficiency" , "Efficiency" ,750 ,750); - c->Divide(2,3) ; - - c->cd(1) ; - gPad->SetLogx() ; - - - hist_p_t->GetXaxis()->SetTitle("true P/GeV" ); - hist_p_t->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_p_t->GetXaxis()->SetTitleOffset( 1.2 ); - - hist_p_t->Draw() ; - - c->cd(2) ; - - hist_th_t->GetXaxis()->SetTitle( "true cos(#theta)" ); - hist_th_t->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_th_t->GetXaxis()->SetTitleOffset( 1.3 ); - hist_th_t->Draw() ; - - - - c->cd(3) ; - gPad->SetLogx() ; - hist_Sp_t->Draw() ; - - hist_p_t->GetXaxis()->SetTitle( "true P/GeV" ); - hist_p_t->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_p_t->GetXaxis()->SetTitleOffset( 1.2 ); - - - - c->cd(4) ; - hist_Sth_t->Draw() ; - - hist_Sth_t->GetXaxis()->SetTitle("true cos(#theta)" ); - hist_Sth_t->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_Sth_t->GetXaxis()->SetTitleOffset( 1.2 ); - - - c->cd(5); - //hist_p_t.Sumw2(); - //hist_Sp_t.Sumw2(); - - TGraphAsymmErrors* hist_eff_p = new TGraphAsymmErrors ; - hist_eff_p->Divide(hist_Sp_t, hist_p_t, "v"); - - hist_eff_p->Draw(); - - gPad->SetLogx() ; - hist_eff_p->SetName(" hist_eff_p" ) ; - - //histo->SetTitle(";x "#epsilon";y"true P/GeV""); - - hist_eff_p->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - hist_eff_p->GetYaxis()->SetTitleSize( 0.06 ) ; - hist_eff_p->GetYaxis()->SetTitleOffset( 0.5 ); - - hist_eff_p->GetXaxis()->SetTitle("true P/GeV" ); - hist_eff_p->GetXaxis()->SetTitleSize( 0.06 ) ; - hist_eff_p->GetXaxis()->SetTitleOffset( 1.2 ); - - - c->cd(6); - //hist_th_t.Sumw2(); - //hist_Sth_t.Sumw2(); - - TGraphAsymmErrors* hist_eff_th = new TGraphAsymmErrors ; - hist_eff_th->Divide(hist_Sth_t, hist_th_t, "v"); - hist_eff_th->Draw(); - hist_eff_th->SetName(" hist_eff_th" ) ; - - - hist_eff_th->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - hist_eff_th->GetYaxis()->SetTitleSize( 0.06 ) ; - hist_eff_th->GetYaxis()->SetTitleOffset( 0.5 ); - - hist_eff_th->GetXaxis()->SetTitle( "true cos(#theta)" ); - hist_eff_th->GetXaxis()->SetTitleSize( 0.06 ) ; - hist_eff_th->GetXaxis()->SetTitleOffset( 0.9 ); - - - TString outfile = getPathPrefix( filename ) ; - outfile += "PID_efficiencies_pdg"; - outfile += pdgCode ; - //c->Print(TString(outfile+".pdf")); - - TCanvas* k = new TCanvas( " PID Failed " , " PID Failed " ,750 ,750); - k->Divide(2,3) ; - - k->cd(1); - gPad->SetLogx() ; - - hist_p_tnot->GetXaxis()->SetTitle("true P/GeV" ); - hist_p_tnot->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_p_tnot->GetXaxis()->SetTitleOffset( 1.2 ); - hist_p_tnot->Draw(); - - k->cd(2); - hist_th_tnot->GetXaxis()->SetTitle( "true cos(#theta)" ); - hist_th_tnot->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_th_tnot->GetXaxis()->SetTitleOffset( 1.2 ); - hist_th_tnot->Draw(); - - k->cd(3); - gPad->SetLogx() ; - hist_Failed_p->GetXaxis()->SetTitle( "true P/GeV" ); - hist_Failed_p->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_Failed_p->GetXaxis()->SetTitleOffset( 1.2 ); - hist_Failed_p->Draw(); - - k->cd(4); - hist_Failed_th->GetXaxis()->SetTitle("true cos(#theta)" ); - hist_Failed_th->GetXaxis()->SetTitleSize( 0.04 ) ; - hist_Failed_th->GetXaxis()->SetTitleOffset( 1.2 ); - hist_Failed_th->Draw(); - - k->cd(5); - - TGraphAsymmErrors* hist_FailRate_p = new TGraphAsymmErrors ; - hist_FailRate_p->Divide( hist_Failed_p, hist_p_tnot, "v" ); - gPad->SetLogx() ; - - hist_FailRate_p->GetYaxis()->SetTitle( "Fake Rate" ); - hist_FailRate_p->GetYaxis()->SetTitleSize( 0.06 ) ; - hist_FailRate_p->GetYaxis()->SetTitleOffset( 1. ); - - hist_FailRate_p->GetXaxis()->SetTitle("true P/GeV" ); - hist_FailRate_p->GetXaxis()->SetTitleSize( 0.06 ) ; - hist_FailRate_p->GetXaxis()->SetTitleOffset( 1.2 ); - - hist_FailRate_p->Draw(); - hist_FailRate_p->SetName(" hist_FailRate_p" ) ; - - k->cd(6); - - TGraphAsymmErrors* hist_FailRate_th = new TGraphAsymmErrors ; - - hist_FailRate_th->Divide( hist_Failed_th, hist_th_tnot, "v" ); - - hist_FailRate_th->GetYaxis()->SetTitle( "Fake Rate" ); - hist_FailRate_th->GetYaxis()->SetTitleSize( 0.06 ) ; - hist_FailRate_th->GetYaxis()->SetTitleOffset( 1. ); - - hist_FailRate_th->GetXaxis()->SetTitle( "true cos(#theta)" ); - hist_FailRate_th->GetXaxis()->SetTitleSize( 0.06 ) ; - hist_FailRate_th->GetXaxis()->SetTitleOffset( 0.9 ); - - hist_FailRate_th->Draw(); - - hist_FailRate_th->SetName(" hist_FailRate_th" ) ; - - outfile = getPathPrefix( filename ) ; - outfile += "PID_Failed_pdg"; - outfile += pdgCode ; - // k->Print(TString(outfile+".pdf")); - - // ------ draw them both in one plot -------------------- - - /// create an empty histogram to set the axes range: - - float minEff = 0. ; - float maxEff = 1.01 ; - float minpt = 0.1 ; - float maxpt = 100. ; - float minct = -1. ; - float maxct = 1. ; - - std::stringstream pTitleS ; - pTitleS << "PID efficiency/fake rate vs P [" << pidName << "] - " << pName ; - std::stringstream cTitleS ; - cTitleS << "PID efficiency/fake rate vs cos(theta) [" << pidName << "] - " << pName ; - - TH2F* hpt = new TH2F( "hpt", pTitleS.str().c_str() ,10, minpt, maxpt, 10, minEff , maxEff ) ; - TH2F* hth = new TH2F( "hth", cTitleS.str().c_str() , 10, minct, maxct, 10, minEff , maxEff ) ; - - - TCanvas* c2 = new TCanvas( "c2" , "Efficiency and Fake Rate" ,750 ,750); - - c2->Divide(1,2) ; - ildStyle->SetOptStat(0000); - c2->cd(1) ; - gPad->SetLogx() ; - hpt->Draw() ; - - hpt->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - hpt->GetYaxis()->SetTitleSize( 0.06 ) ; - hpt->GetYaxis()->SetTitleOffset( 0.5 ); - - hpt->GetXaxis()->SetTitle("true P/GeV" ); - hpt->GetXaxis()->SetTitleSize( 0.06 ) ; - hpt->GetXaxis()->SetTitleOffset( 1.2 ); - - hpt->GetEntries(); - - hist_eff_p->SetMarkerStyle( kOpenTriangleUp ) ; // kDot) ; //kOpenCircle) ; - hist_eff_p->SetMarkerColor( kBlue) ; - hist_eff_p->SetLineColor( kBlue ) ; - hist_eff_p->Draw("P") ; - - hist_FailRate_p->SetMarkerStyle( kOpenCircle) ; - hist_FailRate_p->SetMarkerColor( kRed) ; - hist_FailRate_p->SetLineColor( kRed ) ; - hist_FailRate_p->Draw("P") ; - - // TLegend* leg = new TLegend(0.6, 0.3, .9, .5); - // leg->AddEntry( "hist_eff_p" , "efficiency" , "lep") ; - // leg->AddEntry( "hist_FailRate_p" , "fake rate" , "lep") ; - // leg->Draw(); - - - - // ------------- - - c2->cd(2) ; - hth->Draw() ; - - hth->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - hth->GetYaxis()->SetTitleSize( 0.06 ) ; - hth->GetYaxis()->SetTitleOffset( 0.5 ); - - hth->GetXaxis()->SetTitle( "true cos(#theta)" ); - hth->GetXaxis()->SetTitleSize( 0.06 ) ; - hth->GetXaxis()->SetTitleOffset( 0.9 ); - - hth->GetEntries(); - hist_eff_th->SetMarkerStyle( kDot) ; //kOpenCircle) ; - hist_eff_th->SetMarkerColor( kBlue) ; - hist_eff_th->SetLineColor( kBlue ) ; - hist_eff_th->Draw("P") ; - - - hist_FailRate_th->SetMarkerStyle( kDot) ; //kOpenCircle) ; - hist_FailRate_th->SetMarkerColor( kRed) ; - hist_FailRate_th->SetLineColor( kRed ) ; - hist_FailRate_th->Draw("P") ; - hist_FailRate_th->Draw("P") ; - - outfile = getPathPrefix( filename ) ; - outfile += "PID_efficiency_"; - outfile += pidName ; - outfile += "_pdg"; - outfile += pdgCode ; - - - TString fName = pdfFile.Length() > 0 ? pdfFile : TString(outfile+".pdf") ; - - c2->Print( fName ); - - - - // cleanup... - - delete truePDG ; - delete isSeen ; - delete thePDG ; - delete trueCharge ; - delete seenCharge ; - delete trueP ; - delete trueTheta ; - delete seenTheta ; - delete seenP ; - - delete hist_eff_p ; - delete hist_eff_th ; - delete k ; - delete hist_FailRate_p ; - delete hist_FailRate_th ; - delete hpt ; - delete hth ; - delete c ; - delete c2 ; - treefile->Close() ; + TCanvas* c = new TCanvas(" PID efficiency", "Efficiency", 750, 750); + c->Divide(2, 3); + + c->cd(1); + gPad->SetLogx(); + + hist_p_t->GetXaxis()->SetTitle("true P/GeV"); + hist_p_t->GetXaxis()->SetTitleSize(0.04); + hist_p_t->GetXaxis()->SetTitleOffset(1.2); + + hist_p_t->Draw(); + + c->cd(2); + + hist_th_t->GetXaxis()->SetTitle("true cos(#theta)"); + hist_th_t->GetXaxis()->SetTitleSize(0.04); + hist_th_t->GetXaxis()->SetTitleOffset(1.3); + hist_th_t->Draw(); + + c->cd(3); + gPad->SetLogx(); + hist_Sp_t->Draw(); + + hist_p_t->GetXaxis()->SetTitle("true P/GeV"); + hist_p_t->GetXaxis()->SetTitleSize(0.04); + hist_p_t->GetXaxis()->SetTitleOffset(1.2); + + c->cd(4); + hist_Sth_t->Draw(); + + hist_Sth_t->GetXaxis()->SetTitle("true cos(#theta)"); + hist_Sth_t->GetXaxis()->SetTitleSize(0.04); + hist_Sth_t->GetXaxis()->SetTitleOffset(1.2); + + c->cd(5); + // hist_p_t.Sumw2(); + // hist_Sp_t.Sumw2(); + + TGraphAsymmErrors* hist_eff_p = new TGraphAsymmErrors; + hist_eff_p->Divide(hist_Sp_t, hist_p_t, "v"); + + hist_eff_p->Draw(); + + gPad->SetLogx(); + hist_eff_p->SetName(" hist_eff_p"); + + // histo->SetTitle(";x "#epsilon";y"true P/GeV""); + + hist_eff_p->GetYaxis()->SetTitle("#epsilon_{PID}"); + hist_eff_p->GetYaxis()->SetTitleSize(0.06); + hist_eff_p->GetYaxis()->SetTitleOffset(0.5); + + hist_eff_p->GetXaxis()->SetTitle("true P/GeV"); + hist_eff_p->GetXaxis()->SetTitleSize(0.06); + hist_eff_p->GetXaxis()->SetTitleOffset(1.2); + + c->cd(6); + // hist_th_t.Sumw2(); + // hist_Sth_t.Sumw2(); + + TGraphAsymmErrors* hist_eff_th = new TGraphAsymmErrors; + hist_eff_th->Divide(hist_Sth_t, hist_th_t, "v"); + hist_eff_th->Draw(); + hist_eff_th->SetName(" hist_eff_th"); + + hist_eff_th->GetYaxis()->SetTitle("#epsilon_{PID}"); + hist_eff_th->GetYaxis()->SetTitleSize(0.06); + hist_eff_th->GetYaxis()->SetTitleOffset(0.5); + + hist_eff_th->GetXaxis()->SetTitle("true cos(#theta)"); + hist_eff_th->GetXaxis()->SetTitleSize(0.06); + hist_eff_th->GetXaxis()->SetTitleOffset(0.9); + + TString outfile = getPathPrefix(filename); + outfile += "PID_efficiencies_pdg"; + outfile += pdgCode; + // c->Print(TString(outfile+".pdf")); + + TCanvas* k = new TCanvas(" PID Failed ", " PID Failed ", 750, 750); + k->Divide(2, 3); + + k->cd(1); + gPad->SetLogx(); + + hist_p_tnot->GetXaxis()->SetTitle("true P/GeV"); + hist_p_tnot->GetXaxis()->SetTitleSize(0.04); + hist_p_tnot->GetXaxis()->SetTitleOffset(1.2); + hist_p_tnot->Draw(); + + k->cd(2); + hist_th_tnot->GetXaxis()->SetTitle("true cos(#theta)"); + hist_th_tnot->GetXaxis()->SetTitleSize(0.04); + hist_th_tnot->GetXaxis()->SetTitleOffset(1.2); + hist_th_tnot->Draw(); + + k->cd(3); + gPad->SetLogx(); + hist_Failed_p->GetXaxis()->SetTitle("true P/GeV"); + hist_Failed_p->GetXaxis()->SetTitleSize(0.04); + hist_Failed_p->GetXaxis()->SetTitleOffset(1.2); + hist_Failed_p->Draw(); + + k->cd(4); + hist_Failed_th->GetXaxis()->SetTitle("true cos(#theta)"); + hist_Failed_th->GetXaxis()->SetTitleSize(0.04); + hist_Failed_th->GetXaxis()->SetTitleOffset(1.2); + hist_Failed_th->Draw(); + + k->cd(5); + + TGraphAsymmErrors* hist_FailRate_p = new TGraphAsymmErrors; + hist_FailRate_p->Divide(hist_Failed_p, hist_p_tnot, "v"); + gPad->SetLogx(); + + hist_FailRate_p->GetYaxis()->SetTitle("Fake Rate"); + hist_FailRate_p->GetYaxis()->SetTitleSize(0.06); + hist_FailRate_p->GetYaxis()->SetTitleOffset(1.); + + hist_FailRate_p->GetXaxis()->SetTitle("true P/GeV"); + hist_FailRate_p->GetXaxis()->SetTitleSize(0.06); + hist_FailRate_p->GetXaxis()->SetTitleOffset(1.2); + + hist_FailRate_p->Draw(); + hist_FailRate_p->SetName(" hist_FailRate_p"); + + k->cd(6); + + TGraphAsymmErrors* hist_FailRate_th = new TGraphAsymmErrors; + + hist_FailRate_th->Divide(hist_Failed_th, hist_th_tnot, "v"); + + hist_FailRate_th->GetYaxis()->SetTitle("Fake Rate"); + hist_FailRate_th->GetYaxis()->SetTitleSize(0.06); + hist_FailRate_th->GetYaxis()->SetTitleOffset(1.); + + hist_FailRate_th->GetXaxis()->SetTitle("true cos(#theta)"); + hist_FailRate_th->GetXaxis()->SetTitleSize(0.06); + hist_FailRate_th->GetXaxis()->SetTitleOffset(0.9); + + hist_FailRate_th->Draw(); + + hist_FailRate_th->SetName(" hist_FailRate_th"); + + outfile = getPathPrefix(filename); + outfile += "PID_Failed_pdg"; + outfile += pdgCode; + // k->Print(TString(outfile+".pdf")); + + // ------ draw them both in one plot -------------------- + + /// create an empty histogram to set the axes range: + + float minEff = 0.; + float maxEff = 1.01; + float minpt = 0.1; + float maxpt = 100.; + float minct = -1.; + float maxct = 1.; + + std::stringstream pTitleS; + pTitleS << "PID efficiency/fake rate vs P [" << pidName << "] - " << pName; + std::stringstream cTitleS; + cTitleS << "PID efficiency/fake rate vs cos(theta) [" << pidName << "] - " << pName; + + TH2F* hpt = new TH2F("hpt", pTitleS.str().c_str(), 10, minpt, maxpt, 10, minEff, maxEff); + TH2F* hth = new TH2F("hth", cTitleS.str().c_str(), 10, minct, maxct, 10, minEff, maxEff); + + TCanvas* c2 = new TCanvas("c2", "Efficiency and Fake Rate", 750, 750); + + c2->Divide(1, 2); + ildStyle->SetOptStat(0000); + c2->cd(1); + gPad->SetLogx(); + hpt->Draw(); + + hpt->GetYaxis()->SetTitle("#epsilon_{PID}"); + hpt->GetYaxis()->SetTitleSize(0.06); + hpt->GetYaxis()->SetTitleOffset(0.5); + + hpt->GetXaxis()->SetTitle("true P/GeV"); + hpt->GetXaxis()->SetTitleSize(0.06); + hpt->GetXaxis()->SetTitleOffset(1.2); + + hpt->GetEntries(); + + hist_eff_p->SetMarkerStyle(kOpenTriangleUp); // kDot) ; //kOpenCircle) ; + hist_eff_p->SetMarkerColor(kBlue); + hist_eff_p->SetLineColor(kBlue); + hist_eff_p->Draw("P"); + + hist_FailRate_p->SetMarkerStyle(kOpenCircle); + hist_FailRate_p->SetMarkerColor(kRed); + hist_FailRate_p->SetLineColor(kRed); + hist_FailRate_p->Draw("P"); + + // TLegend* leg = new TLegend(0.6, 0.3, .9, .5); + // leg->AddEntry( "hist_eff_p" , "efficiency" , "lep") ; + // leg->AddEntry( "hist_FailRate_p" , "fake rate" , "lep") ; + // leg->Draw(); + + // ------------- + + c2->cd(2); + hth->Draw(); + + hth->GetYaxis()->SetTitle("#epsilon_{PID}"); + hth->GetYaxis()->SetTitleSize(0.06); + hth->GetYaxis()->SetTitleOffset(0.5); + + hth->GetXaxis()->SetTitle("true cos(#theta)"); + hth->GetXaxis()->SetTitleSize(0.06); + hth->GetXaxis()->SetTitleOffset(0.9); + + hth->GetEntries(); + hist_eff_th->SetMarkerStyle(kDot); // kOpenCircle) ; + hist_eff_th->SetMarkerColor(kBlue); + hist_eff_th->SetLineColor(kBlue); + hist_eff_th->Draw("P"); + + hist_FailRate_th->SetMarkerStyle(kDot); // kOpenCircle) ; + hist_FailRate_th->SetMarkerColor(kRed); + hist_FailRate_th->SetLineColor(kRed); + hist_FailRate_th->Draw("P"); + hist_FailRate_th->Draw("P"); + + outfile = getPathPrefix(filename); + outfile += "PID_efficiency_"; + outfile += pidName; + outfile += "_pdg"; + outfile += pdgCode; + + TString fName = pdfFile.Length() > 0 ? pdfFile : TString(outfile + ".pdf"); + + c2->Print(fName); - return; - + // cleanup... + + delete truePDG; + delete isSeen; + delete thePDG; + delete trueCharge; + delete seenCharge; + delete trueP; + delete trueTheta; + delete seenTheta; + delete seenP; + + delete hist_eff_p; + delete hist_eff_th; + delete k; + delete hist_FailRate_p; + delete hist_FailRate_th; + delete hpt; + delete hth; + delete c; + delete c2; + + treefile->Close(); + + return; } diff --git a/PID/macros/plotPIDLike.C b/PID/macros/plotPIDLike.C index be1ba6c..01bcf10 100644 --- a/PID/macros/plotPIDLike.C +++ b/PID/macros/plotPIDLike.C @@ -1,135 +1,137 @@ -#include "TH1.h" #include "PIDHelper.h" +#include "TH1.h" /** Very simple plotting of likelihood PDG */ -void plotPIDLike(const char* _filename ) { +void plotPIDLike(const char* _filename) { gROOT->SetStyle("ildStyle"); // use small markers: ildStyle->SetMarkerStyle(1); - TFile *treefile = new TFile(_filename); - TTree *hermTree = (TTree*) treefile->Get("hermTree"); - - const int nBins = 100 ; - const double maxX = 10 ; - const double minX = -200; - - TH1F* h1= new TH1F( "h1", "Likely PDG True electorns", nBins ,minX , maxX ) ; - TH1F* h2= new TH1F( "h2", "Likely PDG values for electorns", nBins ,minX , maxX ) ; - TH1F* h3= new TH1F( "h3", "Likely PDG True muons", nBins ,minX , maxX ) ; - TH1F* h4= new TH1F( "h4", "Likely PDG values for muons", nBins , minX, maxX ) ; - TH1F* h5= new TH1F( "h5", "Likely PDG True pions", nBins , minX, maxX) ; - TH1F* h6= new TH1F( "h6", "Likely PDG values for pions", nBins , minX, maxX ) ; - TH1F* h7= new TH1F( "h7", "Likely PDG True Kaons", nBins ,minX , maxX) ; - TH1F* h8= new TH1F( "h8", "Likely PDG values for Kaons", nBins ,minX ,maxX ) ; - TH1F* h9= new TH1F( "h9", "Likely PDG True Protons", nBins ,minX ,maxX ) ; - TH1F* h10= new TH1F( "h10", "Likely PDG vlaues for Protons", nBins ,minX ,maxX ) ; - - - hermTree->Draw("LiPDG_el>>h1" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==11"); - hermTree->Draw("LiPDG_el>>h2" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=11"); - hermTree->Draw("LiPDG_mu>>h3" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==13"); - hermTree->Draw("LiPDG_mu>>h4" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=13"); - hermTree->Draw("LiPDG_pi>>h5" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==211"); - hermTree->Draw("LiPDG_pi>>h6" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=211"); - hermTree->Draw("LiPDG_ka>>h7" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==321"); - hermTree->Draw("LiPDG_ka>>h8" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=321"); - hermTree->Draw("LiPDG_pr>>h9" ,"abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==2212"); - hermTree->Draw("LiPDG_pr>>h10","abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=2212"); - - TCanvas* c2 = new TCanvas("c2","Likely PDG for true and fake particles",750,750 ); - - c2->Divide(2,3) ; - - - c2->cd(1) ; -gPad->SetLogy() ; + TFile* treefile = new TFile(_filename); + TTree* hermTree = (TTree*)treefile->Get("hermTree"); + + const int nBins = 100; + const double maxX = 10; + const double minX = -200; + + TH1F* h1 = new TH1F("h1", "Likely PDG True electorns", nBins, minX, maxX); + TH1F* h2 = new TH1F("h2", "Likely PDG values for electorns", nBins, minX, maxX); + TH1F* h3 = new TH1F("h3", "Likely PDG True muons", nBins, minX, maxX); + TH1F* h4 = new TH1F("h4", "Likely PDG values for muons", nBins, minX, maxX); + TH1F* h5 = new TH1F("h5", "Likely PDG True pions", nBins, minX, maxX); + TH1F* h6 = new TH1F("h6", "Likely PDG values for pions", nBins, minX, maxX); + TH1F* h7 = new TH1F("h7", "Likely PDG True Kaons", nBins, minX, maxX); + TH1F* h8 = new TH1F("h8", "Likely PDG values for Kaons", nBins, minX, maxX); + TH1F* h9 = new TH1F("h9", "Likely PDG True Protons", nBins, minX, maxX); + TH1F* h10 = new TH1F("h10", "Likely PDG vlaues for Protons", nBins, minX, maxX); + + hermTree->Draw("LiPDG_el>>h1", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==11"); + hermTree->Draw("LiPDG_el>>h2", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=11"); + hermTree->Draw("LiPDG_mu>>h3", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==13"); + hermTree->Draw("LiPDG_mu>>h4", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=13"); + hermTree->Draw("LiPDG_pi>>h5", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==211"); + hermTree->Draw("LiPDG_pi>>h6", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=211"); + hermTree->Draw("LiPDG_ka>>h7", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==321"); + hermTree->Draw("LiPDG_ka>>h8", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=321"); + hermTree->Draw("LiPDG_pr>>h9", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==2212"); + hermTree->Draw("LiPDG_pr>>h10", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueP>1.0&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)!=2212"); + + TCanvas* c2 = new TCanvas("c2", "Likely PDG for true and fake particles", 750, 750); + + c2->Divide(2, 3); + + c2->cd(1); + gPad->SetLogy(); // h1->SetFillStyle( 3001); - //h1->SetLineColor( kRed); - //h1->Draw( "hist same"); + // h1->SetLineColor( kRed); + // h1->Draw( "hist same"); + + // h2->SetFillStyle( 3001); + // h2->SetLineColor( kBlue); + // h2->Draw( "hist same"); + + h1->SetLineColor(kBlue); + h2->SetLineColor(kRed); - //h2->SetFillStyle( 3001); - //h2->SetLineColor( kBlue); - //h2->Draw( "hist same"); - - h1->SetLineColor( kBlue); - h2->SetLineColor( kRed); - + h2->GetXaxis()->SetTitle("Likely PDG"); + h2->GetXaxis()->SetTitleSize(0.04); + h2->GetXaxis()->SetTitleOffset(1.5); - h2->GetXaxis()->SetTitle("Likely PDG" ); - h2->GetXaxis()->SetTitleSize( 0.04 ) ; - h2->GetXaxis()->SetTitleOffset( 1.5 ); - - h1->Draw( "hist"); - h2->Draw( "hist same"); - //h1->Draw() ; - //h2->Draw("same"); + h1->Draw("hist"); + h2->Draw("hist same"); + // h1->Draw() ; + // h2->Draw("same"); - - c2->cd(2) ; -gPad->SetLogy() ; + c2->cd(2); + gPad->SetLogy(); - h3->SetLineColor( kBlue); - h4->SetLineColor( kRed); + h3->SetLineColor(kBlue); + h4->SetLineColor(kRed); - h4->GetXaxis()->SetTitle("Likely PDG" ); - h4->GetXaxis()->SetTitleSize( 0.04 ) ; - h4->GetXaxis()->SetTitleOffset( 1.5 ); + h4->GetXaxis()->SetTitle("Likely PDG"); + h4->GetXaxis()->SetTitleSize(0.04); + h4->GetXaxis()->SetTitleOffset(1.5); - h3->SetLineColor( kBlue); - h4->SetLineColor( kRed); + h3->SetLineColor(kBlue); + h4->SetLineColor(kRed); -h4->Draw("hist"); -h3->Draw("hist same"); - + h4->Draw("hist"); + h3->Draw("hist same"); - -c2->cd(3) ; - -gPad->SetLogy() ; + c2->cd(3); -h5->SetLineColor( kBlue); - h6->SetLineColor( kRed); + gPad->SetLogy(); - h6->GetXaxis()->SetTitle("Likely PDG" ); - h6->GetXaxis()->SetTitleSize( 0.04 ) ; - h6->GetXaxis()->SetTitleOffset( 1.5 ); + h5->SetLineColor(kBlue); + h6->SetLineColor(kRed); - h5->Draw( "hist"); - h6->Draw( "hist same"); + h6->GetXaxis()->SetTitle("Likely PDG"); + h6->GetXaxis()->SetTitleSize(0.04); + h6->GetXaxis()->SetTitleOffset(1.5); -c2->cd(4) ; -gPad->SetLogy() ; + h5->Draw("hist"); + h6->Draw("hist same"); -h7->SetLineColor( kBlue); - h8->SetLineColor( kRed); + c2->cd(4); + gPad->SetLogy(); - h8->GetXaxis()->SetTitle("Likely PDG" ); - h8->GetXaxis()->SetTitleSize( 0.04 ) ; - h8->GetXaxis()->SetTitleOffset( 1.5 ); + h7->SetLineColor(kBlue); + h8->SetLineColor(kRed); -h8->Draw( "hist"); - h7->Draw( "hist same"); + h8->GetXaxis()->SetTitle("Likely PDG"); + h8->GetXaxis()->SetTitleSize(0.04); + h8->GetXaxis()->SetTitleOffset(1.5); - c2->cd(5) ; + h8->Draw("hist"); + h7->Draw("hist same"); -gPad->SetLogy() ; + c2->cd(5); -h9->SetLineColor( kBlue); - h10->SetLineColor( kRed); + gPad->SetLogy(); - h10->GetXaxis()->SetTitle("Likely PDG" ); - h10->GetXaxis()->SetTitleSize( 0.04 ) ; - h10->GetXaxis()->SetTitleOffset( 1.5 ); + h9->SetLineColor(kBlue); + h10->SetLineColor(kRed); - h10->Draw( "hist"); - h9->Draw( "hist same"); + h10->GetXaxis()->SetTitle("Likely PDG"); + h10->GetXaxis()->SetTitleSize(0.04); + h10->GetXaxis()->SetTitleOffset(1.5); + h10->Draw("hist"); + h9->Draw("hist same"); - TString outfile = getPathPrefix( _filename ) ; - outfile += "Likely_PDG"; - c2->Print(TString(outfile+".pdf")); - + TString outfile = getPathPrefix(_filename); + outfile += "Likely_PDG"; + c2->Print(TString(outfile + ".pdf")); } diff --git a/PID/macros/plotPIDPurity.C b/PID/macros/plotPIDPurity.C index 7d52910..b89ad32 100644 --- a/PID/macros/plotPIDPurity.C +++ b/PID/macros/plotPIDPurity.C @@ -3,20 +3,20 @@ #include "PIDHelper.h" -#include "TTree.h" #include "TFile.h" #include "TH1F.h" #include "TString.h" +#include "TTree.h" using namespace std; -/// plot the likelihood PID and the resulting efficicency vs purity +/// plot the likelihood PID and the resulting efficicency vs purity void plotPIDPurity(const char* _filename) { - - const int nBins = 100 ; + + const int nBins = 100; int trueCounter[5] = {0, 0, 0, 0, 0}; - int recoCounter[5] ={0, 0, 0, 0, 0}; + int recoCounter[5] = {0, 0, 0, 0, 0}; int trueandrecoCounter[5] = {0, 0, 0, 0, 0}; int BinCentre_ht[nBins]; int BinContent_ht[nBins]; @@ -34,14 +34,14 @@ void plotPIDPurity(const char* _filename) { ildStyle->SetCanvasColor(0); ildStyle->SetTitleColor(1); ildStyle->SetStatColor(0); -// ildStyle->SetOptStat(1110010); + // ildStyle->SetOptStat(1110010); ildStyle->SetOptStat(10); - //ildStyle->SetOptFit(10); - ildStyle->SetPadBottomMargin(0.15); + // ildStyle->SetOptFit(10); + ildStyle->SetPadBottomMargin(0.15); ildStyle->SetPadTopMargin(0.10); ildStyle->SetPadRightMargin(0.025); - ildStyle->SetPadLeftMargin(0.2); + ildStyle->SetPadLeftMargin(0.2); ildStyle->SetMarkerStyle(20); ildStyle->SetMarkerSize(0.625); @@ -49,253 +49,245 @@ void plotPIDPurity(const char* _filename) { int pdgCode[5] = {11, 13, 211, 321, 2212}; TString particleName[5] = {"electrons", "muons", "pions", "kaons", "protons"}; - TString likelihoodName[5] = {"LiPDG_el", "LiPDG_mu", "LiPDG_pi", "LiPDG_ka", "LiPDG_pr" } ; - TH1F* ht[5] ; // true particles - TH1F* hf[5] ; // false particles - TGraph* h[5] ; + TString likelihoodName[5] = {"LiPDG_el", "LiPDG_mu", "LiPDG_pi", "LiPDG_ka", "LiPDG_pr"}; + TH1F* ht[5]; // true particles + TH1F* hf[5]; // false particles + TGraph* h[5]; // --- open the file ----- - TFile *treefile = new TFile(_filename); - TTree *tree = (TTree*) treefile->Get("hermTree"); + TFile* treefile = new TFile(_filename); + TTree* tree = (TTree*)treefile->Get("hermTree"); - - const double maxX = 10. ; - const double minX = -200; - - TString outfile = getPathPrefix( _filename ) ; + const double maxX = 10.; + const double minX = -200; + + TString outfile = getPathPrefix(_filename); outfile += "Eff_Purity.pdf"; for (int i = 0; i < 5; ++i) { // loop over 5 PDG types - // -- create the histograms - TString hname = "ht_" + particleName[i] ; - TString htitle = " Likely PDG true " + particleName[i] ; - ht[i] = new TH1F( hname , htitle, nBins ,minX , maxX ) ; + // -- create the histograms + TString hname = "ht_" + particleName[i]; + TString htitle = " Likely PDG true " + particleName[i]; + ht[i] = new TH1F(hname, htitle, nBins, minX, maxX); - hname = "hf_" + particleName[i] ; - htitle = " Likely PDG false " + particleName[i] ; - hf[i] = new TH1F( hname , htitle, nBins ,minX , maxX ) ; + hname = "hf_" + particleName[i]; + htitle = " Likely PDG false " + particleName[i]; + hf[i] = new TH1F(hname, htitle, nBins, minX, maxX); - - //********************************************************************************************** + //********************************************************************************************** // read branches int npart; - vector *truePDG = new vector ; - vector *isSeen = new vector ; - vector *basicPDG = new vector ; - vector *dEdxPDG = new vector ; - vector *showerPDG = new vector ; - vector *likeliPDG = new vector ; - vector *lowmomPDG = new vector ; - vector *trueCharge = new vector ; - vector *seenCharge = new vector ; - vector *trueP = new vector ; - vector *trueTheta = new vector ; - vector *seenTheta = new vector ; - vector *seenP = new vector ; - vector *seenDEdx = new vector ; - vector *likelihood = new vector ; - - tree->SetBranchAddress("nMCParticles", &npart); - tree->SetBranchAddress("trueCharge", &trueCharge); - tree->SetBranchAddress("truePDG", &truePDG); - tree->SetBranchAddress("isSeen", &isSeen); - tree->SetBranchAddress("seenCharge", &seenCharge); - tree->SetBranchAddress("basicPDG", &basicPDG); - tree->SetBranchAddress("dEdxPDG", &dEdxPDG); - tree->SetBranchAddress("showerPDG", &showerPDG); - tree->SetBranchAddress("likeliPDG", &likeliPDG); - tree->SetBranchAddress("lowmomPDG", &lowmomPDG); - + vector* truePDG = new vector; + vector* isSeen = new vector; + vector* basicPDG = new vector; + vector* dEdxPDG = new vector; + vector* showerPDG = new vector; + vector* likeliPDG = new vector; + vector* lowmomPDG = new vector; + vector* trueCharge = new vector; + vector* seenCharge = new vector; + vector* trueP = new vector; + vector* trueTheta = new vector; + vector* seenTheta = new vector; + vector* seenP = new vector; + vector* seenDEdx = new vector; + vector* likelihood = new vector; + + tree->SetBranchAddress("nMCParticles", &npart); + tree->SetBranchAddress("trueCharge", &trueCharge); + tree->SetBranchAddress("truePDG", &truePDG); + tree->SetBranchAddress("isSeen", &isSeen); + tree->SetBranchAddress("seenCharge", &seenCharge); + tree->SetBranchAddress("basicPDG", &basicPDG); + tree->SetBranchAddress("dEdxPDG", &dEdxPDG); + tree->SetBranchAddress("showerPDG", &showerPDG); + tree->SetBranchAddress("likeliPDG", &likeliPDG); + tree->SetBranchAddress("lowmomPDG", &lowmomPDG); + tree->SetBranchAddress("trueP", &trueP); tree->SetBranchAddress("trueTheta", &trueTheta); tree->SetBranchAddress("seenTheta", &seenTheta); tree->SetBranchAddress("seenP", &seenP); tree->SetBranchAddress("seenDEdx", &seenDEdx); - - tree->SetBranchAddress( likelihoodName[i] , &likelihood ); - - + tree->SetBranchAddress(likelihoodName[i], &likelihood); + // ************************* loop over events and particles in tree ***************************** - - + int nevts = tree->GetEntries(); - + for (int ievt = 0; ievt < nevts; ++ievt) { - + tree->GetEntry(ievt); - - for (int ipart = 0; ipart < npart; ipart++) { - - if ( isSeen->at( ipart ) < 0.5 ) continue ;// require MC-truth link weight to be > 0.5 - - if( seenCharge->at( ipart ) == 0 ) continue; // only look at charged - - if( trueP->at( ipart ) < 1.0 ) continue; // momentum > 1GeV - - if( seenDEdx->at( ipart ) < 0 ) continue; - - if( seenDEdx->at( ipart ) > 1.e-6) continue; - - if( std::abs( truePDG->at( ipart ) ) == pdgCode[i] ) { - - ht[i]->Fill( likelihood->at( ipart ) ); - - } else { - - hf[i]->Fill( likelihood->at( ipart ) ) ; - } + + for (int ipart = 0; ipart < npart; ipart++) { + + if (isSeen->at(ipart) < 0.5) + continue; // require MC-truth link weight to be > 0.5 + + if (seenCharge->at(ipart) == 0) + continue; // only look at charged + + if (trueP->at(ipart) < 1.0) + continue; // momentum > 1GeV + + if (seenDEdx->at(ipart) < 0) + continue; + + if (seenDEdx->at(ipart) > 1.e-6) + continue; + + if (std::abs(truePDG->at(ipart)) == pdgCode[i]) { + + ht[i]->Fill(likelihood->at(ipart)); + + } else { + + hf[i]->Fill(likelihood->at(ipart)); + } } - } // ----- loop over events + } // ----- loop over events + + for (int iBins = 0; iBins < nBins; iBins++) { - for(int iBins=0; iBinsGetBinCenter (iBins) ; - BinContent_ht[iBins] = ht[i]->GetBinContent(iBins+1) ; - //BinCentre_hf[iBins] = hf[i]->GetBinCenter (iBins) ; - BinContent_hf[iBins] = hf[i]->GetBinContent(iBins+1) ; + // BinCentre_ht[iBins] = ht[i]->GetBinCenter (iBins) ; + BinContent_ht[iBins] = ht[i]->GetBinContent(iBins + 1); + // BinCentre_hf[iBins] = hf[i]->GetBinCenter (iBins) ; + BinContent_hf[iBins] = hf[i]->GetBinContent(iBins + 1); } - - double eff[ nBins ] ; - double pur[ nBins ] ; - - for(int iBins=0; iBinsDivide(2,3) ; - for(int i=0 ; i<5; ++i){ - c0->cd(i+1) ; - gPad->SetLogy() ; - ht[i]->SetLineColor( kBlue); - hf[i]->SetLineColor( kRed); - ht[i]->Draw() ; - hf[i]->Draw("same") ; + TCanvas* c0 = new TCanvas("xxx", "xxx", 750, 750); + c0->Divide(2, 3); + for (int i = 0; i < 5; ++i) { + c0->cd(i + 1); + gPad->SetLogy(); + ht[i]->SetLineColor(kBlue); + hf[i]->SetLineColor(kRed); + ht[i]->Draw(); + hf[i]->Draw("same"); } - c0->Print( outfile+"(" ) ; - - // and now the eff vs. pur. - TGraph* h1 = h[0] ; - TGraph* h2 = h[1] ; - TGraph* h3 = h[2] ; - TGraph* h4 = h[3] ; - TGraph* h5 = h[4] ; - - TCanvas* c = new TCanvas( " PID efficiency vs purity" , "Efficiency purity" ,750 ,750); - c->Divide(2,3) ; - - c->cd(1) ; - + c0->Print(outfile + "("); + + // and now the eff vs. pur. + TGraph* h1 = h[0]; + TGraph* h2 = h[1]; + TGraph* h3 = h[2]; + TGraph* h4 = h[3]; + TGraph* h5 = h[4]; + + TCanvas* c = new TCanvas(" PID efficiency vs purity", "Efficiency purity", 750, 750); + c->Divide(2, 3); + + c->cd(1); + h1->SetTitle("Electrons Efficiency vs Purity"); - h1->GetXaxis()->SetTitle("Purity" ); - h1->GetXaxis()->SetTitleSize( 0.04 ) ; - h1->GetXaxis()->SetTitleOffset( 1.2 ); + h1->GetXaxis()->SetTitle("Purity"); + h1->GetXaxis()->SetTitleSize(0.04); + h1->GetXaxis()->SetTitleOffset(1.2); - h1->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - h1->GetYaxis()->SetTitleSize( 0.06 ) ; - h1->GetYaxis()->SetTitleOffset( 0.5 ); - - h1->Draw() ; + h1->GetYaxis()->SetTitle("#epsilon_{PID}"); + h1->GetYaxis()->SetTitleSize(0.06); + h1->GetYaxis()->SetTitleOffset(0.5); - c->cd(2) ; + h1->Draw(); + + c->cd(2); h2->SetTitle("Muons Efficiency vs Purity"); - h2->GetXaxis()->SetTitle("Purity" ); - h2->GetXaxis()->SetTitleSize( 0.04 ) ; - h2->GetXaxis()->SetTitleOffset( 1.2 ); + h2->GetXaxis()->SetTitle("Purity"); + h2->GetXaxis()->SetTitleSize(0.04); + h2->GetXaxis()->SetTitleOffset(1.2); - h2->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - h2->GetYaxis()->SetTitleSize( 0.06 ) ; - h2->GetYaxis()->SetTitleOffset( 0.5 ); + h2->GetYaxis()->SetTitle("#epsilon_{PID}"); + h2->GetYaxis()->SetTitleSize(0.06); + h2->GetYaxis()->SetTitleOffset(0.5); - h2->Draw() ; + h2->Draw(); - c->cd(3) ; + c->cd(3); h3->SetTitle("Pions Efficiency vs Purity"); - - h3->GetXaxis()->SetTitle("Purity" ); - h3->GetXaxis()->SetTitleSize( 0.04 ) ; - h3->GetXaxis()->SetTitleOffset( 1.2 ); - h3->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - h3->GetYaxis()->SetTitleSize( 0.06 ) ; - h3->GetYaxis()->SetTitleOffset( 0.5 ); - - h3->Draw() ; + h3->GetXaxis()->SetTitle("Purity"); + h3->GetXaxis()->SetTitleSize(0.04); + h3->GetXaxis()->SetTitleOffset(1.2); + + h3->GetYaxis()->SetTitle("#epsilon_{PID}"); + h3->GetYaxis()->SetTitleSize(0.06); + h3->GetYaxis()->SetTitleOffset(0.5); + + h3->Draw(); - c->cd(4) ; + c->cd(4); h4->SetTitle("Kaons Efficiency vs Purity"); - - h4->GetXaxis()->SetTitle("Purity" ); - h4->GetXaxis()->SetTitleSize( 0.04 ) ; - h4->GetXaxis()->SetTitleOffset( 1.2 ); - - h4->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - h4->GetYaxis()->SetTitleSize( 0.06 ) ; - h4->GetYaxis()->SetTitleOffset( 0.5 ); - - h4->Draw() ; - + + h4->GetXaxis()->SetTitle("Purity"); + h4->GetXaxis()->SetTitleSize(0.04); + h4->GetXaxis()->SetTitleOffset(1.2); + + h4->GetYaxis()->SetTitle("#epsilon_{PID}"); + h4->GetYaxis()->SetTitleSize(0.06); + h4->GetYaxis()->SetTitleOffset(0.5); + + h4->Draw(); + c->cd(5); - + h5->SetTitle("Protons Efficiency vs Purity"); - - h5->GetXaxis()->SetTitle("Purity" ); - h5->GetXaxis()->SetTitleSize( 0.04 ) ; - h5->GetXaxis()->SetTitleOffset( 1.2 ); - h5->GetYaxis()->SetTitle( "#epsilon_{PID}" ); - h5->GetYaxis()->SetTitleSize( 0.06 ) ; - h5->GetYaxis()->SetTitleOffset( 0.5 ); - - h5->Draw() ; + h5->GetXaxis()->SetTitle("Purity"); + h5->GetXaxis()->SetTitleSize(0.04); + h5->GetXaxis()->SetTitleOffset(1.2); + + h5->GetYaxis()->SetTitle("#epsilon_{PID}"); + h5->GetYaxis()->SetTitleSize(0.06); + h5->GetYaxis()->SetTitleOffset(0.5); + h5->Draw(); - c->Print( outfile+")" ); + c->Print(outfile + ")"); return; - } diff --git a/PID/macros/plotPIDs.C b/PID/macros/plotPIDs.C index ee50699..80794ec 100644 --- a/PID/macros/plotPIDs.C +++ b/PID/macros/plotPIDs.C @@ -1,16 +1,15 @@ #include -#include "TTree.h" #include "TFile.h" #include "TH1F.h" #include "TString.h" +#include "TTree.h" #include "PIDHelper.h" using namespace std; -void getPDGHistos (TH1F **hist, TTree *tree, int &pdg, int &itruecut) ; - +void getPDGHistos(TH1F** hist, TTree* tree, int& pdg, int& itruecut); /// Create PID plots for four different algorithms in directory where ROOT file is found void plotPIDs(const char* _filename) { @@ -25,26 +24,26 @@ void plotPIDs(const char* _filename) { ildStyle->SetCanvasColor(0); ildStyle->SetTitleColor(1); ildStyle->SetStatColor(0); -// ildStyle->SetOptStat(1110010); + // ildStyle->SetOptStat(1110010); ildStyle->SetOptStat(10); - //ildStyle->SetOptFit(10); - + // ildStyle->SetOptFit(10); + ildStyle->SetPadBottomMargin(0.15); ildStyle->SetPadTopMargin(0.10); ildStyle->SetPadRightMargin(0.025); ildStyle->SetPadLeftMargin(0.2); - + ildStyle->SetMarkerStyle(20); ildStyle->SetMarkerSize(0.625); - TFile *treefile = new TFile(_filename); - TTree *tree = (TTree*) treefile->Get("hermTree"); - + TFile* treefile = new TFile(_filename); + TTree* tree = (TTree*)treefile->Get("hermTree"); + // cut:PID_output_n1n1hh2.root // 1: p > 1 GeV // 8: 1 GeV < p < 10 GeV int icut = 9; - + // particles: // pdg = 0: all // pdg = 1: all charged @@ -53,91 +52,150 @@ void plotPIDs(const char* _filename) { int npdg = 5; int kpdg[5] = {11, 13, 211, 321, 2212}; TString tpdg[5] = {"electrons", "muons", "pions", "kaons", "protons"}; - - TCanvas *cpdg[5]; - TH1F *hpdg[5][6]; - TLegend *lpdg[5][6]; - + + TCanvas* cpdg[5]; + TH1F* hpdg[5][6]; + TLegend* lpdg[5][6]; + for (int ipdg = 0; ipdg < 5; ipdg++) { - + // draw - cpdg[ipdg] = new TCanvas (tpdg[ipdg],tpdg[ipdg],750,750); - cpdg[ipdg]->Divide(2,2); - + cpdg[ipdg] = new TCanvas(tpdg[ipdg], tpdg[ipdg], 750, 750); + cpdg[ipdg]->Divide(2, 2); + getPDGHistos(hpdg[ipdg], tree, kpdg[ipdg], icut); - + int ntrue = hpdg[ipdg][0]->GetEntries(); cout << "ntrue = " << ntrue << endl; - + for (int ihist = 1; ihist < 5; ihist++) { - //cout << "ipdg, ihist = " << ipdg << "," << ihist << ": npart = " << hpdg[ipdg][ihist]->GetEntries() << endl; + // cout << "ipdg, ihist = " << ipdg << "," << ihist << ": npart = " << hpdg[ipdg][ihist]->GetEntries() << endl; cpdg[ipdg]->cd(ihist); gPad->SetGridy(1); if (ntrue > 0) { - hpdg[ipdg][ihist]->Scale(100./ntrue); + hpdg[ipdg][ihist]->Scale(100. / ntrue); hpdg[ipdg][ihist]->SetMaximum(110.); - } + } hpdg[ipdg][ihist]->Draw("E0"); -// lpdg[ipdg][ihist] = new TLegend (0.25, 0.7, 0.7, 0.9, hpdg[ipdg][ihist]->GetTitle()); -// lpdg[ipdg][ihist]->Draw(); - } - + // lpdg[ipdg][ihist] = new TLegend (0.25, 0.7, 0.7, 0.9, hpdg[ipdg][ihist]->GetTitle()); + // lpdg[ipdg][ihist]->Draw(); + } - TString outfile = getPathPrefix(_filename ) ; + TString outfile = getPathPrefix(_filename); outfile += "PIDs_pdg"; outfile += kpdg[ipdg]; outfile += "_cut"; outfile += icut; - //cout << outfile << endl; - // cpdg[ipdg]->Print(TString(outfile+".eps")); - // cpdg[ipdg]->Print(TString(outfile+".ps")); - cpdg[ipdg]->Print(TString(outfile+".pdf")); - + // cout << outfile << endl; + // cpdg[ipdg]->Print(TString(outfile+".eps")); + // cpdg[ipdg]->Print(TString(outfile+".ps")); + cpdg[ipdg]->Print(TString(outfile + ".pdf")); } - + return; - } -void getPDGHistos (TH1F **hist, TTree *tree, int &pdg, int &itruecut) { +void getPDGHistos(TH1F** hist, TTree* tree, int& pdg, int& itruecut) { cout << "pdg = " << pdg << ", itruecut = " << itruecut << endl; TString partname = ""; switch (pdg) { - case 0: partname = ", all"; break; - case 1: partname = ", all charged"; break; - case 2: partname = ", all neutral"; break; - case 11: partname = ", electrons"; break; - case 13: partname = ", muons"; break; - case 15: partname = ", taus"; break; - case 111: partname = ", pi0"; break; - case 211: partname = ", pi+-"; break; - case 321: partname = ", K+-"; break; - case 2212: partname = ", protons"; break; + case 0: + partname = ", all"; + break; + case 1: + partname = ", all charged"; + break; + case 2: + partname = ", all neutral"; + break; + case 11: + partname = ", electrons"; + break; + case 13: + partname = ", muons"; + break; + case 15: + partname = ", taus"; + break; + case 111: + partname = ", pi0"; + break; + case 211: + partname = ", pi+-"; + break; + case 321: + partname = ", K+-"; + break; + case 2212: + partname = ", protons"; + break; } - - + TString cutname = "truePt"; TString cuttitle = ""; double cutmin = 1; double cutmax = 1000000000; - //cout << "itruecut = " << itruecut << endl; + // cout << "itruecut = " << itruecut << endl; switch (itruecut) { - case 1: cutname = "trueP"; cutmin = 1; cutmax = 1000000000; cuttitle = " with P > 1 GeV"; break; - case 2: cutname = "trueP"; cutmin = 0; cutmax = 2.; cuttitle = " with P < 2 GeV"; break; - case 3: cutname = "trueTheta"; cutmin = 0; cutmax = 3.2; break; - case 4: cutname = "truePhi"; cutmin = 0; cutmax = 3.2; break; - case 5: cutname = "trueTheta"; cutmin = 0; cutmax = 0.95; cuttitle = " with |cos(theta)|<0.95"; break; - case 6: cutname = "truePt"; cutmin = 0; cutmax = 1; cuttitle = " with pt < 1 GeV"; break; - case 7: cutname = "truePt"; cutmin = 1; cutmax = 10; cuttitle = " with 1 GeV < pt < 10 GeV"; break; - case 8: cutname = "trueP"; cutmin = 1; cutmax = 10; cuttitle = " with 1 GeV < p < 10 GeV"; break; - case 9: cutname = "trueP"; cutmin = 3; cutmax = 1000000000; cuttitle = " with P > 3 GeV"; break; + case 1: + cutname = "trueP"; + cutmin = 1; + cutmax = 1000000000; + cuttitle = " with P > 1 GeV"; + break; + case 2: + cutname = "trueP"; + cutmin = 0; + cutmax = 2.; + cuttitle = " with P < 2 GeV"; + break; + case 3: + cutname = "trueTheta"; + cutmin = 0; + cutmax = 3.2; + break; + case 4: + cutname = "truePhi"; + cutmin = 0; + cutmax = 3.2; + break; + case 5: + cutname = "trueTheta"; + cutmin = 0; + cutmax = 0.95; + cuttitle = " with |cos(theta)|<0.95"; + break; + case 6: + cutname = "truePt"; + cutmin = 0; + cutmax = 1; + cuttitle = " with pt < 1 GeV"; + break; + case 7: + cutname = "truePt"; + cutmin = 1; + cutmax = 10; + cuttitle = " with 1 GeV < pt < 10 GeV"; + break; + case 8: + cutname = "trueP"; + cutmin = 1; + cutmax = 10; + cuttitle = " with 1 GeV < p < 10 GeV"; + break; + case 9: + cutname = "trueP"; + cutmin = 3; + cutmax = 1000000000; + cuttitle = " with P > 3 GeV"; + break; } - //cout << "cutname = " << cutname << endl; - + // cout << "cutname = " << cutname << endl; + // book histos TString hname[6] = {"MCTruth", "BasicPID", "dEdxPID", "ShowerPID", "LikeliPID", "LowMomPID"}; for (int i = 0; i < 6; ++i) { - hist[i] = new TH1F(hname[i],hname[i] + partname + cuttitle, 5, -0.5, 4.5); + hist[i] = new TH1F(hname[i], hname[i] + partname + cuttitle, 5, -0.5, 4.5); hist[i]->Sumw2(); hist[i]->SetTitle(hname[i] + partname + cuttitle); hist[i]->GetYaxis()->SetTitle(TString("% ")); @@ -149,66 +207,68 @@ void getPDGHistos (TH1F **hist, TTree *tree, int &pdg, int &itruecut) { hist[i]->GetYaxis()->SetLabelSize(0.06); hist[i]->GetXaxis()->SetLabelOffset(0.02); hist[i]->GetYaxis()->SetLabelOffset(0.01); - hist[i]->GetXaxis()->SetBinLabel(1,"e"); - hist[i]->GetXaxis()->SetBinLabel(2,"mu"); - hist[i]->GetXaxis()->SetBinLabel(3,"pi"); - hist[i]->GetXaxis()->SetBinLabel(4,"K"); - hist[i]->GetXaxis()->SetBinLabel(5,"p"); - } - - + hist[i]->GetXaxis()->SetBinLabel(1, "e"); + hist[i]->GetXaxis()->SetBinLabel(2, "mu"); + hist[i]->GetXaxis()->SetBinLabel(3, "pi"); + hist[i]->GetXaxis()->SetBinLabel(4, "K"); + hist[i]->GetXaxis()->SetBinLabel(5, "p"); + } + // read branches int npart; - vector *cutvar = new vector ; - vector *truePDG = new vector ; - vector *isSeen = new vector ; - vector *basicPDG = new vector ; - vector *dEdxPDG = new vector ; - vector *showerPDG = new vector ; - vector *likeliPDG = new vector ; - vector *lowmomPDG = new vector ; - vector *trueCharge = new vector ; - vector *seenCharge = new vector ; - tree->SetBranchAddress("nMCParticles", &npart); - tree->SetBranchAddress(cutname, &cutvar); - tree->SetBranchAddress("trueCharge", &trueCharge); - tree->SetBranchAddress("truePDG", &truePDG); - tree->SetBranchAddress("isSeen", &isSeen); - tree->SetBranchAddress("seenCharge", &seenCharge); - tree->SetBranchAddress("basicPDG", &basicPDG); - tree->SetBranchAddress("dEdxPDG", &dEdxPDG); - tree->SetBranchAddress("showerPDG", &showerPDG); - tree->SetBranchAddress("likeliPDG", &likeliPDG); - tree->SetBranchAddress("lowmomPDG", &lowmomPDG); - - //cout << "after branch addressing " << endl; + vector* cutvar = new vector; + vector* truePDG = new vector; + vector* isSeen = new vector; + vector* basicPDG = new vector; + vector* dEdxPDG = new vector; + vector* showerPDG = new vector; + vector* likeliPDG = new vector; + vector* lowmomPDG = new vector; + vector* trueCharge = new vector; + vector* seenCharge = new vector; + tree->SetBranchAddress("nMCParticles", &npart); + tree->SetBranchAddress(cutname, &cutvar); + tree->SetBranchAddress("trueCharge", &trueCharge); + tree->SetBranchAddress("truePDG", &truePDG); + tree->SetBranchAddress("isSeen", &isSeen); + tree->SetBranchAddress("seenCharge", &seenCharge); + tree->SetBranchAddress("basicPDG", &basicPDG); + tree->SetBranchAddress("dEdxPDG", &dEdxPDG); + tree->SetBranchAddress("showerPDG", &showerPDG); + tree->SetBranchAddress("likeliPDG", &likeliPDG); + tree->SetBranchAddress("lowmomPDG", &lowmomPDG); + + // cout << "after branch addressing " << endl; // loop over tree - bool truecut = false; + bool truecut = false; int nevts = tree->GetEntries(); int idmap[3000]; - idmap[11] = 0; + idmap[11] = 0; idmap[13] = 1; idmap[211] = 2; idmap[321] = 3; idmap[2212] = 4; for (int ievt = 0; ievt < nevts; ++ievt) { tree->GetEntry(ievt); - - for (int ipart = 0; ipart < truePDG->size(); ipart++) { - truecut = (pdg==0 || (pdg==1 && trueCharge->at(ipart)!=0) || (pdg==2 && trueCharge->at(ipart)==0) || (pdg > 10 && abs(truePDG->at(ipart)) == pdg)); - if (itruecut==5) { // cos theta - truecut &= (itruecut==0 || (fabs(cos(cutvar->at(ipart))) > cutmin && fabs(cos(cutvar->at(ipart))) < cutmax)); - } - else { - truecut &= (itruecut==0 || (cutvar->at(ipart) > cutmin && cutvar->at(ipart) < cutmax)); - } - - if (!truecut) continue; - - if (isSeen->at(ipart)<0.5) continue; - if (seenCharge->at(ipart)==0) continue; - + + for (int ipart = 0; ipart < truePDG->size(); ipart++) { + truecut = (pdg == 0 || (pdg == 1 && trueCharge->at(ipart) != 0) || (pdg == 2 && trueCharge->at(ipart) == 0) || + (pdg > 10 && abs(truePDG->at(ipart)) == pdg)); + if (itruecut == 5) { // cos theta + truecut &= (itruecut == 0 || (fabs(cos(cutvar->at(ipart))) > cutmin && fabs(cos(cutvar->at(ipart))) < cutmax)); + } else { + truecut &= (itruecut == 0 || (cutvar->at(ipart) > cutmin && cutvar->at(ipart) < cutmax)); + } + + if (!truecut) + continue; + + if (isSeen->at(ipart) < 0.5) + continue; + if (seenCharge->at(ipart) == 0) + continue; + hist[0]->Fill(idmap[abs(truePDG->at(ipart))]); hist[1]->Fill(idmap[abs(basicPDG->at(ipart))]); hist[2]->Fill(idmap[abs(dEdxPDG->at(ipart))]); @@ -217,16 +277,15 @@ void getPDGHistos (TH1F **hist, TTree *tree, int &pdg, int &itruecut) { hist[5]->Fill(idmap[abs(lowmomPDG->at(ipart))]); } } - -// for (int i = 0; i < 6; ++i) { -// // cout << "pdg, i = " << pdg << "," << i << ": npart = " << hist[i]->GetEntries() << endl; -// hist[i]->SetTitle(hname[i] + partname + cuttitle + TString("; ntot = ") + TString(hist[i]->GetEntries())); -// } - double ymax = hist[0]->GetMaximum()*1.2; + + // for (int i = 0; i < 6; ++i) { + // // cout << "pdg, i = " << pdg << "," << i << ": npart = " << hist[i]->GetEntries() << endl; + // hist[i]->SetTitle(hname[i] + partname + cuttitle + TString("; ntot = ") + TString(hist[i]->GetEntries())); + // } + double ymax = hist[0]->GetMaximum() * 1.2; for (int i = 0; i < 6; ++i) { hist[i]->SetAxisRange(0, ymax, "Y"); } - - return; + return; } diff --git a/PID/macros/plotdEdx.C b/PID/macros/plotdEdx.C index 64cecdd..19bc700 100644 --- a/PID/macros/plotdEdx.C +++ b/PID/macros/plotdEdx.C @@ -1,135 +1,135 @@ -#include "TH1.h" #include "PIDHelper.h" +#include "TH1.h" /** Very simply plotting of dEdx as a function of beta*gamma (p/m). - * + * */ -void plotdEdx(const char* _filename ) { +void plotdEdx(const char* _filename) { gROOT->SetStyle("ildStyle"); // use small markers: ildStyle->SetMarkerStyle(1); - TFile *treefile = new TFile(_filename); - TTree *hermTree = (TTree*) treefile->Get("hermTree"); + TFile* treefile = new TFile(_filename); + TTree* hermTree = (TTree*)treefile->Get("hermTree"); - const int nBins = 10000 ; - const double minX = 0.1 ; - const double maxX = 1e2 ; - const double minY = 0.00000008 ; - const double maxY = 0.0000003 ; + const int nBins = 10000; + const double minX = 0.1; + const double maxX = 1e2; + const double minY = 0.00000008; + const double maxY = 0.0000003; - TH2F* h1 = new TH2F("h1","All Partilces",nBins, minX, maxX, nBins, minY, maxY); - TH2F* h2 = new TH2F("h2","Electrons",nBins, minX, maxX, nBins, minY, maxY); - TH2F* h3 = new TH2F("h3","muons",nBins, minX, maxX, nBins, minY, maxY); - TH2F* h4 = new TH2F("h4","pions",nBins, minX, maxX, nBins, minY, maxY); - TH2F* h5 = new TH2F("h5","kaons",nBins, minX, maxX, nBins, minY, maxY); - TH2F* h6 = new TH2F("h6","protons",nBins, minX, maxX, nBins, minY, maxY); + TH2F* h1 = new TH2F("h1", "All Partilces", nBins, minX, maxX, nBins, minY, maxY); + TH2F* h2 = new TH2F("h2", "Electrons", nBins, minX, maxX, nBins, minY, maxY); + TH2F* h3 = new TH2F("h3", "muons", nBins, minX, maxX, nBins, minY, maxY); + TH2F* h4 = new TH2F("h4", "pions", nBins, minX, maxX, nBins, minY, maxY); + TH2F* h5 = new TH2F("h5", "kaons", nBins, minX, maxX, nBins, minY, maxY); + TH2F* h6 = new TH2F("h6", "protons", nBins, minX, maxX, nBins, minY, maxY); - h2->SetMarkerColor(kBlue); h3->SetMarkerColor(8); h4->SetMarkerColor(kRed); h5->SetMarkerColor(kOrange); h6->SetMarkerColor(1); - hermTree->Draw("seenDEdx:seenP>>h2","abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==11") ; - hermTree->Draw("seenDEdx:seenP>>h3","abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==13 "); - hermTree->Draw("seenDEdx:seenP>>h4","abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==211"); - hermTree->Draw("seenDEdx:seenP>>h5","abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==321"); - hermTree->Draw("seenDEdx:seenP>>h6","abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==2212"); + hermTree->Draw("seenDEdx:seenP>>h2", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==11"); + hermTree->Draw("seenDEdx:seenP>>h3", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==13 "); + hermTree->Draw("seenDEdx:seenP>>h4", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==211"); + hermTree->Draw("seenDEdx:seenP>>h5", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==321"); + hermTree->Draw("seenDEdx:seenP>>h6", + "abs(trueCharge)>0.5&&isSeen>0.7&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6&&abs(truePDG)==2212"); + TCanvas* c2 = new TCanvas("c2", "dE/dx of charged particles", 750, 750); - TCanvas* c2 = new TCanvas("c2","dE/dx of charged particles",750,750 ); - - c2->Divide(2,3) ; - - - c2->cd(1) ; + c2->Divide(2, 3); + + c2->cd(1); gPad->SetLogx(); - - h1->GetXaxis()->SetTitle("P/GeV" ); - h1->GetXaxis()->SetTitleSize( 0.04 ) ; - h1->GetXaxis()->SetTitleOffset( 1.5 ); - - h1->GetYaxis()->SetTitle( "dE/dx (MeV/g.cm^-2)" ); - h1->GetYaxis()->SetTitleSize( 0.06 ) ; - h1->GetYaxis()->SetTitleOffset( 1 ); - - h1->Draw() ; + + h1->GetXaxis()->SetTitle("P/GeV"); + h1->GetXaxis()->SetTitleSize(0.04); + h1->GetXaxis()->SetTitleOffset(1.5); + + h1->GetYaxis()->SetTitle("dE/dx (MeV/g.cm^-2)"); + h1->GetYaxis()->SetTitleSize(0.06); + h1->GetYaxis()->SetTitleOffset(1); + + h1->Draw(); h2->Draw("same"); h3->Draw("same"); h4->Draw("same"); h5->Draw("same"); - h6->Draw("same") ; - //hermTree->Draw("seenDEdx:trueP/trueMass","abs(trueCharge)>0.5&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6") ; - - - c2->cd(2) ; - gPad->SetLogx(); - h2->GetXaxis()->SetTitle("P/GeV" ); - h2->GetXaxis()->SetTitleSize( 0.04 ) ; - h2->GetXaxis()->SetTitleOffset( 1.5 ); - - h2->GetYaxis()->SetTitle( "dE/dx (MeV/g.cm^-2)" ); - h2->GetYaxis()->SetTitleSize( 0.06 ) ; - h2->GetYaxis()->SetTitleOffset( 1 ); - - h2->Draw(); - -c2->cd(3) ; - gPad->SetLogx(); - - h3->GetXaxis()->SetTitle("P/GeV" ); - h3->GetXaxis()->SetTitleSize( 0.04 ) ; - h3->GetXaxis()->SetTitleOffset( 1.5 ); - - h3->GetYaxis()->SetTitle( "dE/dx (MeV/g.cm^-2) " ); - h3->GetYaxis()->SetTitleSize( 0.06 ) ; - h3->GetYaxis()->SetTitleOffset(1 ); - -h3->Draw(); - -c2->cd(4) ; -gPad->SetLogx(); - - h4->GetXaxis()->SetTitle("P/GeV" ); - h4->GetXaxis()->SetTitleSize( 0.04 ) ; - h4->GetXaxis()->SetTitleOffset( 1.5 ); - - h4->GetYaxis()->SetTitle( "dE/dx (MeV/g.cm^-2)" ); - h4->GetYaxis()->SetTitleSize( 0.06 ) ; - h4->GetYaxis()->SetTitleOffset( 1 ); - -h4->Draw(); - - c2->cd(5) ; -gPad->SetLogx() ; - - h5->GetXaxis()->SetTitle("P/GeV" ); - h5->GetXaxis()->SetTitleSize( 0.04 ) ; - h5->GetXaxis()->SetTitleOffset( 1.5 ); - - h5->GetYaxis()->SetTitle( "dE/dx (MeV/g.cm^-2)" ); - h5->GetYaxis()->SetTitleSize( 0.06 ) ; - h5->GetYaxis()->SetTitleOffset( 1 ); - -h5->Draw(); - - c2->cd(6) ; - gPad->SetLogx() ; - - h6->GetXaxis()->SetTitle("P/GeV" ); - h6->GetXaxis()->SetTitleSize( 0.04 ) ; - h6->GetXaxis()->SetTitleOffset( 1.5 ); - h6->GetYaxis()->SetTitle( "dE/dx (MeV/g.cm^-2)" ); - h6->GetYaxis()->SetTitleSize( 0.06 ) ; - h6->GetYaxis()->SetTitleOffset( 1 ); - - h6->Draw(); - - TString outfile = getPathPrefix( _filename ) ; - outfile += "dEdx_plots_output"; - c2->Print(TString(outfile+".pdf")); + h6->Draw("same"); + // hermTree->Draw("seenDEdx:trueP/trueMass","abs(trueCharge)>0.5&&trueMass>0.&&seenDEdx>0.&&seenDEdx<1.e-6") ; + + c2->cd(2); + gPad->SetLogx(); + h2->GetXaxis()->SetTitle("P/GeV"); + h2->GetXaxis()->SetTitleSize(0.04); + h2->GetXaxis()->SetTitleOffset(1.5); + + h2->GetYaxis()->SetTitle("dE/dx (MeV/g.cm^-2)"); + h2->GetYaxis()->SetTitleSize(0.06); + h2->GetYaxis()->SetTitleOffset(1); + + h2->Draw(); + + c2->cd(3); + gPad->SetLogx(); + + h3->GetXaxis()->SetTitle("P/GeV"); + h3->GetXaxis()->SetTitleSize(0.04); + h3->GetXaxis()->SetTitleOffset(1.5); + + h3->GetYaxis()->SetTitle("dE/dx (MeV/g.cm^-2) "); + h3->GetYaxis()->SetTitleSize(0.06); + h3->GetYaxis()->SetTitleOffset(1); + + h3->Draw(); + + c2->cd(4); + gPad->SetLogx(); + + h4->GetXaxis()->SetTitle("P/GeV"); + h4->GetXaxis()->SetTitleSize(0.04); + h4->GetXaxis()->SetTitleOffset(1.5); + + h4->GetYaxis()->SetTitle("dE/dx (MeV/g.cm^-2)"); + h4->GetYaxis()->SetTitleSize(0.06); + h4->GetYaxis()->SetTitleOffset(1); + + h4->Draw(); + + c2->cd(5); + gPad->SetLogx(); + + h5->GetXaxis()->SetTitle("P/GeV"); + h5->GetXaxis()->SetTitleSize(0.04); + h5->GetXaxis()->SetTitleOffset(1.5); + + h5->GetYaxis()->SetTitle("dE/dx (MeV/g.cm^-2)"); + h5->GetYaxis()->SetTitleSize(0.06); + h5->GetYaxis()->SetTitleOffset(1); + + h5->Draw(); + + c2->cd(6); + gPad->SetLogx(); + + h6->GetXaxis()->SetTitle("P/GeV"); + h6->GetXaxis()->SetTitleSize(0.04); + h6->GetXaxis()->SetTitleOffset(1.5); + h6->GetYaxis()->SetTitle("dE/dx (MeV/g.cm^-2)"); + h6->GetYaxis()->SetTitleSize(0.06); + h6->GetYaxis()->SetTitleOffset(1); + + h6->Draw(); + TString outfile = getPathPrefix(_filename); + outfile += "dEdx_plots_output"; + c2->Print(TString(outfile + ".pdf")); } diff --git a/PID/macros/rootlogon.C b/PID/macros/rootlogon.C index 5891074..c0987f8 100644 --- a/PID/macros/rootlogon.C +++ b/PID/macros/rootlogon.C @@ -1,86 +1,84 @@ { -//ild TStyle -TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); - -//set the background color to white -ildStyle->SetFillColor(10); -ildStyle->SetFrameFillColor(10); -ildStyle->SetCanvasColor(10); -ildStyle->SetPadColor(10); -ildStyle->SetTitleFillColor(0); -ildStyle->SetStatColor(10); - -//dont put a colored frame around the plots -ildStyle->SetFrameBorderMode(0); -ildStyle->SetCanvasBorderMode(0); -ildStyle->SetPadBorderMode(0); -ildStyle->SetLegendBorderSize(0); - -//use the primary color palette -ildStyle->SetPalette(1,0); - -//set the default line color for a histogram to be black -ildStyle->SetHistLineColor(kBlack); - -//set the default line color for a fit function to be red -ildStyle->SetFuncColor(kRed); - -//make the axis labels black -ildStyle->SetLabelColor(kBlack,"xyz"); - -//set the default title color to be black -ildStyle->SetTitleColor(kBlack); - -//set the margins -ildStyle->SetPadBottomMargin(0.18); -ildStyle->SetPadTopMargin(0.08); -ildStyle->SetPadRightMargin(0.08); -ildStyle->SetPadLeftMargin(0.17); - -//set axis label and title text sizes -ildStyle->SetLabelFont(42,"xyz"); -ildStyle->SetLabelSize(0.06,"xyz"); -ildStyle->SetLabelOffset(0.015,"xyz"); -ildStyle->SetTitleFont(42,"xyz"); -ildStyle->SetTitleSize(0.07,"xyz"); -ildStyle->SetTitleOffset(1.1,"yz"); -ildStyle->SetTitleOffset(1.0,"x"); -ildStyle->SetStatFont(42); -ildStyle->SetStatFontSize(0.07); -ildStyle->SetTitleBorderSize(0); -ildStyle->SetStatBorderSize(0); -ildStyle->SetTextFont(42); - -//set line widths -ildStyle->SetFrameLineWidth(2); -ildStyle->SetFuncWidth(2); -ildStyle->SetHistLineWidth(2); - -//set the number of divisions to show -ildStyle->SetNdivisions(506, "xy"); - -//turn off xy grids -ildStyle->SetPadGridX(0); -ildStyle->SetPadGridY(0); - -//set the tick mark style -ildStyle->SetPadTickX(1); -ildStyle->SetPadTickY(1); - -//turn off stats -ildStyle->SetOptStat(0); -ildStyle->SetOptFit(0); - -//marker settings -ildStyle->SetMarkerStyle(20); -ildStyle->SetMarkerSize(0.7); -ildStyle->SetLineWidth(2); - -//done -ildStyle->cd(); -gROOT->ForceStyle(); -gStyle->ls(); - + // ild TStyle + TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); + + // set the background color to white + ildStyle->SetFillColor(10); + ildStyle->SetFrameFillColor(10); + ildStyle->SetCanvasColor(10); + ildStyle->SetPadColor(10); + ildStyle->SetTitleFillColor(0); + ildStyle->SetStatColor(10); + + // dont put a colored frame around the plots + ildStyle->SetFrameBorderMode(0); + ildStyle->SetCanvasBorderMode(0); + ildStyle->SetPadBorderMode(0); + ildStyle->SetLegendBorderSize(0); + + // use the primary color palette + ildStyle->SetPalette(1, 0); + + // set the default line color for a histogram to be black + ildStyle->SetHistLineColor(kBlack); + + // set the default line color for a fit function to be red + ildStyle->SetFuncColor(kRed); + + // make the axis labels black + ildStyle->SetLabelColor(kBlack, "xyz"); + + // set the default title color to be black + ildStyle->SetTitleColor(kBlack); + + // set the margins + ildStyle->SetPadBottomMargin(0.18); + ildStyle->SetPadTopMargin(0.08); + ildStyle->SetPadRightMargin(0.08); + ildStyle->SetPadLeftMargin(0.17); + + // set axis label and title text sizes + ildStyle->SetLabelFont(42, "xyz"); + ildStyle->SetLabelSize(0.06, "xyz"); + ildStyle->SetLabelOffset(0.015, "xyz"); + ildStyle->SetTitleFont(42, "xyz"); + ildStyle->SetTitleSize(0.07, "xyz"); + ildStyle->SetTitleOffset(1.1, "yz"); + ildStyle->SetTitleOffset(1.0, "x"); + ildStyle->SetStatFont(42); + ildStyle->SetStatFontSize(0.07); + ildStyle->SetTitleBorderSize(0); + ildStyle->SetStatBorderSize(0); + ildStyle->SetTextFont(42); + + // set line widths + ildStyle->SetFrameLineWidth(2); + ildStyle->SetFuncWidth(2); + ildStyle->SetHistLineWidth(2); + + // set the number of divisions to show + ildStyle->SetNdivisions(506, "xy"); + + // turn off xy grids + ildStyle->SetPadGridX(0); + ildStyle->SetPadGridY(0); + + // set the tick mark style + ildStyle->SetPadTickX(1); + ildStyle->SetPadTickY(1); + + // turn off stats + ildStyle->SetOptStat(0); + ildStyle->SetOptFit(0); + + // marker settings + ildStyle->SetMarkerStyle(20); + ildStyle->SetMarkerSize(0.7); + ildStyle->SetLineWidth(2); + + // done + ildStyle->cd(); + gROOT->ForceStyle(); + gStyle->ls(); } - diff --git a/TimeOfFlight/macros/plotting/draw_tof_singleparticle.cpp b/TimeOfFlight/macros/plotting/draw_tof_singleparticle.cpp index db6f068..52fcf24 100644 --- a/TimeOfFlight/macros/plotting/draw_tof_singleparticle.cpp +++ b/TimeOfFlight/macros/plotting/draw_tof_singleparticle.cpp @@ -1,229 +1,247 @@ -#include "tof_helpers.cpp" #include "../reading_config/read_config.cpp" +#include "tof_helpers.cpp" -void draw_tof_singleparticle(const string ConfigDir="../..", const string InFileBase = "../../output/SingleParticle_rv02-00-01_sv02-00-01_mILD_l5_o1_v02/", const string OutFileBase = "../../output/SP") { - string plot_config_path = ConfigDir + "/PlottingSettings.cnf"; +void draw_tof_singleparticle( + const string ConfigDir = "../..", + const string InFileBase = "../../output/SingleParticle_rv02-00-01_sv02-00-01_mILD_l5_o1_v02/", + const string OutFileBase = "../../output/SP") { + string plot_config_path = ConfigDir + "/PlottingSettings.cnf"; string ptype_config_path = ConfigDir + "/ParticleTypes.cnf"; - string res_config_path = ConfigDir + "/TimeResolutions.cnf"; + string res_config_path = ConfigDir + "/TimeResolutions.cnf"; - float min_p = 0, max_p = 100; + float min_p = 0, max_p = 100; float min_beta = 0.5, max_beta = 1.05; ConfigReader plot_settings_reader(plot_config_path); auto beta_p_settings = plot_settings_reader["BetaPPlots"]; - int bins_p = stoi(beta_p_settings["NbinsBeta"]); - int bins_beta = stoi(beta_p_settings["NbinsP"]); - int every_nth_bin = stoi(beta_p_settings["BinJumpsPerSlice"]); // Consider only every n-th bin (=slice) in the momentum distribution - + int bins_p = stoi(beta_p_settings["NbinsBeta"]); + int bins_beta = stoi(beta_p_settings["NbinsP"]); + int every_nth_bin = + stoi(beta_p_settings["BinJumpsPerSlice"]); // Consider only every n-th bin (=slice) in the momentum distribution + ConfigReader ptype_reader(ptype_config_path); - ParticleVec particle_types {}; + ParticleVec particle_types{}; auto ptype_names = ptype_reader.get_keys(); - for (auto & ptype_name: ptype_names) { - auto ptype_sec = ptype_reader[ptype_name]; // Section - particle_types.push_back( ParticleType(stoi(ptype_sec["pdgID"]), ptype_sec["name_s"], ptype_name, stod(ptype_sec["mass"]), stoi(ptype_sec["colour"])) ); + for (auto& ptype_name : ptype_names) { + auto ptype_sec = ptype_reader[ptype_name]; // Section + particle_types.push_back(ParticleType(stoi(ptype_sec["pdgID"]), ptype_sec["name_s"], ptype_name, + stod(ptype_sec["mass"]), stoi(ptype_sec["colour"]))); } int N_ptypes = particle_types.size(); - + ConfigReader res_reader(res_config_path); - ResVec resolutions {}; + ResVec resolutions{}; auto res_values = res_reader.get_keys(); - for (auto & res_value: res_values) { - auto res_sec = res_reader[res_value]; - resolutions.push_back( Resolution(stof(res_value), stoi(res_sec["colour"])) ); + for (auto& res_value : res_values) { + auto res_sec = res_reader[res_value]; + resolutions.push_back(Resolution(stof(res_value), stoi(res_sec["colour"]))); } int N_ress = resolutions.size(); - - HistoMap beta_histos {}; - - for ( auto &ptype : particle_types ) { - for ( auto &res : resolutions) { - beta_histos.addHisto( ptype, res ); + + HistoMap beta_histos{}; + + for (auto& ptype : particle_types) { + for (auto& res : resolutions) { + beta_histos.addHisto(ptype, res); } } // TODO Also loop over different time estimators?? (Here: CH -> Closest Hit) - unique_ptr c_dummy {new TCanvas("dummy","",1000,800)}; // To write histos to that don't need to be written to current canvas + unique_ptr c_dummy{ + new TCanvas("dummy", "", 1000, 800)}; // To write histos to that don't need to be written to current canvas - unique_ptr c_beta_p {new TCanvas("c_beta_p","#beta_{CH} vs momentum",400*N_ress,400*N_ptypes)}; - unique_ptr c_beta_p_average {new TCanvas("c_beta_p_average","#beta_{CH}^{average} vs momentum",400*N_ress,400*N_ptypes)}; + unique_ptr c_beta_p{new TCanvas("c_beta_p", "#beta_{CH} vs momentum", 400 * N_ress, 400 * N_ptypes)}; + unique_ptr c_beta_p_average{ + new TCanvas("c_beta_p_average", "#beta_{CH}^{average} vs momentum", 400 * N_ress, 400 * N_ptypes)}; c_beta_p->Clear(); c_beta_p_average->Clear(); c_beta_p->Divide(resolutions.size(), particle_types.size()); c_beta_p_average->Divide(resolutions.size(), particle_types.size()); - int i_pad=0; - - vector closables {}; // Because ROOT... To collect files that I need to close later - - unique_ptr file_beta_p {new TFile ( ( OutFileBase + "_beta_p.root" ).c_str() ,"recreate")}; - + int i_pad = 0; + + vector closables{}; // Because ROOT... To collect files that I need to close later + + unique_ptr file_beta_p{new TFile((OutFileBase + "_beta_p.root").c_str(), "recreate")}; + // Get the beta vs p histograms and save for each particle type - for ( auto & ptype : particle_types ) { - TFile* file = new TFile ( ( InFileBase + to_string(ptype.pdg_id) + "_lctuple.root" ).c_str() ,"r"); - TTree* tree = (TTree*) file->Get("MyLCTuple"); - - TF1* beta_func = new TF1( ("beta_func_" + ptype.name_s).c_str(), "x / sqrt(x^2 + [0]^2)", min_p, max_p); + for (auto& ptype : particle_types) { + TFile* file = new TFile((InFileBase + to_string(ptype.pdg_id) + "_lctuple.root").c_str(), "r"); + TTree* tree = (TTree*)file->Get("MyLCTuple"); + + TF1* beta_func = new TF1(("beta_func_" + ptype.name_s).c_str(), "x / sqrt(x^2 + [0]^2)", min_p, max_p); beta_func->SetParameter(0, ptype.mass); beta_func->SetLineWidth(1); beta_func->SetLineColorAlpha(6, 0.5); file_beta_p->WriteTObject(beta_func); - - for (auto &res : resolutions) { + + for (auto& res : resolutions) { i_pad++; c_beta_p->cd(i_pad); string h_beta_name = "h_beta_" + ptype.name_s + "_" + res.str(); - TH2F *h_beta = new TH2F( h_beta_name.c_str(), - ("#beta_{CH} vs momentum, " + ptype.name_l + ", " + res.w_unit() + "; p [GeV/c] ; #beta ").c_str(), - bins_p, min_p, max_p, bins_beta, min_beta, max_beta - ); - + TH2F* h_beta = + new TH2F(h_beta_name.c_str(), + ("#beta_{CH} vs momentum, " + ptype.name_l + ", " + res.w_unit() + "; p [GeV/c] ; #beta ").c_str(), + bins_p, min_p, max_p, bins_beta, min_beta, max_beta); + string tof_res = "tof" + res.str(); - string draw_string = tof_res + "len/" + tof_res + "ch/299.8:sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)>>" + h_beta_name; - string cut_string = tof_res + "len>1.&&" + tof_res + "ch>0.1&&(" + tof_res + "len/" + tof_res + "ch/299.8)<1.1 && sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)<100.&&abs(rccha)>0.005 && abs(rcmoz)/sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz) < 0.792573 && sqrt(rcmox*rcmox+rcmoy*rcmoy) > 0.948543 && nrec==1"; - - tree->Draw( draw_string.c_str(), cut_string.c_str(), "colz" ); + string draw_string = + tof_res + "len/" + tof_res + "ch/299.8:sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)>>" + h_beta_name; + string cut_string = tof_res + "len>1.&&" + tof_res + "ch>0.1&&(" + tof_res + "len/" + tof_res + + "ch/299.8)<1.1 && sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)<100.&&abs(rccha)>0.005 && " + "abs(rcmoz)/sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz) < 0.792573 && " + "sqrt(rcmox*rcmox+rcmoy*rcmoy) > 0.948543 && nrec==1"; + + tree->Draw(draw_string.c_str(), cut_string.c_str(), "colz"); file_beta_p->WriteTObject(h_beta); beta_func->Draw("same"); - + c_dummy->cd(); beta_histos.getHisto(res, ptype)->histo = h_beta; beta_histos.getHisto(res, ptype)->slice_histo(every_nth_bin); - + c_beta_p_average->cd(i_pad); string h_beta_average_name = "h_beta_average_" + ptype.name_s + "_" + res.str(); - TH1F* h_beta_average = new TH1F( h_beta_average_name.c_str(), - ("#beta_{CH}^{average} vs momentum, " + ptype.name_l + ", " + res.w_unit() + ", error = #sigma_{gaus}; p [GeV/c] ; #beta ").c_str(), - bins_p, min_p, max_p - ); - for ( auto & slice: beta_histos.getHisto(res, ptype)->slices ) { + TH1F* h_beta_average = new TH1F(h_beta_average_name.c_str(), + ("#beta_{CH}^{average} vs momentum, " + ptype.name_l + ", " + res.w_unit() + + ", error = #sigma_{gaus}; p [GeV/c] ; #beta ") + .c_str(), + bins_p, min_p, max_p); + for (auto& slice : beta_histos.getHisto(res, ptype)->slices) { int bin = h_beta_average->FindBin(slice.p); if (slice.fit_successful) { h_beta_average->SetBinContent(bin, slice.mean); - h_beta_average->SetBinError( bin, slice.sigma); + h_beta_average->SetBinError(bin, slice.sigma); } } h_beta_average->SetMarkerSize(0); h_beta_average->SetFillColor(2); h_beta_average->Draw("E5"); beta_func->Draw("same"); - + file_beta_p->WriteTObject(h_beta_average); file->cd(); } closables.push_back(file); } - c_beta_p->Print( (OutFileBase + "_beta_p.pdf").c_str() ); - c_beta_p_average->Print( (OutFileBase + "_beta_p_average.pdf").c_str() ); - + c_beta_p->Print((OutFileBase + "_beta_p.pdf").c_str()); + c_beta_p_average->Print((OutFileBase + "_beta_p_average.pdf").c_str()); + file_beta_p->Close(); - + // Save the sliced histograms - for ( auto & res: resolutions ) { - unique_ptr file_slices { new TFile( (OutFileBase + "_slices_" + res.w_unit() + ".root").c_str(), "RECREATE" ) }; + for (auto& res : resolutions) { + unique_ptr file_slices{new TFile((OutFileBase + "_slices_" + res.w_unit() + ".root").c_str(), "RECREATE")}; - for ( auto & histo: beta_histos.getHistosToRes(res) ) { - for ( auto & slice: histo->slices ) { + for (auto& histo : beta_histos.getHistosToRes(res)) { + for (auto& slice : histo->slices) { slice.histo->Write(); } } file_slices->Close(); } - - unique_ptr file_sep_pwr { new TFile( (OutFileBase + "_separation_powers.root").c_str(), "RECREATE" ) }; - // Find separation power for all combinations - for (int i=0; i file_sep_pwr{new TFile((OutFileBase + "_separation_powers.root").c_str(), "RECREATE")}; + // Find separation power for all combinations + for (int i = 0; i < N_ptypes - 1; i++) { + if (1 == N_ptypes) { cout << "Only one particle type given, not creating separation power plots." << endl; break; } - for (int j=i+1; j c_sep_pwr {new TCanvas( ("c_sep_pwr_" + ptype1.name_s + "_" + ptype2.name_s).c_str() , - "Separation power vs momentum", - 800*resolutions.size(),800)}; + + unique_ptr c_sep_pwr{new TCanvas(("c_sep_pwr_" + ptype1.name_s + "_" + ptype2.name_s).c_str(), + "Separation power vs momentum", 800 * resolutions.size(), 800)}; c_sep_pwr->Divide(resolutions.size(), 1); int i_seppwr_pad = 1; - - vector> sep_pwr_hists {}; - - for ( auto & res: resolutions ) { + + vector> sep_pwr_hists{}; + + for (auto& res : resolutions) { auto slices_p1 = beta_histos.getHisto(res, ptype1)->slices; auto slices_p2 = beta_histos.getHisto(res, ptype2)->slices; - + int N_slices = slices_p1.size(); - - TH1D* h_seppwr = new TH1D(("h_seppwr_" + ptype1.name_s + ptype2.name_s + res.str()).c_str(), - (ptype1.name_l + " - " + ptype2.name_l + " TOF-separation, " + res.w_unit() + "; p [GeV/c] ; Separation Power [#sigma]").c_str(), + + TH1D* h_seppwr = new TH1D(("h_seppwr_" + ptype1.name_s + ptype2.name_s + res.str()).c_str(), + (ptype1.name_l + " - " + ptype2.name_l + " TOF-separation, " + res.w_unit() + + "; p [GeV/c] ; Separation Power [#sigma]") + .c_str(), N_slices, min_p, max_p); - - for (int i_slice=0; i_sliceSetBinContent(h_seppwr->FindBin(p), sep_pwr); - h_seppwr->SetBinError( h_seppwr->FindBin(p), sep_pwr_err); - } - + h_seppwr->SetBinError(h_seppwr->FindBin(p), sep_pwr_err); + } + h_seppwr->Write(); - + c_sep_pwr->cd(i_seppwr_pad++); h_seppwr->Draw("pe"); // TODO Better drawing style: Set some better markers, REMOVE X ERROR h_seppwr->SetMinimum(0); h_seppwr->SetMaximum(40); - - sep_pwr_hists.push_back(make_pair(res,h_seppwr)); + + sep_pwr_hists.push_back(make_pair(res, h_seppwr)); } c_sep_pwr->Write(); - - unique_ptr c_sep_pwr_comb { new TCanvas( ("c_sep_pwr_comb_" + ptype1.name_s + "_" + ptype2.name_s).c_str() , - "Separation power vs momentum", - 800,800) - }; - unique_ptr h_sep_pwr_comb { new THStack( - ("h_seppwr_comb_" + ptype1.name_s + ptype2.name_s).c_str(), - (ptype1.name_l + " - " + ptype2.name_l + " TOF-separation; p [GeV/c] ; Separation Power [#sigma]").c_str()) - }; - unique_ptr leg_sep_pwr_comb { new TLegend(0.48,0.7,0.8,0.9) }; - for (auto &res_hist: sep_pwr_hists) { - Resolution res = res_hist.first; - TH1D* h_seppwr = res_hist.second; + + unique_ptr c_sep_pwr_comb{new TCanvas(("c_sep_pwr_comb_" + ptype1.name_s + "_" + ptype2.name_s).c_str(), + "Separation power vs momentum", 800, 800)}; + unique_ptr h_sep_pwr_comb{new THStack( + ("h_seppwr_comb_" + ptype1.name_s + ptype2.name_s).c_str(), + (ptype1.name_l + " - " + ptype2.name_l + " TOF-separation; p [GeV/c] ; Separation Power [#sigma]").c_str())}; + unique_ptr leg_sep_pwr_comb{new TLegend(0.48, 0.7, 0.8, 0.9)}; + for (auto& res_hist : sep_pwr_hists) { + Resolution res = res_hist.first; + TH1D* h_seppwr = res_hist.second; leg_sep_pwr_comb->AddEntry(h_seppwr, res.w_unit().c_str(), "lep"); h_sep_pwr_comb->Add(h_seppwr); h_seppwr->SetLineColor(res.colour_index); } h_sep_pwr_comb->Draw("nostack"); h_sep_pwr_comb->SetMinimum(0); - if( h_sep_pwr_comb->GetMaximum() > 120 ) { h_sep_pwr_comb->SetMaximum(100); } + if (h_sep_pwr_comb->GetMaximum() > 120) { + h_sep_pwr_comb->SetMaximum(100); + } gPad->Modified(); gPad->Update(); leg_sep_pwr_comb->Draw(); - c_sep_pwr_comb->Write(); + c_sep_pwr_comb->Write(); } } file_sep_pwr->Close(); - for ( auto & closable : closables ) { + for (auto& closable : closables) { closable->Close(); delete closable; - } + } } \ No newline at end of file diff --git a/TimeOfFlight/macros/plotting/draw_tof_ttbar.cpp b/TimeOfFlight/macros/plotting/draw_tof_ttbar.cpp index b4c4d51..bef519e 100644 --- a/TimeOfFlight/macros/plotting/draw_tof_ttbar.cpp +++ b/TimeOfFlight/macros/plotting/draw_tof_ttbar.cpp @@ -2,89 +2,90 @@ // TODO More status reports!!! // TODO CHANGE DEFAULT IN FILE NAME -void draw_tof_ttbar( const string InFile = "lctuplep.root", const string OutFileBase = "ttbar" ){ - - ParticleVec particle_types {}; - particle_types.push_back( ParticleType(2212, "p", "Proton", 0.938272, kRed+1) ); - particle_types.push_back( ParticleType(321, "K", "Kaon", 0.493677, kGreen+2) ); - particle_types.push_back( ParticleType(211, "Pi", "Pion", 0.13957, kViolet) ); - particle_types.push_back( ParticleType(11, "e1", "Electron", 0.000511, kCyan+1) ); - particle_types.push_back( ParticleType(13, "e2", "Muon", 0.1056584, kBlue-3) ); - - ResVec resolutions {}; - resolutions.push_back( Resolution(0, kBlue) ); - resolutions.push_back( Resolution(10, kGreen+1) ); - resolutions.push_back( Resolution(50, kRed+2) ); - - HistoMap beta_histos {}; +void draw_tof_ttbar(const string InFile = "lctuplep.root", const string OutFileBase = "ttbar") { + + ParticleVec particle_types{}; + particle_types.push_back(ParticleType(2212, "p", "Proton", 0.938272, kRed + 1)); + particle_types.push_back(ParticleType(321, "K", "Kaon", 0.493677, kGreen + 2)); + particle_types.push_back(ParticleType(211, "Pi", "Pion", 0.13957, kViolet)); + particle_types.push_back(ParticleType(11, "e1", "Electron", 0.000511, kCyan + 1)); + particle_types.push_back(ParticleType(13, "e2", "Muon", 0.1056584, kBlue - 3)); + + ResVec resolutions{}; + resolutions.push_back(Resolution(0, kBlue)); + resolutions.push_back(Resolution(10, kGreen + 1)); + resolutions.push_back(Resolution(50, kRed + 2)); + + HistoMap beta_histos{}; ParticleType ttbar = ParticleType("ttbar", "ttbar"); - for ( auto &res : resolutions) { - beta_histos.addHisto( ttbar, res ); + for (auto& res : resolutions) { + beta_histos.addHisto(ttbar, res); } - + int bins_per_slice = 10; - - unique_ptr c_dummy {new TCanvas("dummy","",1000,800)}; // To write histos to that don't need to be written to current canvas - - unique_ptr file { new TFile (InFile.c_str(),"r") }; - TTree* tree = (TTree*) file->Get("MyLCTuple"); - unique_ptr file_all_ptypes { new TFile( (OutFileBase + "_all_particles.root").c_str(), "RECREATE" ) }; + unique_ptr c_dummy{ + new TCanvas("dummy", "", 1000, 800)}; // To write histos to that don't need to be written to current canvas + + unique_ptr file{new TFile(InFile.c_str(), "r")}; + TTree* tree = (TTree*)file->Get("MyLCTuple"); - for (auto &res : resolutions) { + unique_ptr file_all_ptypes{new TFile((OutFileBase + "_all_particles.root").c_str(), "RECREATE")}; - unique_ptr c_beta_p { new TCanvas( ("c_beta_p_" + res.str()).c_str(), - ("#beta vs momentum, ttbar, " + res.w_unit()).c_str(), - 500,500) }; //(plot, name, [ 10, -5, -10 100 all looks same] ) + for (auto& res : resolutions) { + + unique_ptr c_beta_p{new TCanvas(("c_beta_p_" + res.str()).c_str(), + ("#beta vs momentum, ttbar, " + res.w_unit()).c_str(), 500, + 500)}; //(plot, name, [ 10, -5, -10 100 all looks same] ) c_beta_p->Clear(); string h_beta_name = "h_beta_" + res.str(); - TH2F *h_beta = new TH2F( h_beta_name.c_str(), - ("#beta vs momentum, ttbar, " + res.w_unit()).c_str(), - 200, 0, 10., 200, 0.5, 1.); // (plot ,name ,nbin x ,x low ,x up ,nbin y ,y low ,y up) - + TH2F* h_beta = new TH2F(h_beta_name.c_str(), ("#beta vs momentum, ttbar, " + res.w_unit()).c_str(), 200, 0, 10., + 200, 0.5, 1.); // (plot ,name ,nbin x ,x low ,x up ,nbin y ,y low ,y up) + string tof_res = "tof" + res.str(); - string draw_string = tof_res + "len/" + tof_res + "ch/299.8:sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)>>" + h_beta_name; - string cut_string = tof_res + "len>1.&&" + tof_res + "ch>0.1&&(" + tof_res + "len/" + tof_res + "ch/299.8)<1.1 && sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)<10.&&abs(rccha)>0.01"; - tree->Draw( draw_string.c_str(), cut_string.c_str() ); + string draw_string = + tof_res + "len/" + tof_res + "ch/299.8:sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)>>" + h_beta_name; + string cut_string = tof_res + "len>1.&&" + tof_res + "ch>0.1&&(" + tof_res + "len/" + tof_res + + "ch/299.8)<1.1 && sqrt(rcmox*rcmox+rcmoy*rcmoy+rcmoz*rcmoz)<10.&&abs(rccha)>0.01"; + tree->Draw(draw_string.c_str(), cut_string.c_str()); h_beta->Write(); - for ( auto & ptype : particle_types ) { - TF1* beta_func = new TF1( ("beta_func_" + ptype.name_l).c_str(), "x / sqrt(x^2 + [0]^2)", 0., 10); + for (auto& ptype : particle_types) { + TF1* beta_func = new TF1(("beta_func_" + ptype.name_l).c_str(), "x / sqrt(x^2 + [0]^2)", 0., 10); beta_func->SetParameter(0, ptype.mass); beta_func->Draw("same"); beta_func->SetLineColor(ptype.colour_index); - } c_beta_p->Update(); c_beta_p->Write(); c_beta_p->Close(); - + // c_dummy->cd(); beta_histos.getHisto(res, ttbar)->histo = h_beta; beta_histos.getHisto(res, ttbar)->slice_histo(bins_per_slice, false); - + int N_slices = beta_histos.getHisto(res, ttbar)->slices.size(); - unique_ptr c_beta_p_slices { new TCanvas( ("c_beta_p_slices_" + res.str()).c_str(), - ("#beta, p slices, ttbar, " + res.w_unit()).c_str(), - 500*N_slices,500) }; //(plot, name, [ 10, -5, -10 100 all looks same] ) + unique_ptr c_beta_p_slices{new TCanvas(("c_beta_p_slices_" + res.str()).c_str(), + ("#beta, p slices, ttbar, " + res.w_unit()).c_str(), 500 * N_slices, + 500)}; //(plot, name, [ 10, -5, -10 100 all looks same] ) c_beta_p_slices->Divide(N_slices, 1); int i_pad = 1; - - unique_ptr dir_slices { file_all_ptypes->mkdir( ("slices_" + res.str()).c_str() ) }; - for ( auto & slice: beta_histos.getHisto(res, ttbar)->slices ) { + + unique_ptr dir_slices{file_all_ptypes->mkdir(("slices_" + res.str()).c_str())}; + for (auto& slice : beta_histos.getHisto(res, ttbar)->slices) { c_beta_p_slices->cd(i_pad++); slice.histo->Draw(); - - for ( auto & ptype : particle_types ) { + + for (auto& ptype : particle_types) { double p = slice.p; - double beta = p/sqrt(ptype.mass*ptype.mass + p*p); - TLine *line = new TLine(beta,0.0,beta,1000); + double beta = p / sqrt(ptype.mass * ptype.mass + p * p); + TLine* line = new TLine(beta, 0.0, beta, 1000); line->SetLineColor(ptype.colour_index); line->Draw(); } - + dir_slices->cd(); slice.histo->Write(); } @@ -94,55 +95,57 @@ void draw_tof_ttbar( const string InFile = "lctuplep.root", const string OutFile c_beta_p_slices->Write(); c_beta_p_slices->Close(); } - + file_all_ptypes->Close(); - + ////////////////////////////////////////////////////////////////////////////// - unique_ptr file_diff { new TFile( (OutFileBase + "_tof_diffs.root").c_str(), "RECREATE" ) }; + unique_ptr file_diff{new TFile((OutFileBase + "_tof_diffs.root").c_str(), "RECREATE")}; - MethodVec tof_methods {}; // TODO Move this to start and make universal also in other draw + MethodVec tof_methods{}; // TODO Move this to start and make universal also in other draw tof_methods.push_back(Method("ch", "Closest Hits")); tof_methods.push_back(Method("fh", "First Hit")); tof_methods.push_back(Method("th", "Last Tracker Hit")); - for (int i=0; i c_tof_diff { new TCanvas( ("c_tof_diff_" + res_1.str() + res_2.str() + method.name_s).c_str(), - ("TOF difference " + method.name_l + ", " + res_1.w_unit() + "-" + res_2.w_unit()).c_str(), - 500, 500) }; - c_tof_diff->Clear(); + + for (auto& method : tof_methods) { + unique_ptr c_tof_diff{new TCanvas( + ("c_tof_diff_" + res_1.str() + res_2.str() + method.name_s).c_str(), + ("TOF difference " + method.name_l + ", " + res_1.w_unit() + "-" + res_2.w_unit()).c_str(), 500, 500)}; + c_tof_diff->Clear(); string h_diff_name = "h_tof_diff_" + res_1.str() + res_2.str() + method.name_s; - TH1D *h_tof_diff = new TH1D( h_diff_name.c_str(), - ("#Delta TOF_{" + method.name_s + "}, " + res_1.w_unit() + "-" + res_2.w_unit() + "; #Delta TOF; #").c_str(), - 1000, -1. ,1.); - - - string draw_string = "tof" + res_1.str() + method.name_s + "-tof" + res_2.str() + method.name_s + ">>" + h_diff_name; - string cut_string = "tof" + res_1.str() + method.name_s + " != -1 && tof" + res_2.str() + method.name_s + " != -1"; + TH1D* h_tof_diff = new TH1D( + h_diff_name.c_str(), + ("#Delta TOF_{" + method.name_s + "}, " + res_1.w_unit() + "-" + res_2.w_unit() + "; #Delta TOF; #") + .c_str(), + 1000, -1., 1.); + + string draw_string = + "tof" + res_1.str() + method.name_s + "-tof" + res_2.str() + method.name_s + ">>" + h_diff_name; + string cut_string = + "tof" + res_1.str() + method.name_s + " != -1 && tof" + res_2.str() + method.name_s + " != -1"; tree->Draw(draw_string.c_str(), cut_string.c_str()); - + c_tof_diff->Update(); c_tof_diff->Write(); - } + } } } file_diff->Close(); - ////////////////////////////////////////////////////////////////////////////// const int max_N_rec = 3000; - + Int_t nmcp; Int_t mcpdg[max_N_rec]; Int_t N_rec; @@ -151,79 +154,84 @@ void draw_tof_ttbar( const string InFile = "lctuplep.root", const string OutFile Int_t r2mnrel, r2mf[max_N_rec], r2mt[max_N_rec]; Float_t r2mw[max_N_rec]; Float_t m2rw[max_N_rec]; - - tree->SetBranchAddress("nmcp",&nmcp); - tree->SetBranchAddress("mcpdg",&mcpdg); - tree->SetBranchAddress("nrec",&N_rec); - tree->SetBranchAddress("rcmox",rcmox); - tree->SetBranchAddress("rcmoy",rcmoy); - tree->SetBranchAddress("rcmoz",rcmoz); - tree->SetBranchAddress("rccha",rccha); - tree->SetBranchAddress("r2mnrel",&r2mnrel); - tree->SetBranchAddress("r2mf",&r2mf); - tree->SetBranchAddress("r2mt",&r2mt); - tree->SetBranchAddress("r2mw",&r2mw); - + + tree->SetBranchAddress("nmcp", &nmcp); + tree->SetBranchAddress("mcpdg", &mcpdg); + tree->SetBranchAddress("nrec", &N_rec); + tree->SetBranchAddress("rcmox", rcmox); + tree->SetBranchAddress("rcmoy", rcmoy); + tree->SetBranchAddress("rcmoz", rcmoz); + tree->SetBranchAddress("rccha", rccha); + tree->SetBranchAddress("r2mnrel", &r2mnrel); + tree->SetBranchAddress("r2mf", &r2mf); + tree->SetBranchAddress("r2mt", &r2mt); + tree->SetBranchAddress("r2mw", &r2mw); + int N_entries = tree->GetEntries(); - - unique_ptr file_individual_ptypes { new TFile( (OutFileBase + "_individual_types.root").c_str(), "RECREATE" ) }; - - for ( auto & res: resolutions ) { + + unique_ptr file_individual_ptypes{new TFile((OutFileBase + "_individual_types.root").c_str(), "RECREATE")}; + + for (auto& res : resolutions) { Float_t tof_len[max_N_rec]; Float_t tof_ch[max_N_rec]; - tree->SetBranchAddress( ("tof" + res.str() + "len").c_str() ,&tof_len); - tree->SetBranchAddress( ("tof" + res.str() + "ch").c_str() ,&tof_ch ); - - for ( auto & ptype: particle_types ) { - + tree->SetBranchAddress(("tof" + res.str() + "len").c_str(), &tof_len); + tree->SetBranchAddress(("tof" + res.str() + "ch").c_str(), &tof_ch); + + for (auto& ptype : particle_types) { + // TODO delete or make unique - TH2F *h_beta_p = new TH2F( ("ttbar_beta_p_" + ptype.name_s + "_" + res.str()).c_str(), - ("#beta vs p, " + ptype.name_l + ", " + res.w_unit() + "; p; #beta; #" + ptype.name_l).c_str(), - 200, 0, 10., 200, 0.5, 1.05 ); - - // for (int i=0; i< 566; i++) - for (int i=0; iGetEntry(i); - - for (int i_rec=0; i_rec weight) { - final_i_rel = k ; + final_i_rel = k; weight = calweight; } - } + } } - - if ( weight > 0.9 ) { - if (final_i_rel < 0 || final_i_rel >= r2mnrel ) { - cout << "ERROR: MCParticle index out of range: final = " << final_i_rel << ", r2mnrel = " << r2mnrel << endl; + if (weight > 0.9) { + + if (final_i_rel < 0 || final_i_rel >= r2mnrel) { + cout << "ERROR: MCParticle index out of range: final = " << final_i_rel << ", r2mnrel = " << r2mnrel + << endl; continue; } - i_mc = r2mt[final_i_rel]; + i_mc = r2mt[final_i_rel]; - if (i_mc < 0 || i_mc >= nmcp ) { + if (i_mc < 0 || i_mc >= nmcp) { cout << "ERROR: MCParticle index out of range: MCP = " << i_mc << ", nmcp = " << nmcp << endl; - continue; + continue; } IntVec ptype_pdgs = pdg_map[ptype.name_s]; - bool mc_is_ptype = ( find(ptype_pdgs.begin(), ptype_pdgs.end(), abs(mcpdg[i_mc])) != ptype_pdgs.end() ); + bool mc_is_ptype = (find(ptype_pdgs.begin(), ptype_pdgs.end(), abs(mcpdg[i_mc])) != ptype_pdgs.end()); - if ( mc_is_ptype ) { - double p = sqrt(rcmox[i_rec]*rcmox[i_rec]+rcmoy[i_rec]*rcmoy[i_rec]+rcmoz[i_rec]*rcmoz[i_rec]); - double beta = (tof_len[i_rec]/tof_ch[i_rec]/299.8); + if (mc_is_ptype) { + double p = sqrt(rcmox[i_rec] * rcmox[i_rec] + rcmoy[i_rec] * rcmoy[i_rec] + rcmoz[i_rec] * rcmoz[i_rec]); + double beta = (tof_len[i_rec] / tof_ch[i_rec] / 299.8); - if ( beta <1.1 && p <10. && tof_len[i_rec]>1. && tof_ch[i_rec]>0.1 && abs(rccha[i_rec])>0.01 && abs(rcmoz[i_rec])/sqrt(rcmox[i_rec]*rcmox[i_rec]+rcmoy[i_rec]*rcmoy[i_rec]+rcmoz[i_rec]*rcmoz[i_rec]) > 0.79257283 ) { - h_beta_p->Fill(p, beta); - } + if (beta < 1.1 && p < 10. && tof_len[i_rec] > 1. && tof_ch[i_rec] > 0.1 && abs(rccha[i_rec]) > 0.01 && + abs(rcmoz[i_rec]) / sqrt(rcmox[i_rec] * rcmox[i_rec] + rcmoy[i_rec] * rcmoy[i_rec] + + rcmoz[i_rec] * rcmoz[i_rec]) > + 0.79257283) { + h_beta_p->Fill(p, beta); + } } } } @@ -233,6 +241,6 @@ void draw_tof_ttbar( const string InFile = "lctuplep.root", const string OutFile } } file_individual_ptypes->Close(); - + file->Close(); } diff --git a/TimeOfFlight/macros/plotting/tof_helpers.cpp b/TimeOfFlight/macros/plotting/tof_helpers.cpp index 85768e1..685d2db 100644 --- a/TimeOfFlight/macros/plotting/tof_helpers.cpp +++ b/TimeOfFlight/macros/plotting/tof_helpers.cpp @@ -1,68 +1,67 @@ struct ParticleType { - int pdg_id {}; - string name_s {}; - string name_l {}; - float mass {}; // in GeV - Color_t colour_index {}; - - ParticleType( int _pdg_id=0, string _name_s="", string _name_l="", float _mass=0, Color_t _colour_index=0 ) : - pdg_id(_pdg_id), name_s(_name_s), name_l(_name_l), mass(_mass), colour_index(_colour_index) {}; - + int pdg_id{}; + string name_s{}; + string name_l{}; + float mass{}; // in GeV + Color_t colour_index{}; + + ParticleType(int _pdg_id = 0, string _name_s = "", string _name_l = "", float _mass = 0, Color_t _colour_index = 0) + : pdg_id(_pdg_id), name_s(_name_s), name_l(_name_l), mass(_mass), colour_index(_colour_index) {}; + // Copy constructor - ParticleType(const ParticleType &_ptype) : - pdg_id(_ptype.pdg_id), name_s(_ptype.name_s), name_l(_ptype.name_l), mass(_ptype.mass), colour_index(_ptype.colour_index) {}; - - bool operator== (const ParticleType &ptype){ + ParticleType(const ParticleType& _ptype) + : pdg_id(_ptype.pdg_id), name_s(_ptype.name_s), name_l(_ptype.name_l), mass(_ptype.mass), + colour_index(_ptype.colour_index) {}; + + bool operator==(const ParticleType& ptype) { return pdg_id == ptype.pdg_id && name_s == ptype.name_s && name_l == ptype.name_l && mass == ptype.mass; } }; struct Resolution { - float value {}; - string unit {}; - Color_t colour_index {}; - - Resolution( float _value=0, Color_t _colour_index=0 , string _unit="ps") : - value(_value), unit(_unit), colour_index(_colour_index) {}; - - bool operator== (const Resolution &res){ - return value == res.value && unit == res.unit; - } - + float value{}; + string unit{}; + Color_t colour_index{}; + + Resolution(float _value = 0, Color_t _colour_index = 0, string _unit = "ps") + : value(_value), unit(_unit), colour_index(_colour_index) {}; + + bool operator==(const Resolution& res) { return value == res.value && unit == res.unit; } + string str() const { string value_str = to_string(value); - if ( roundf(value) == value ) { value_str = to_string(int(value)); } + if (roundf(value) == value) { + value_str = to_string(int(value)); + } return value_str; } - - string w_unit() const { - return this->str() + unit; - } + + string w_unit() const { return this->str() + unit; } }; struct Method { - string name_s {}; - string name_l {}; - Color_t colour_index {}; - - Method( string _name_s="", string _name_l="", Color_t _colour_index=0 ) : - name_s(_name_s), name_l(_name_l), colour_index(_colour_index) {}; + string name_s{}; + string name_l{}; + Color_t colour_index{}; + + Method(string _name_s = "", string _name_l = "", Color_t _colour_index = 0) + : name_s(_name_s), name_l(_name_l), colour_index(_colour_index) {}; }; struct Slice { - double p {}; - TH1D* histo {}; - double mean {}; - double sigma {}; - double mean_err {}; - double sigma_err {}; - bool fit_successful {false}; - - void extract_fit_parameters(string fit_name="gaus") { + double p{}; + TH1D* histo{}; + double mean{}; + double sigma{}; + double mean_err{}; + double sigma_err{}; + bool fit_successful{false}; + + void extract_fit_parameters(string fit_name = "gaus") { auto fit_result = this->histo->GetFunction(fit_name.c_str()); - this->mean = fit_result->GetParameter(1); - this->sigma = fit_result->GetParameter(2); - this->mean_err = fit_result->GetParError(1); + this->mean = fit_result->GetParameter(1); + this->sigma = fit_result->GetParameter(2); + this->mean_err = fit_result->GetParError(1); this->sigma_err = fit_result->GetParError(2); } }; @@ -70,111 +69,113 @@ struct Slice { struct Histo { ParticleType ptype; Resolution res; - TH2F* histo {}; - vector slices {}; - - Histo( ParticleType &_ptype, Resolution &_res ){ - ptype = _ptype; - res = _res; + TH2F* histo{}; + vector slices{}; + + Histo(ParticleType& _ptype, Resolution& _res) { + ptype = _ptype; + res = _res; } - - ~Histo(){ // TODO Had to remove this to avoid seg fault at end of ttbar script. Don't know how to fix. + + ~Histo() { // TODO Had to remove this to avoid seg fault at end of ttbar script. Don't know how to fix. // delete histo; } - - void perform_slice_fit(Slice &slice, double &beta_low, double &beta_up) { - if (slice.histo->GetEntries() < 1) { return; } - - double delta_beta = (beta_up-beta_low)/2.0; - - double fit_low_edge = max( 0.99 * (beta_low - 3.0*delta_beta), 0.0 ); - double fit_up_edge = min( 1.01 * (beta_up + 3.0*delta_beta), 1.1 ); - - ((TF1*)gROOT->GetFunction("gaus"))->SetParLimits(0, 0, 2.0); // Gaussian amplitude - ((TF1*)gROOT->GetFunction("gaus"))->SetParLimits(1, 0, 1.5); // Mean - ((TF1*)gROOT->GetFunction("gaus"))->SetParLimits(2, delta_beta/2.0, 1.0); // Sigma - + + void perform_slice_fit(Slice& slice, double& beta_low, double& beta_up) { + if (slice.histo->GetEntries() < 1) { + return; + } + + double delta_beta = (beta_up - beta_low) / 2.0; + + double fit_low_edge = max(0.99 * (beta_low - 3.0 * delta_beta), 0.0); + double fit_up_edge = min(1.01 * (beta_up + 3.0 * delta_beta), 1.1); + + ((TF1*)gROOT->GetFunction("gaus"))->SetParLimits(0, 0, 2.0); // Gaussian amplitude + ((TF1*)gROOT->GetFunction("gaus"))->SetParLimits(1, 0, 1.5); // Mean + ((TF1*)gROOT->GetFunction("gaus"))->SetParLimits(2, delta_beta / 2.0, 1.0); // Sigma + int fit_success = 1; ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit2"); - fit_success = slice.histo->Fit("gaus","QI","",fit_low_edge,fit_up_edge); - if ( fit_success == 0 ) { // Confusingly meaning fit was successful + fit_success = slice.histo->Fit("gaus", "QI", "", fit_low_edge, fit_up_edge); + if (fit_success == 0) { // Confusingly meaning fit was successful slice.extract_fit_parameters(); - - fit_low_edge = min( slice.mean-(2.5*slice.sigma), 0.99 ); - fit_up_edge = max( slice.mean+(2.5*slice.sigma), 1.1 ); - + + fit_low_edge = min(slice.mean - (2.5 * slice.sigma), 0.99); + fit_up_edge = max(slice.mean + (2.5 * slice.sigma), 1.1); + ROOT::Math::MinimizerOptions::SetDefaultStrategy(2); // More accurate error calculation - fit_success = slice.histo->Fit("gaus","QI","",fit_low_edge,fit_up_edge); - if ( fit_success == 0 ) { // Confusingly meaning fit was successful + fit_success = slice.histo->Fit("gaus", "QI", "", fit_low_edge, fit_up_edge); + if (fit_success == 0) { // Confusingly meaning fit was successful slice.fit_successful = true; slice.extract_fit_parameters(); } ROOT::Math::MinimizerOptions::SetDefaultStrategy(1); // Re-set to default } - } - - void slice_histo(int bin_step_size, bool do_fit=true){ + + void slice_histo(int bin_step_size, bool do_fit = true) { if (nullptr == histo) { cout << "Can't slice empty histo!" << endl; return; } - - for (int slice_bin=1; slice_binGetNbinsX()+1; slice_bin+=bin_step_size){ + + for (int slice_bin = 1; slice_bin < histo->GetNbinsX() + 1; slice_bin += bin_step_size) { double p = histo->GetXaxis()->GetBinCenter(slice_bin); double p_low = histo->GetXaxis()->GetBinLowEdge(slice_bin); - double p_up = histo->GetXaxis()->GetBinUpEdge(slice_bin); - - double beta_low = p_low/sqrt(ptype.mass*ptype.mass + p_low*p_low); - double beta_up = p_up /sqrt(ptype.mass*ptype.mass + p_up *p_up); - + double p_up = histo->GetXaxis()->GetBinUpEdge(slice_bin); + + double beta_low = p_low / sqrt(ptype.mass * ptype.mass + p_low * p_low); + double beta_up = p_up / sqrt(ptype.mass * ptype.mass + p_up * p_up); + Slice slice; slice.p = p; - TString slice_name = TString( "beta_CH_" + ptype.name_s + "_bin" + to_string(slice_bin) + "_p" + to_string(p) ); - slice.histo = histo->ProjectionY(slice_name,slice_bin,slice_bin,"e"); - slice.histo->SetTitle( TString( "#beta_{CH} sliced at p=" + to_string(p) + "GeV, bin " + to_string(slice_bin) + ", " + ptype.name_l ) ); - slice.histo->Scale(1.0/slice.histo->Integral()); - + TString slice_name = TString("beta_CH_" + ptype.name_s + "_bin" + to_string(slice_bin) + "_p" + to_string(p)); + slice.histo = histo->ProjectionY(slice_name, slice_bin, slice_bin, "e"); + slice.histo->SetTitle( + TString("#beta_{CH} sliced at p=" + to_string(p) + "GeV, bin " + to_string(slice_bin) + ", " + ptype.name_l)); + slice.histo->Scale(1.0 / slice.histo->Integral()); + if (do_fit) { this->perform_slice_fit(slice, beta_low, beta_up); } - + slices.push_back(slice); } } - - }; typedef vector HistoVec; typedef vector> HistoPtrVec; struct HistoMap { - HistoPtrVec histos {}; - + HistoPtrVec histos{}; + HistoMap() {}; - void addHisto( ParticleType &_ptype, Resolution &_res ) { - histos.push_back( make_shared(_ptype, _res) ); - } - - HistoPtrVec getHistosToRes(Resolution &res) const{ + void addHisto(ParticleType& _ptype, Resolution& _res) { histos.push_back(make_shared(_ptype, _res)); } + + HistoPtrVec getHistosToRes(Resolution& res) const { HistoPtrVec histos_to_res{}; - for( auto & histo: histos ) { - if ( histo->res == res ) { histos_to_res.push_back(histo); } + for (auto& histo : histos) { + if (histo->res == res) { + histos_to_res.push_back(histo); + } } return histos_to_res; } - - HistoPtrVec getHistosToPType(ParticleType &ptype) const{ + + HistoPtrVec getHistosToPType(ParticleType& ptype) const { HistoPtrVec histos_to_ptype{}; - for( auto & histo: histos ) { - if ( histo->ptype == ptype ) { histos_to_ptype.push_back(histo); } + for (auto& histo : histos) { + if (histo->ptype == ptype) { + histos_to_ptype.push_back(histo); + } } return histos_to_ptype; } - - shared_ptr getHisto(Resolution &res, ParticleType &ptype) { - for ( auto &histo: histos) { + + shared_ptr getHisto(Resolution& res, ParticleType& ptype) { + for (auto& histo : histos) { if (histo->res == res && histo->ptype == ptype) { return histo; } @@ -183,8 +184,8 @@ struct HistoMap { } }; -typedef vector ParticleVec; -typedef vector ResVec; -typedef vector MethodVec; +typedef vector ParticleVec; +typedef vector ResVec; +typedef vector MethodVec; typedef vector FloatVec; -typedef vector IntVec; \ No newline at end of file +typedef vector IntVec; \ No newline at end of file diff --git a/TimeOfFlight/macros/reading_config/read_config.cpp b/TimeOfFlight/macros/reading_config/read_config.cpp index c7fd3ce..d715907 100644 --- a/TimeOfFlight/macros/reading_config/read_config.cpp +++ b/TimeOfFlight/macros/reading_config/read_config.cpp @@ -1,106 +1,108 @@ struct Section { string key{}; - map variables{}; - + map variables{}; + void clear() { key = ""; variables = {}; } - - string operator [](string variable) const {return variables.at(variable);} - string & operator [](string variable) {return variables[variable];} + + string operator[](string variable) const { return variables.at(variable); } + string& operator[](string variable) { return variables[variable]; } }; -class ConfigReader{ - ofstream config_file {}; - string file_name {}; - vector
sections {}; - - int find_key_index (string key) const { +class ConfigReader { + ofstream config_file{}; + string file_name{}; + vector
sections{}; + + int find_key_index(string key) const { int index = 9999; - for ( int i=0; iread_file(); + } + +public: + ConfigReader(string _file_name) : file_name(_file_name) { this->read_file(); } + + vector get_keys() { + vector keys{}; + for (auto& section : this->sections) { + keys.push_back(section.key); } - - vector get_keys() { - vector keys {}; - for (auto & section: this->sections) { keys.push_back(section.key); } - return keys; + return keys; + } + + Section operator[](string key) const { return sections[find_key_index(key)]; } + Section& operator[](string key) { return sections[find_key_index(key)]; } + +private: + string find_key(string line) { + string key = ""; + if (line.find("[") != string::npos) { + auto first = line.find("[") + 1; + auto last = line.find("]"); + key = line.substr(first, last - first); } - - Section operator [](string key) const {return sections[find_key_index(key)];} - Section & operator [](string key) {return sections[find_key_index(key)];} - - private: - - string find_key(string line){ - string key = ""; - if (line.find("[") != string::npos) { - auto first = line.find("[")+1; - auto last = line.find("]"); - key = line.substr(first,last-first); - } - return key; + return key; + } + + pair find_variable(string line) { + pair variable_value{}; + if (line.find("=") != string::npos) { + string line_no_spaces = line; + line_no_spaces.erase(remove_if(line_no_spaces.begin(), line_no_spaces.end(), ::isspace), line_no_spaces.end()); + auto delimiter = line_no_spaces.find("="); + string variable = line_no_spaces.substr(0, delimiter); + string value = line_no_spaces.substr(delimiter + 1); + variable_value = make_pair(variable, value); } - - pair find_variable(string line){ - pair variable_value {}; - if (line.find("=") != string::npos) { - string line_no_spaces = line; - line_no_spaces.erase(remove_if(line_no_spaces.begin(), line_no_spaces.end(), ::isspace), line_no_spaces.end()); - auto delimiter = line_no_spaces.find("="); - string variable = line_no_spaces.substr(0, delimiter); - string value = line_no_spaces.substr(delimiter+1); - variable_value = make_pair(variable, value); - } - return variable_value; - } - - void read_file(){ - ifstream myfile(file_name.c_str()); - string line; - if (myfile.is_open()) { - Section section {}; - while ( getline (myfile,line) ) { - string check_for_key = find_key(line); - if (check_for_key != "") { - if ( section.key != "" ) { sections.push_back(section); } // Save finished section - section.clear(); - section.key = check_for_key; - continue; - } - auto check_for_variable = find_variable(line); - if (check_for_variable.first != "") { - section.variables[check_for_variable.first] = check_for_variable.second; - } + return variable_value; + } + + void read_file() { + ifstream myfile(file_name.c_str()); + string line; + if (myfile.is_open()) { + Section section{}; + while (getline(myfile, line)) { + string check_for_key = find_key(line); + if (check_for_key != "") { + if (section.key != "") { + sections.push_back(section); + } // Save finished section + section.clear(); + section.key = check_for_key; + continue; + } + auto check_for_variable = find_variable(line); + if (check_for_variable.first != "") { + section.variables[check_for_variable.first] = check_for_variable.second; } - if ( section.key != "" ) { sections.push_back(section); } // Save last section - myfile.close(); - } else { - cout << "ERROR: Unable to open config file!" << endl; } + if (section.key != "") { + sections.push_back(section); + } // Save last section + myfile.close(); + } else { + cout << "ERROR: Unable to open config file!" << endl; } - + } }; -// -// +// +// // void read_config() { // string conf_file="../../config/ParticleTypes.cnf"; // ConfigReader reader(conf_file); // auto keys = reader.get_keys(); -// for (auto & key: keys) { +// for (auto & key: keys) { // cout << key << endl; // } // cout << reader["Proton"]["mass"] << endl; -// +// // } \ No newline at end of file diff --git a/WWZZSeparation/processor/include/EventInformation.h b/WWZZSeparation/processor/include/EventInformation.h index 203535e..a8660e9 100644 --- a/WWZZSeparation/processor/include/EventInformation.h +++ b/WWZZSeparation/processor/include/EventInformation.h @@ -1,70 +1,68 @@ #ifndef EVENT_INFORMATION_H -#define EVENT_INFORMATION_H 1 +#define EVENT_INFORMATION_H 1 #include "TLorentzVector.h" #include - struct Observables { /* Class that holds all information, that can be measured by the detector - and I make a cut on */ + and I make a cut on */ - float pair1_mass {}; - float pair2_mass {}; + float pair1_mass{}; + float pair2_mass{}; - float miss_mass {}; // Also called: recoil mass + float miss_mass{}; // Also called: recoil mass - float sum_E_q {}; // should be called sum_E_vis ... - float E_T_vis {}; - float p_T_vis {}; - float E_10cone_EmaxTrack {}; + float sum_E_q{}; // should be called sum_E_vis ... + float E_T_vis{}; + float p_T_vis{}; + float E_10cone_EmaxTrack{}; - float cosTheta_miss {}; - float cosTheta_EmaxTrack {}; + float cosTheta_miss{}; + float cosTheta_EmaxTrack{}; // Distance parameter when clustering jets from 4 to 3 jets - float y_34 {}; + float y_34{}; - // Each of those is the minimum over all 4 jets + // Each of those is the minimum over all 4 jets // -> Cut on them means cut on all jets - float min_Ejet {}; - int min_num_particles_jet {}; - int min_num_chargedparticles_jet {}; + float min_Ejet{}; + int min_num_particles_jet{}; + int min_num_chargedparticles_jet{}; - int num_isolated_leptons {}; + int num_isolated_leptons{}; - TLorentzVector pair1_tlv {}; - TLorentzVector pair2_tlv {}; - TLorentzVector visible_tlv {}; - TLorentzVector miss_tlv {}; + TLorentzVector pair1_tlv{}; + TLorentzVector pair2_tlv{}; + TLorentzVector visible_tlv{}; + TLorentzVector miss_tlv{}; void init() { - pair1_tlv = TLorentzVector(0.0, 0.0, 0.0, 0.0); - pair2_tlv = TLorentzVector(0.0, 0.0, 0.0, 0.0); + pair1_tlv = TLorentzVector(0.0, 0.0, 0.0, 0.0); + pair2_tlv = TLorentzVector(0.0, 0.0, 0.0, 0.0); visible_tlv = TLorentzVector(0.0, 0.0, 0.0, 0.0); - miss_tlv = TLorentzVector(0.0, 0.0, 0.0, 0.0); + miss_tlv = TLorentzVector(0.0, 0.0, 0.0, 0.0); - pair1_mass = -10; - pair2_mass = -10; + pair1_mass = -10; + pair2_mass = -10; - miss_mass = -10; + miss_mass = -10; - sum_E_q = -10; - E_T_vis = -10; - p_T_vis = -10; - E_10cone_EmaxTrack = -10; + sum_E_q = -10; + E_T_vis = -10; + p_T_vis = -10; + E_10cone_EmaxTrack = -10; - cosTheta_miss = -2; - cosTheta_EmaxTrack = -2; + cosTheta_miss = -2; + cosTheta_EmaxTrack = -2; - y_34 = -1; + y_34 = -1; - min_Ejet = -10; - min_num_particles_jet = -1; - min_num_chargedparticles_jet = -1; + min_Ejet = -10; + min_num_particles_jet = -1; + min_num_chargedparticles_jet = -1; num_isolated_leptons = -1; - } void processTLVs() { @@ -72,52 +70,48 @@ struct Observables { pair2_mass = pair2_tlv.M(); visible_tlv = pair1_tlv + pair2_tlv; - sum_E_q = visible_tlv.E(); - E_T_vis = visible_tlv.Et(); - p_T_vis = visible_tlv.Pt(); - - TLorentzVector initial = TLorentzVector(1000*sin(0.014/2.0),0,0,1000); - miss_tlv = initial - pair1_tlv - pair2_tlv; - miss_mass = miss_tlv.M(); - cosTheta_miss = miss_tlv.CosTheta(); + sum_E_q = visible_tlv.E(); + E_T_vis = visible_tlv.Et(); + p_T_vis = visible_tlv.Pt(); + + TLorentzVector initial = TLorentzVector(1000 * sin(0.014 / 2.0), 0, 0, 1000); + miss_tlv = initial - pair1_tlv - pair2_tlv; + miss_mass = miss_tlv.M(); + cosTheta_miss = miss_tlv.CosTheta(); } - }; - struct ProcessInfo { /* Class that stores metadata about sample */ - float cross_section {}; + float cross_section{}; // Store e-/e+ polarisations: +1 = right-handed, -1 = left-handed - int e_pol {}; - int p_pol {}; + int e_pol{}; + int p_pol{}; void init() { cross_section = -10; e_pol = 0; p_pol = 0; } - }; - struct EventInfo { - /* General class that holds all information about the event + /* General class that holds all information about the event on all the levels of the generation */ - int evtN {}; - ProcessInfo process {}; + int evtN{}; + ProcessInfo process{}; - // True event type determined from MC-info, 1=ZZ, 2=WW, 0=other - int true_event_type {}; + // True event type determined from MC-info, 1=ZZ, 2=WW, 0=other + int true_event_type{}; // Storage for everything that can be actually observed - Observables observ {}; + Observables observ{}; // Flag for whether event passed preselection - int passed_preselection {}; + int passed_preselection{}; void init() { process.init(); @@ -126,10 +120,8 @@ struct EventInfo { observ.init(); - passed_preselection = -1; + passed_preselection = -1; } }; #endif - - diff --git a/WWZZSeparation/processor/include/StandardIncludes.h b/WWZZSeparation/processor/include/StandardIncludes.h index 1769781..f73db5f 100644 --- a/WWZZSeparation/processor/include/StandardIncludes.h +++ b/WWZZSeparation/processor/include/StandardIncludes.h @@ -1,27 +1,26 @@ -#include "marlin/Processor.h" #include "lcio.h" -#include +#include "marlin/Processor.h" #include +#include #include +#include // for std::find +#include // for std::begin, std::end #include #include -#include // for std::find -#include // for std::begin, std::end -//ROOT +// ROOT #include "TFile.h" -#include "TTree.h" #include "TLorentzVector.h" +#include "TTree.h" -//LCIO +// LCIO #include -#include +#include #include //----- include for verbosity dependend logging --------- #include "marlin/VerbosityLevels.h" -using namespace lcio ; -using namespace marlin ; - +using namespace lcio; +using namespace marlin; diff --git a/WWZZSeparation/processor/include/VpairFinder.h b/WWZZSeparation/processor/include/VpairFinder.h index 2a0066d..d2d6f64 100644 --- a/WWZZSeparation/processor/include/VpairFinder.h +++ b/WWZZSeparation/processor/include/VpairFinder.h @@ -3,11 +3,9 @@ #include "WWZZProcessor.h" - -template -void WWZZProcessor::fillVPairInformation( - std::vector V1, std::vector V2, - Observables &observ ) { +template +void WWZZProcessor::fillVPairInformation(std::vector V1, std::vector V2, + Observables& observ) { /* Function to centrally fill V pair information once the V's have been identified. Separate from VpairFinder so that otherwise found pairs can @@ -16,11 +14,11 @@ void WWZZProcessor::fillVPairInformation( TLorentzVector V1_tlv = TLorentzVector(0, 0, 0, 0); TLorentzVector V2_tlv = TLorentzVector(0, 0, 0, 0); - for(unsigned int i=0;igetMomentum(), V1[i]->getEnergy() ); + for (unsigned int i = 0; i < V1.size(); i++) { + V1_tlv += TLorentzVector(V1[i]->getMomentum(), V1[i]->getEnergy()); } - for(unsigned int i=0;igetMomentum(), V2[i]->getEnergy() ); + for (unsigned int i = 0; i < V2.size(); i++) { + V2_tlv += TLorentzVector(V2[i]->getMomentum(), V2[i]->getEnergy()); } observ.pair1_tlv = V1_tlv; @@ -28,67 +26,64 @@ void WWZZProcessor::fillVPairInformation( observ.processTLVs(); } - -template -void WWZZProcessor::getAllVVTo4ParticleCombinations ( - std::vector particles, - std::vector>> &VV_candidates ) { +template +void WWZZProcessor::getAllVVTo4ParticleCombinations( + std::vector particles, std::vector>>& VV_candidates) { /* Take a collection of particles and get a vector with all possible - (particle particle) (particle particle) pair combinations without any + (particle particle) (particle particle) pair combinations without any doubling of a pair */ int n_particles = particles.size(); - // This loop combination should give you all possible (particle particle) (particle particle) + // This loop combination should give you all possible (particle particle) (particle particle) // pair combinations exactly once // If you don't believe me test it on paper - for(int i=0;i V1_candidate {pair1_p1, pair1_p2}; - std::vector V2_candidate {pair2_p1, pair2_p2}; - std::vector> VV_candidate {V1_candidate, V2_candidate}; - - VV_candidates.push_back(VV_candidate); - } + for (int i = 0; i < n_particles - 3; i++) { + for (int j = i + 1; j < n_particles; j++) { + for (int k = i + 1; k < n_particles - 1; k++) { + for (int l = k + 1; l < n_particles; l++) { + // Skip combinations that take same quark twice. + // Duplicate within pair already excluded by starting second loop with i+1 and fourth with k+1 + if (j == k || j == l) { + continue; + } + + LCIOParticleType* pair1_p1 = particles[i]; + LCIOParticleType* pair1_p2 = particles[j]; + LCIOParticleType* pair2_p1 = particles[k]; + LCIOParticleType* pair2_p2 = particles[l]; + + std::vector V1_candidate{pair1_p1, pair1_p2}; + std::vector V2_candidate{pair2_p1, pair2_p2}; + std::vector> VV_candidate{V1_candidate, V2_candidate}; + + VV_candidates.push_back(VV_candidate); + } + } } } - } - } +template +void WWZZProcessor::getVVCandidatesMasses(std::vector>> VV_candidates, + std::vector>& candidates_masses) { -template -void WWZZProcessor::getVVCandidatesMasses( - std::vector>> VV_candidates, - std::vector> &candidates_masses ) { - - /* Function fills the vector with the mass of each of the 2 Vs - does that for each VV combination - -> VectorOfCombinations> + /* Function fills the vector with the mass of each of the 2 Vs + does that for each VV combination + -> VectorOfCombinations> */ - //for: every VV combinations - for (unsigned int i=0; i VV_candidate_masses; - //for: every V - for (unsigned int j=0; jgetMomentum(), VV_candidates[i][j][k]->getEnergy() ); + // for: every particle in the V + for (unsigned int k = 0; k < VV_candidates[i][j].size(); k++) { + V_tlv += TLorentzVector(VV_candidates[i][j][k]->getMomentum(), VV_candidates[i][j][k]->getEnergy()); } // -> Got full TLV of the V, now get its mass VV_candidate_masses.push_back(V_tlv.M()); @@ -97,10 +92,9 @@ void WWZZProcessor::getVVCandidatesMasses( } } - -template -int WWZZProcessor::findIndexBestPairInVVCandidates( - std::vector>> VV_candidates ) { +template +int WWZZProcessor::findIndexBestPairInVVCandidates( + std::vector>> VV_candidates) { /* Function that finds index of VV combination that minimizes the pairing requirement (e.g. |mV1 -mV2|, ...) @@ -108,44 +102,41 @@ int WWZZProcessor::findIndexBestPairInVVCandidates( // For each candidate collect masses of Vs std::vector> candidates_masses; - getVVCandidatesMasses( VV_candidates, candidates_masses ); + getVVCandidatesMasses(VV_candidates, candidates_masses); // Then for each pair get mass difference and find index of best pair std::vector minimize_me; streamlog_out(DEBUG5) << "\nMinimizing mass difference:" << std::endl; - for (unsigned int i=0; i -void WWZZProcessor::findVpair(std::vector particles, Observables &observ) { +template +void WWZZProcessor::findVpair(std::vector particles, Observables& observ) { /* In 4 jet topology find the (jet jet)=V (jet jet)=V combination which minimizes some required function, here |mV1-mV2|*/ // Find all possible (jet jet) (jet jet) combinations std::vector>> VV_candidates; - getAllVVTo4ParticleCombinations( particles, VV_candidates ); + getAllVVTo4ParticleCombinations(particles, VV_candidates); // Find index of pair that's most "VV-like" - int best_pair_index = findIndexBestPairInVVCandidates( VV_candidates ); + int best_pair_index = findIndexBestPairInVVCandidates(VV_candidates); // Extract information about that pair std::vector V1 = VV_candidates[best_pair_index][0]; std::vector V2 = VV_candidates[best_pair_index][1]; - fillVPairInformation( V1, V2, observ ); - - streamlog_out(DEBUG5) << "\nResulted best mass difference:" - << fabs(observ.pair1_mass - observ.pair2_mass) - << std::endl; + fillVPairInformation(V1, V2, observ); + streamlog_out(DEBUG5) << "\nResulted best mass difference:" << fabs(observ.pair1_mass - observ.pair2_mass) + << std::endl; } #endif diff --git a/WWZZSeparation/processor/include/WWZZProcessor.h b/WWZZSeparation/processor/include/WWZZProcessor.h index 92ab2e1..ec7f20b 100644 --- a/WWZZSeparation/processor/include/WWZZProcessor.h +++ b/WWZZSeparation/processor/include/WWZZProcessor.h @@ -5,118 +5,106 @@ #include "StandardIncludes.h" class WWZZProcessor : public Processor { - - public: - virtual Processor* newProcessor() { return new WWZZProcessor ; } +public: + virtual Processor* newProcessor() { return new WWZZProcessor; } + WWZZProcessor(); + WWZZProcessor(const WWZZProcessor&) = delete; + WWZZProcessor& operator=(const WWZZProcessor&) = delete; - WWZZProcessor() ; - WWZZProcessor(const WWZZProcessor &) = delete; - WWZZProcessor& operator=(const WWZZProcessor &) = delete ; + /** Called at the begin of the job before anything is read. + * Use to initialize the processor, e.g. book histograms. + */ + virtual void init(); - /** Called at the begin of the job before anything is read. - * Use to initialize the processor, e.g. book histograms. - */ - virtual void init() ; + /** Called for every run. + */ + virtual void processRunHeader(LCRunHeader* run); - /** Called for every run. - */ - virtual void processRunHeader( LCRunHeader* run ) ; + /** Called for every event - the working horse. + */ + virtual void processEvent(LCEvent* evt); - /** Called for every event - the working horse. - */ - virtual void processEvent( LCEvent * evt ) ; + /** Subroutines + */ + virtual void analyseEvent(LCCollection* colMC, LCCollection* colPFOs, LCCollection* colJets, LCCollection* colIsoLeps, + EventInfo& info); - /** Subroutines - */ - virtual void analyseEvent( - LCCollection* colMC, LCCollection* colPFOs, LCCollection* colJets, - LCCollection* colIsoLeps, EventInfo &info); + std::vector checkMCFinalState(LCCollection* AllMC); + std::vector checkPOFinalState(LCCollection* AllPOs); - std::vector checkMCFinalState(LCCollection* AllMC); - std::vector checkPOFinalState(LCCollection* AllPOs) ; + // Using Generator level information + virtual std::vector findGenLevelNeutrinos(std::vector MCparticles); + virtual std::vector findGenLevelQuarks(std::vector MCparticles); - // Using Generator level information - virtual std::vector findGenLevelNeutrinos(std::vector MCparticles); - virtual std::vector findGenLevelQuarks(std::vector MCparticles); + // True event type finding + virtual void findAllowedVVCandidates(std::vector>> all_VV_candidates, + std::vector>>& possible_VV_candidates, + std::string VV_name); - // True event type finding - virtual void findAllowedVVCandidates( - std::vector>> all_VV_candidates, - std::vector>> &possible_VV_candidates, - std::string VV_name ); + virtual void findTrueEventType(std::vector MCparticles, EventInfo& info); - virtual void findTrueEventType(std::vector MCparticles, EventInfo &info); + // V pair finding + template + void fillVPairInformation(std::vector V1, std::vector V2, Observables& observ); - // V pair finding - template void fillVPairInformation( - std::vector V1, std::vector V2, - Observables &observ); + template + void getAllVVTo4ParticleCombinations(std::vector particles, + std::vector>>& VV_candidates); - template void getAllVVTo4ParticleCombinations ( - std::vector particles, - std::vector>> &VV_candidates ); + template + void getVVCandidatesMasses(std::vector>> VV_candidates, + std::vector>& candidates_masses); - template void getVVCandidatesMasses( - std::vector>> VV_candidates, - std::vector> &candidates_masses ) ; + template + int findIndexBestPairInVVCandidates(std::vector>> VV_candidates); - template int findIndexBestPairInVVCandidates( - std::vector>> VV_candidates ); + template + void findVpair(std::vector jets, Observables& observ); - template void findVpair( - std::vector jets, Observables &observ); + // Cut parameter calculation + virtual void calculateCutParameters(std::vector PFOs, + std::vector jets, Observables& observ); - // Cut parameter calculation - virtual void calculateCutParameters( - std::vector PFOs, std::vector jets, - Observables &observ); + // Event selection + virtual bool passesSelectionCriteria(Observables& observ); + virtual void eventSelection(EventInfo& info); - // Event selection - virtual bool passesSelectionCriteria( Observables &observ ); - virtual void eventSelection( EventInfo &info ); + virtual void check(LCEvent* evt); - virtual void check( LCEvent * evt ) ; - - /** Called after data processing for clean up. - */ - virtual void end() ; - - protected: + /** Called after data processing for clean up. + */ + virtual void end(); - /** Input collection name. - */ - std::string _colAllPFOs{}; - std::string _colFastJets{}; - std::string _colIsoleps{}; - std::string _colMC{}; +protected: + /** Input collection name. + */ + std::string _colAllPFOs{}; + std::string _colFastJets{}; + std::string _colIsoleps{}; + std::string _colMC{}; - /** Parameters during Marlin analysis - */ + /** Parameters during Marlin analysis + */ - int _nRun {}; - int _nEvt {}; + int _nRun{}; + int _nEvt{}; - EventInfo _info{}; + EventInfo _info{}; + /** Sample cross section + */ + float _cross_section{}; - /** Sample cross section - */ - float _cross_section {}; - - /** Output File specifics - */ - TFile* _otfile{}; - TTree* _tree{}; - - std::string _rootfilename{}; -} ; + /** Output File specifics + */ + TFile* _otfile{}; + TTree* _tree{}; + std::string _rootfilename{}; +}; // This needs to be at end of this header, otherwise template functionality doesn't work -#include "VpairFinder.h" +#include "VpairFinder.h" #endif - - - diff --git a/dEdX/include/ILDStyle_Standalone.h b/dEdX/include/ILDStyle_Standalone.h index a7829e2..76bf8e9 100644 --- a/dEdX/include/ILDStyle_Standalone.h +++ b/dEdX/include/ILDStyle_Standalone.h @@ -1,93 +1,89 @@ -//#include "TH1.h" +// #include "TH1.h" #include "TROOT.h" #include "TStyle.h" -//#include "TLegend.h" - +// #include "TLegend.h" void ILDStyle(TStyle* ildStyle) { -//cout << "Loading ILD rootlogon for some stylish root standards." << endl; - -//ild TStyle - - -//set the background color to white -ildStyle->SetFillColor(10); -ildStyle->SetFrameFillColor(10); -ildStyle->SetCanvasColor(10); -ildStyle->SetPadColor(10); -ildStyle->SetTitleFillColor(0); -ildStyle->SetStatColor(10); - -//dont put a colored frame around the plots -ildStyle->SetFrameBorderMode(0); -ildStyle->SetCanvasBorderMode(0); -ildStyle->SetPadBorderMode(0); -ildStyle->SetLegendBorderSize(0); - -//use the primary color palette -ildStyle->SetPalette(1,0); - -//set the default line color for a histogram to be black -ildStyle->SetHistLineColor(kBlack); - -//set the default line color for a fit function to be red -ildStyle->SetFuncColor(kRed); - -//make the axis labels black -ildStyle->SetLabelColor(kBlack,"xyz"); - -//set the default title color to be black -ildStyle->SetTitleColor(kBlack); - -//set the margins -ildStyle->SetPadBottomMargin(0.18); -ildStyle->SetPadTopMargin(0.08); -ildStyle->SetPadRightMargin(0.08); -ildStyle->SetPadLeftMargin(0.17); - -//set axis label and title text sizes -ildStyle->SetLabelFont(42,"xyz"); -ildStyle->SetLabelSize(0.06,"xyz"); -ildStyle->SetLabelOffset(0.015,"xyz"); -ildStyle->SetTitleFont(42,"xyz"); -ildStyle->SetTitleSize(0.07,"xyz"); -ildStyle->SetTitleOffset(1.1,"yz"); -ildStyle->SetTitleOffset(1.0,"x"); -ildStyle->SetStatFont(42); -ildStyle->SetStatFontSize(0.07); -ildStyle->SetTitleBorderSize(0); -ildStyle->SetStatBorderSize(0); -ildStyle->SetTextFont(42); - -//set line widths -ildStyle->SetFrameLineWidth(2); -ildStyle->SetFuncWidth(2); -ildStyle->SetHistLineWidth(2); - -//set the number of divisions to show -ildStyle->SetNdivisions(506, "xy"); - -//turn off xy grids -ildStyle->SetPadGridX(0); -ildStyle->SetPadGridY(0); - -//set the tick mark style -ildStyle->SetPadTickX(1); -ildStyle->SetPadTickY(1); - -//turn off stats -ildStyle->SetOptStat(0); -ildStyle->SetOptFit(0); - -//marker settings -ildStyle->SetMarkerStyle(20); -ildStyle->SetMarkerSize(0.7); -ildStyle->SetLineWidth(2); - -//done - - + // cout << "Loading ILD rootlogon for some stylish root standards." << endl; + + // ild TStyle + + // set the background color to white + ildStyle->SetFillColor(10); + ildStyle->SetFrameFillColor(10); + ildStyle->SetCanvasColor(10); + ildStyle->SetPadColor(10); + ildStyle->SetTitleFillColor(0); + ildStyle->SetStatColor(10); + + // dont put a colored frame around the plots + ildStyle->SetFrameBorderMode(0); + ildStyle->SetCanvasBorderMode(0); + ildStyle->SetPadBorderMode(0); + ildStyle->SetLegendBorderSize(0); + + // use the primary color palette + ildStyle->SetPalette(1, 0); + + // set the default line color for a histogram to be black + ildStyle->SetHistLineColor(kBlack); + + // set the default line color for a fit function to be red + ildStyle->SetFuncColor(kRed); + + // make the axis labels black + ildStyle->SetLabelColor(kBlack, "xyz"); + + // set the default title color to be black + ildStyle->SetTitleColor(kBlack); + + // set the margins + ildStyle->SetPadBottomMargin(0.18); + ildStyle->SetPadTopMargin(0.08); + ildStyle->SetPadRightMargin(0.08); + ildStyle->SetPadLeftMargin(0.17); + + // set axis label and title text sizes + ildStyle->SetLabelFont(42, "xyz"); + ildStyle->SetLabelSize(0.06, "xyz"); + ildStyle->SetLabelOffset(0.015, "xyz"); + ildStyle->SetTitleFont(42, "xyz"); + ildStyle->SetTitleSize(0.07, "xyz"); + ildStyle->SetTitleOffset(1.1, "yz"); + ildStyle->SetTitleOffset(1.0, "x"); + ildStyle->SetStatFont(42); + ildStyle->SetStatFontSize(0.07); + ildStyle->SetTitleBorderSize(0); + ildStyle->SetStatBorderSize(0); + ildStyle->SetTextFont(42); + + // set line widths + ildStyle->SetFrameLineWidth(2); + ildStyle->SetFuncWidth(2); + ildStyle->SetHistLineWidth(2); + + // set the number of divisions to show + ildStyle->SetNdivisions(506, "xy"); + + // turn off xy grids + ildStyle->SetPadGridX(0); + ildStyle->SetPadGridY(0); + + // set the tick mark style + ildStyle->SetPadTickX(1); + ildStyle->SetPadTickY(1); + + // turn off stats + ildStyle->SetOptStat(0); + ildStyle->SetOptFit(0); + + // marker settings + ildStyle->SetMarkerStyle(20); + ildStyle->SetMarkerSize(0.7); + ildStyle->SetLineWidth(2); + + // done } diff --git a/dEdX/include/dEdxAnalyser.h b/dEdX/include/dEdxAnalyser.h index 3fd9c44..4e28b93 100644 --- a/dEdX/include/dEdxAnalyser.h +++ b/dEdX/include/dEdxAnalyser.h @@ -1,94 +1,101 @@ #ifndef dEdxAnalyser_H #define dEdxAnalyser_H 1 -#include -#include "marlin/Processor.h" +#include "UTIL/ILDConf.h" #include "lcio.h" +#include "marlin/Processor.h" +#include +#include #include #include -#include -#include "UTIL/ILDConf.h" +#include "TCanvas.h" +#include "TF1.h" +#include "TF2.h" +#include "TFitResult.h" +#include "TFitResultPtr.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" -#include "TMath.h" -#include "TF1.h" -#include "TF2.h" -#include "TCanvas.h" #include "TImage.h" -#include "TFitResultPtr.h" -#include "TFitResult.h" +#include "TMath.h" -#ifdef MARLIN_AIDA //AIDA +#ifdef MARLIN_AIDA // AIDA #include #endif using namespace lcio; using namespace marlin; - /** dEdxAnalyser Processor
- * The dEdxAnalyser processor loops through tracks (directly or via PFOs) to collect their dE/dx, fills various histograms and calculates dE/dx resolution and separation power. - * Everything is stored in an AIDA-generated root-file. + * The dEdxAnalyser processor loops through tracks (directly or via PFOs) to collect their dE/dx, fills various + * histograms and calculates dE/dx resolution and separation power. Everything is stored in an AIDA-generated root-file. * Various plots can be automatically produced in the current working directory. * * The required collections are Tracks, a TrackMCTruthLink and the corresponding MCParticles. * If tracks attached to PFOs should be used, also a PFO collection is required. * The number of particle species to be investigated and their properties are hard-coded and must be set: - * _nPart is the number of species, set in this header, while the PDG number and the names of the particles (for labelling the histograms) are set in the init(). - * This version: _nPart = 5; species: electrons, muons, pions, kaon, protons. + * _nPart is the number of species, set in this header, while the PDG number and the names of the particles (for + * labelling the histograms) are set in the init(). This version: _nPart = 5; species: electrons, muons, pions, kaon, + * protons. * - * First, in processEvent(), the dE/dx value of each track is filled in the corresponding histogram, resulting in Bethe-Bloch curves. - * The true PDG is received from the MCParticle linked to the track. - * In end(), these histograms are then fitted with FitSlices, and the resulting mean and sigma values for each momentum bin are used to calculate resolution and separation power. - * The separation power is calculated for each combination of the _nPart species. - * All histograms, including the auto-generated fit results, are stored via AIDA in a root file. - * Finally, many of the histograms can be plotted and saved as images to the current working directory. + * First, in processEvent(), the dE/dx value of each track is filled in the corresponding histogram, resulting in + * Bethe-Bloch curves. The true PDG is received from the MCParticle linked to the track. In end(), these histograms are + * then fitted with FitSlices, and the resulting mean and sigma values for each momentum bin are used to calculate + * resolution and separation power. The separation power is calculated for each combination of the _nPart species. All + * histograms, including the auto-generated fit results, are stored via AIDA in a root file. Finally, many of the + * histograms can be plotted and saved as images to the current working directory. * * Several special histograms for calibration purposes are provided. - * The FiducialElectrons histograms collects electrons which are similar to electrons at the test beam. The resulting dE/dx resolution in ResNorm_FiducialElectrons should be used to calibrate the smearing factor in the Compute_dEdxProcessor. - * The histogram NormLambdaFullAll_1 contains the mean dE/dx over |lambda| incl. a poly3 fit, which is used in the AngularCorrection_dEdxProcessor for correction of the angular dependence. - * The histogram NormCosThFullAll_1 contains the mean dE/dx over cos(theta), and shows the information of NormLambdaFullAll_1 over an alternative angular scale. - * The Bethe-Bloch curves in BBHist are fitted to provide the parameters of the reference curves for the dEdxPID in the LikelihoodPIDProcessor. - * The fit results are stored with the histograms and also printed on the console at the end of the processor. + * The FiducialElectrons histograms collects electrons which are similar to electrons at the test beam. The resulting + * dE/dx resolution in ResNorm_FiducialElectrons should be used to calibrate the smearing factor in the + * Compute_dEdxProcessor. The histogram NormLambdaFullAll_1 contains the mean dE/dx over |lambda| incl. a poly3 fit, + * which is used in the AngularCorrection_dEdxProcessor for correction of the angular dependence. The histogram + * NormCosThFullAll_1 contains the mean dE/dx over cos(theta), and shows the information of NormLambdaFullAll_1 over an + * alternative angular scale. The Bethe-Bloch curves in BBHist are fitted to provide the parameters of the reference + * curves for the dEdxPID in the LikelihoodPIDProcessor. The fit results are stored with the histograms and also printed + * on the console at the end of the processor. * * You can run this Analyser over any selection of tracks, e.g. events that contain only pion and kaon tracks. - * In that case, only the pion and kaon resolution as well as only the pion-kaon separation would give sensible plots, but all other plots are be generated empty alongside. - * The Analyser has mostly been used to extract the dE/dx performance from single-particle random-momentum files, but also to check e.g. 6f-ttbar events. + * In that case, only the pion and kaon resolution as well as only the pion-kaon separation would give sensible plots, + * but all other plots are be generated empty alongside. The Analyser has mostly been used to extract the dE/dx + * performance from single-particle random-momentum files, but also to check e.g. 6f-ttbar events. * - * Note that the hit energy histograms will only be filled, if the track hits are available, which is usually only the case for REC-files. - * The hit number histograms are unaffected by this. + * Note that the hit energy histograms will only be filled, if the track hits are available, which is usually only the + * case for REC-files. The hit number histograms are unaffected by this. * - * @param _plotStuff - Set to true to switch on automatic image generation of many histograms in the current working directory. - * bool, default: false. + * @param _plotStuff - Set to true to switch on automatic image generation of many histograms in the current working + * directory. bool, default: false. * @param _fileFormat - Select the file extension to be used for the automatically generated images. - * Selection depends on root TPad::Print() capabilities, typically: [.ps, .eps, .pdf, .svg, .tex, .gif, .xpm, .png, .jpg, .tiff, .cxx, .xml, .json, .root]. - * See https://root.cern.ch/doc/master/classTPad.html#ad2fc5f449e4cb5480b9fb05fda3a8307 for details. - * string, default: .png + * Selection depends on root TPad::Print() capabilities, typically: [.ps, .eps, .pdf, .svg, .tex, .gif, .xpm, .png, + * .jpg, .tiff, .cxx, .xml, .json, .root]. See + * https://root.cern.ch/doc/master/classTPad.html#ad2fc5f449e4cb5480b9fb05fda3a8307 for details. string, default: .png * - * @param _usePFOTracks - Set to true to use tracks attached to charged PFO, instead of all tracks in the track collection. This should be used with events which are more busy than single particle files. - * bool, default: false. - * @param _useOneTrack - Set true if from every event only the first object in the selected collection (track or PFO) should be used. Usually, don't combine this with _usePFOTracks. - * bool, default: false. - * @param _usePFOTruthLink - Set true if the LCRelation from PFO to MCTruth instead of Track to MCTruth should be used to determine MC PDG. Caution: the name of this relation still needs to be given in TrackMCTruthLink. - * bool, default: false. + * @param _usePFOTracks - Set to true to use tracks attached to charged PFO, instead of all tracks in the track + * collection. This should be used with events which are more busy than single particle files. bool, default: false. + * @param _useOneTrack - Set true if from every event only the first object in the selected collection (track or PFO) + * should be used. Usually, don't combine this with _usePFOTracks. bool, default: false. + * @param _usePFOTruthLink - Set true if the LCRelation from PFO to MCTruth instead of Track to MCTruth should be used + * to determine MC PDG. Caution: the name of this relation still needs to be given in TrackMCTruthLink. bool, default: + * false. * - * You can make a track selection via the optional parameters, e. g. to reduce 'contamination' from mis-linked Tracks and MCParticles. + * You can make a track selection via the optional parameters, e. g. to reduce 'contamination' from mis-linked Tracks + * and MCParticles. * @param _cutdEdx - Set true if particles with a very off dE/dx value (hard-coded) should be ignored. * bool, default: false. - * @param _cutTrackPurity - Set true if particles should be ignored, where the MCParticle is connected to more than one track. - * bool, default: false. + * @param _cutTrackPurity - Set true if particles should be ignored, where the MCParticle is connected to more than one + * track. bool, default: false. * @param _cutD0 - Tracks with a d0 larger than the given value will be ignored. Set to 0 to accept all particles. * double, default: 0. * @param _cutZ0 - Tracks with a z0 larger than the given value will be ignored. Set to 0 to accept all particles. * double, default: 0. - * @param _cutMomMin - Tracks with a momentum smaller than the given value will be ignored. Set to 0 to accept all particles. - * double, default: 0. - * @param _cutMomMax - Tracks with a momentum larger than the given value will be ignored. Set to 0 to accept all particles. - * double, default: 0. + * @param _cutMomMin - Tracks with a momentum smaller than the given value will be ignored. Set to 0 to accept all + * particles. double, default: 0. + * @param _cutMomMax - Tracks with a momentum larger than the given value will be ignored. Set to 0 to accept all + * particles. double, default: 0. * - * For calibration with beam test results, so-called fiducial electrons are selected, which ought to be similar to beam-test conditions, and their properties stored in separate histograms. + * For calibration with beam test results, so-called fiducial electrons are selected, which ought to be similar to + * beam-test conditions, and their properties stored in separate histograms. * @param _fidMomMin - Fiducial minimum absolut momentum / GeV. * double, default: 3. * @param _fidMomMax - Fiducial maximum absolut momentum / GeV. @@ -100,7 +107,8 @@ using namespace marlin; * @param _fidNHitsMin - Fiducial minimum number of hits. * int, default: 200. * - * For some of the histograms, the axis binning can be adapted, which can be useful in case of very high or low statistics. + * For some of the histograms, the axis binning can be adapted, which can be useful in case of very high or low + * statistics. * @param _nBinsX - Number of bins of the momentum axis in histograms. * int, default: 100. * @param _nBinsY - Number of bins of the dE/dx axis in histograms. @@ -119,14 +127,11 @@ using namespace marlin; * @date 11/2022 */ - class dEdxAnalyser : public Processor { - - public: - - virtual Processor* newProcessor() { return new dEdxAnalyser ; } - - + +public: + virtual Processor* newProcessor() { return new dEdxAnalyser; } + dEdxAnalyser(); virtual ~dEdxAnalyser() = default; @@ -135,24 +140,21 @@ class dEdxAnalyser : public Processor { dEdxAnalyser& operator=(const dEdxAnalyser&) = delete; - virtual void init(); - - virtual void processRunHeader( LCRunHeader* run ); - - virtual void processEvent( LCEvent * evt ); - - virtual void check( LCEvent * evt ); - - virtual void end(); - virtual void PlotTH1( TCanvas* can, TH1* hist ); - virtual void PlotTH2( TCanvas* can, TH2* hist ); - virtual void PlotTH1_FPn( TCanvas* can, TH1* hist, int n ); + virtual void processRunHeader(LCRunHeader* run); + virtual void processEvent(LCEvent* evt); - protected: + virtual void check(LCEvent* evt); + virtual void end(); + + virtual void PlotTH1(TCanvas* can, TH1* hist); + virtual void PlotTH2(TCanvas* can, TH2* hist); + virtual void PlotTH1_FPn(TCanvas* can, TH1* hist, int n); + +protected: std::string _description = ""; int _nRun{}; int _nEvt{}; @@ -161,7 +163,7 @@ class dEdxAnalyser : public Processor { float _TPC_inner = 0; float _TPC_outer = 0; double _bField{}; - //std::vector _MCmomVec{}; + // std::vector _MCmomVec{}; // collection names std::string _trackColName{}; @@ -170,86 +172,90 @@ class dEdxAnalyser : public Processor { std::string _PFOColName{}; // optional parameters: binning, track selection, fiducial parameters and plotting - int _nBinsX=0, _nBinsY=0; - double _minBinX=0, _maxBinX=0, _minBinX2=0; - double _minBinY=0, _maxBinY=0; - - bool _usePFOTracks=false; - bool _useOneTrack=false; - bool _usePFOTruthLink=false; - bool _cutdEdx=false; - bool _cutTrackPurity=false; - bool _cutTrackPurityMom=false; - double _cutD0=0; - double _cutZ0=0; - double _cutMomMin=0; - double _cutMomMax=0; - double _cutLamMin=0; - double _cutLamMax=0; - - double _fidMomMin=0; - double _fidMomMax=0; - double _fidLamMin=0; - double _fidLamMax=0; - int _fidNHitsMin=0; + int _nBinsX = 0, _nBinsY = 0; + double _minBinX = 0, _maxBinX = 0, _minBinX2 = 0; + double _minBinY = 0, _maxBinY = 0; + + bool _usePFOTracks = false; + bool _useOneTrack = false; + bool _usePFOTruthLink = false; + bool _cutdEdx = false; + bool _cutTrackPurity = false; + bool _cutTrackPurityMom = false; + double _cutD0 = 0; + double _cutZ0 = 0; + double _cutMomMin = 0; + double _cutMomMax = 0; + double _cutLamMin = 0; + double _cutLamMax = 0; + + double _fidMomMin = 0; + double _fidMomMax = 0; + double _fidLamMin = 0; + double _fidLamMax = 0; + int _fidNHitsMin = 0; std::string _LikelihoodPIDMethod = "dEdxPID"; - bool _plotStuff=false; - bool _useLCTPCStyle=false; + bool _plotStuff = false; + bool _useLCTPCStyle = false; std::string _plotFolder = "."; std::string _fileFormat = ".png"; // number of particle species to be separated static const int _nPart = 5; - // pdg numbers and masses of particles, to be specified in ::init() (along with corresponding strings for names and descriptions) - std::array _PDG{}; + // pdg numbers and masses of particles, to be specified in ::init() (along with corresponding strings for names and + // descriptions) + std::array _PDG{}; std::array _Masses{}; // Bethe-Bloch histograms (including one for "other particles" and one for "all particles") - TH2* _BBHist[_nPart+2]; + TH2* _BBHist[_nPart + 2]; // Gaussian fit results: each TObjArray has 4 histograms (amplitude, mean, sigma and chi2) TObjArray* _FitHist[_nPart]; TObjArray* _FitLambda[_nPart]; - TObjArray* _FitNHit[_nPart+1]; + TObjArray* _FitNHit[_nPart + 1]; TObjArray* _FitBoth[_nPart]; TObjArray* _FitBoth_1GeV[_nPart]; - TObjArray* _FitLambdaFull[_nPart+1]; - TObjArray* _FitCosThFull[_nPart+1]; + TObjArray* _FitLambdaFull[_nPart + 1]; + TObjArray* _FitCosThFull[_nPart + 1]; - // Storage for names of histograms to have a handle on fit results that are 'free floating' in memory, since TH3::FitSlicesZ has no direct transfer - std::vector< std::string > _NormBothHistNames[_nPart]; - std::vector< std::string > _NormBothHistNames_1GeV[_nPart]; + // Storage for names of histograms to have a handle on fit results that are 'free floating' in memory, since + // TH3::FitSlicesZ has no direct transfer + std::vector _NormBothHistNames[_nPart]; + std::vector _NormBothHistNames_1GeV[_nPart]; // dE/dx resolution over momentum histograms - TH1* _FitHist_Res[_nPart]; // resolution from fit results - TH1* _FitHist_ResSum[_nPart]; // resolution from fit results summed up above 1 GeV - TH1* _ResNormHist[_nPart]; // resolution for all entries of a species above .3 GeV with normalisation - TH1* _ResNormHist_1GeV[_nPart]; // resolution for all entries of a species above 1 GeV with normalisation - TH1* _ResElectrons{}; // resolution for all electron entries above .3 GeV, no normalisation - TH1* _ResNorm_FiducialElectrons{}; // resolution for all fiducial electrons with normalisation + TH1* _FitHist_Res[_nPart]; // resolution from fit results + TH1* _FitHist_ResSum[_nPart]; // resolution from fit results summed up above 1 GeV + TH1* _ResNormHist[_nPart]; // resolution for all entries of a species above .3 GeV with normalisation + TH1* _ResNormHist_1GeV[_nPart]; // resolution for all entries of a species above 1 GeV with normalisation + TH1* _ResElectrons{}; // resolution for all electron entries above .3 GeV, no normalisation + TH1* _ResNorm_FiducialElectrons{}; // resolution for all fiducial electrons with normalisation // Resolution dependence on different parameters, fit histograms - TH2* _NormLambdaHist[_nPart]; // relative dEdx vs. lambda of track, for tracks with p>1GeV, nHits>=200 - TH1* _FitLambda_Res[_nPart]; // resolution vs. lambda from fit results - TH2* _NormNHitHist[_nPart+1]; // normalised dEdx vs. number of hits of track, for tracks with |lambda|<20deg - TH1* _FitNHit_Res[_nPart+1]; // resolution vs. number of hits from fit results - TH3* _NormBothHist[_nPart]; // relative dEdx vs. lambda of track and vs. number of hits - TH2* _FitBoth_Res[_nPart]; // resolution vs. lambda and vs. number of hits from fit results - TH3* _NormBothHist_1GeV[_nPart]; // relative dEdx vs. lambda of track and vs. number of hits, for tracks with p>1GeV - TH2* _FitBoth_Res_1GeV[_nPart]; // resolution vs. lambda and vs. number of hits from fit results, for tracks with p>1GeV - TH2* _NormLambdaFullHist[_nPart+1]; // relative dEdx vs. lambda of track, for tracks with p>1GeV - TH1* _FitLambdaFull_Res[_nPart+1]; // resolution vs. lambda from fit results - TH2* _NormCosThFullHist[_nPart+1]; // relative dEdx vs. lambda of track, for tracks with p>1GeV - TH1* _FitCosThFull_Res[_nPart+1]; // resolution vs. lambda from fit results - - // Vector array of all momentum, dE/dx, dE/dx error, tan lambda, number of hits and transverse momentum values for each track - std::vector< std::array > _dEdxVec[_nPart]; + TH2* _NormLambdaHist[_nPart]; // relative dEdx vs. lambda of track, for tracks with p>1GeV, nHits>=200 + TH1* _FitLambda_Res[_nPart]; // resolution vs. lambda from fit results + TH2* _NormNHitHist[_nPart + 1]; // normalised dEdx vs. number of hits of track, for tracks with |lambda|<20deg + TH1* _FitNHit_Res[_nPart + 1]; // resolution vs. number of hits from fit results + TH3* _NormBothHist[_nPart]; // relative dEdx vs. lambda of track and vs. number of hits + TH2* _FitBoth_Res[_nPart]; // resolution vs. lambda and vs. number of hits from fit results + TH3* _NormBothHist_1GeV[_nPart]; // relative dEdx vs. lambda of track and vs. number of hits, for tracks with p>1GeV + TH2* _FitBoth_Res_1GeV[_nPart]; // resolution vs. lambda and vs. number of hits from fit results, for tracks with + // p>1GeV + TH2* _NormLambdaFullHist[_nPart + 1]; // relative dEdx vs. lambda of track, for tracks with p>1GeV + TH1* _FitLambdaFull_Res[_nPart + 1]; // resolution vs. lambda from fit results + TH2* _NormCosThFullHist[_nPart + 1]; // relative dEdx vs. lambda of track, for tracks with p>1GeV + TH1* _FitCosThFull_Res[_nPart + 1]; // resolution vs. lambda from fit results + + // Vector array of all momentum, dE/dx, dE/dx error, tan lambda, number of hits and transverse momentum values for + // each track + std::vector> _dEdxVec[_nPart]; // Separation power between all particle combinations - TH1* _SPHist[_nPart*(_nPart-1)/2]; + TH1* _SPHist[_nPart * (_nPart - 1) / 2]; // MC particle multiplicity according to track2mctruth link TH1* _MCmult{}; @@ -274,19 +280,18 @@ class dEdxAnalyser : public Processor { TH2* _dEdxErrorCorrelation{}; // Hit charge spectrum - TH1* _HitEnergySpectrum[_nPart+2]; - TH1* _HitNumberSpectrum[_nPart+2]; - TH1* _HitEnergySpectrum_at1[_nPart+2]; - TH1* _HitEnergySpectrum_at25[_nPart+2]; - TH2* _HEHist[_nPart+2]; + TH1* _HitEnergySpectrum[_nPart + 2]; + TH1* _HitNumberSpectrum[_nPart + 2]; + TH1* _HitEnergySpectrum_at1[_nPart + 2]; + TH1* _HitEnergySpectrum_at25[_nPart + 2]; + TH2* _HEHist[_nPart + 2]; // Landau fit results: each TObjArray has 4 histograms (amplitude, MPV, sigma and chi2) TObjArray* _HEFitHist[_nPart]; // handles on number of hits, stored in the vector SubdetectorHitNumbers at a certain index const int _TPCID = ILDDetID::TPC; - const int _TPCindex = _TPCID*2-2; - -} ; + const int _TPCindex = _TPCID * 2 - 2; +}; #endif diff --git a/kinfit/macros/WW5CFit_compare.C b/kinfit/macros/WW5CFit_compare.C index 34fa79a..26ea0ac 100644 --- a/kinfit/macros/WW5CFit_compare.C +++ b/kinfit/macros/WW5CFit_compare.C @@ -1,105 +1,98 @@ ///////////////////////////////////////////////////////////////////////////////////////// -#include +#include - -void WW5CFit_compare (const char* reffilename = "WW5CFit.root", - const char* testfilename = "../rootfiles/WW5CFit_test.root", - const char* legtitle = "OPALFitter, WW -> 4jets", - const char* outfilename = "comparison_WW5C") { +void WW5CFit_compare(const char* reffilename = "WW5CFit.root", + const char* testfilename = "../rootfiles/WW5CFit_test.root", + const char* legtitle = "OPALFitter, WW -> 4jets", const char* outfilename = "comparison_WW5C") { gStyle->SetOptTitle(0); - gStyle->SetTitleOffset(1.5,"y"); + gStyle->SetTitleOffset(1.5, "y"); gStyle->SetPadLeftMargin(0.2); - + const int nfile = 2; - TFile *histfile[nfile]; + TFile* histfile[nfile]; histfile[0] = new TFile(testfilename); histfile[1] = new TFile(reffilename); - - + const int nhist = 4; TString histnames[nhist]; histnames[0] = "MyWW5CFit/hJetMass"; - //histnames[0] = "MyWW5CFit/hFitError"; + // histnames[0] = "MyWW5CFit/hFitError"; histnames[1] = "MyWW5CFit/hNItBest"; histnames[2] = "MyWW5CFit/hFitProb"; histnames[3] = "MyWW5CFit/hRecWMassBest"; - + bool logy[nhist] = {true, true, true, false}; - + TString axistitle[nhist]; axistitle[0] = "Jet mass / GeV"; -// axistitle[0] = "Error flag"; + // axistitle[0] = "Error flag"; axistitle[1] = "Number of iterations"; axistitle[2] = "Fit probability"; axistitle[3] = "W mass / GeV"; - + double leg_left[nhist] = {0.4, 0.4, 0.4, 0.6}; double leg_right[nhist] = {0.9, 0.9, 0.9, 0.9}; - - TH1F *h[nhist][nfile]; - + + TH1F* h[nhist][nfile]; + // read histos for (int ifile = 0; ifile < nfile; ++ifile) { if (!histfile[ifile]) { cout << "ERROR: couldn't open file " << histfile[ifile] << endl; - return; - } + return; + } for (int ihist = 0; ihist < nhist; ++ihist) { cout << "reading histogram " << histnames[ihist] << " from ifile " << ifile << endl; - h[ihist][ifile] = (TH1F *) histfile[ifile]->Get(histnames[ihist]); + h[ihist][ifile] = (TH1F*)histfile[ifile]->Get(histnames[ihist]); if (!h[ihist][ifile]) { cout << "ERROR: couldn't find histogram" << endl; - return; - } + return; + } h[ihist][ifile]->StatOverflows(true); h[ihist][ifile]->SetXTitle(axistitle[ihist]); h[ihist][ifile]->SetYTitle("Events"); - if (ifile == 0){ // test histo - h[ihist][ifile]->SetMarkerColor(1); - h[ihist][ifile]->SetMarkerStyle(20); - h[ihist][ifile]->SetMarkerSize(0.75); - } - else if (ifile == 1) { // ref histo + if (ifile == 0) { // test histo + h[ihist][ifile]->SetMarkerColor(1); + h[ihist][ifile]->SetMarkerStyle(20); + h[ihist][ifile]->SetMarkerSize(0.75); + } else if (ifile == 1) { // ref histo double norm = h[ihist][0]->GetEntries() / h[ihist][1]->GetEntries(); - cout << "scaling reference histogram by " << norm << endl; + cout << "scaling reference histogram by " << norm << endl; h[ihist][ifile]->Scale(norm); - h[ihist][ifile]->SetLineColor(2); - //h[ihist][ifile]->SetHistLineWidth(4); - } + h[ihist][ifile]->SetLineColor(2); + // h[ihist][ifile]->SetHistLineWidth(4); + } } } - - + cout << "FINISHED READING HISTOGRAMS!" << endl; // draw - TCanvas *c = new TCanvas ("c","compare",600,600); - c->Divide(2,2); - TLegend *leg[nhist]; + TCanvas* c = new TCanvas("c", "compare", 600, 600); + c->Divide(2, 2); + TLegend* leg[nhist]; for (int ihist = 0; ihist < nhist; ++ihist) { - c->cd(ihist+1); - if (logy[ihist]) gPad->SetLogy(); - leg[ihist] = new TLegend (leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); + c->cd(ihist + 1); + if (logy[ihist]) + gPad->SetLogy(); + leg[ihist] = new TLegend(leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); h[ihist][1]->Draw("hist"); - leg[ihist]->AddEntry(h[ihist][1],"Reference","L"); + leg[ihist]->AddEntry(h[ihist][1], "Reference", "L"); h[ihist][0]->Draw("e0same"); - leg[ihist]->AddEntry(h[ihist][0],"Test file","P"); - - leg[ihist]->Draw(); - } - - // --------------- save to pdf file ---------------------------------- - - std::string epsFile( std::string( outfilename ) + std::string( ".eps" ) ) ; - std::string pdfFile( std::string( outfilename ) + std::string( ".pdf" ) ) ; - std::string cFile ( std::string( outfilename ) + std::string( ".C" ) ) ; - c->Print( epsFile.c_str() ) ; - c->Print( pdfFile.c_str() ) ; - c->Print( cFile.c_str() ) ; + leg[ihist]->AddEntry(h[ihist][0], "Test file", "P"); + leg[ihist]->Draw(); + } + // --------------- save to pdf file ---------------------------------- + std::string epsFile(std::string(outfilename) + std::string(".eps")); + std::string pdfFile(std::string(outfilename) + std::string(".pdf")); + std::string cFile(std::string(outfilename) + std::string(".C")); + c->Print(epsFile.c_str()); + c->Print(pdfFile.c_str()); + c->Print(cFile.c_str()); } diff --git a/kinfit/macros/ZH5CFit_compare.C b/kinfit/macros/ZH5CFit_compare.C index 6cc2223..32a0c22 100644 --- a/kinfit/macros/ZH5CFit_compare.C +++ b/kinfit/macros/ZH5CFit_compare.C @@ -1,24 +1,21 @@ ///////////////////////////////////////////////////////////////////////////////////////// -#include +#include - -void ZH5CFit_compare (const char* reffilename = "ZH5CFit_OPAL.root", - const char* testfilename = "../rootfiles/ZH5CFit_test.root", - const char* legtitle = "ZH -> 4jets", - const char* outfilename = "comparison_ZH5CFit") { +void ZH5CFit_compare(const char* reffilename = "ZH5CFit_OPAL.root", + const char* testfilename = "../rootfiles/ZH5CFit_test.root", const char* legtitle = "ZH -> 4jets", + const char* outfilename = "comparison_ZH5CFit") { gStyle->SetOptTitle(0); -// gStyle->SetOptStat(0); + // gStyle->SetOptStat(0); gStyle->SetOptFit(1); - gStyle->SetTitleOffset(1.5,"y"); + gStyle->SetTitleOffset(1.5, "y"); gStyle->SetPadLeftMargin(0.2); - + const int nfile = 2; - TFile *histfile[nfile]; + TFile* histfile[nfile]; histfile[0] = new TFile(testfilename); histfile[1] = new TFile(reffilename); - - + const int nhist = 12; TString histnames[nhist][nfile]; @@ -26,41 +23,41 @@ void ZH5CFit_compare (const char* reffilename = "ZH5CFit_OPAL.root", histnames[1][0] = "MyZH5CFit/hNItBest"; histnames[2][0] = "MyZH5CFit/hFitProb"; histnames[3][0] = "MyZH5CFit/hPhotonEnergy"; - + histnames[4][0] = "MyZH5CFit/hRecHMassBest"; histnames[5][0] = "MyZH5CFit/hRecHMassAll"; histnames[6][0] = "MyZH5CFit/hRecHMassNoFitBest"; histnames[7][0] = "MyZH5CFit/hRecZMassNoFitBest"; - + histnames[8][0] = "MyZH5CFit/hFitErrorBest"; histnames[9][0] = "MyZH5CFit/hPullEJetBest"; histnames[10][0] = "MyZH5CFit/hPullThJetBest"; histnames[11][0] = "MyZH5CFit/hPullPhJetBest"; - + histnames[0][1] = "MyZH5CFit/hJetMass"; histnames[1][1] = "MyZH5CFit/hNItBest"; histnames[2][1] = "MyZH5CFit/hFitProb"; histnames[3][1] = "MyZH5CFit/hPhotonEnergy"; - + histnames[4][1] = "MyZH5CFit/hRecHMassBest"; histnames[5][1] = "MyZH5CFit/hRecHMassAll"; histnames[6][1] = "MyZH5CFit/hRecHMassNoFitBest"; histnames[7][1] = "MyZH5CFit/hRecZMassNoFitBest"; - + histnames[8][1] = "MyZH5CFit/hFitErrorBest"; histnames[9][1] = "MyZH5CFit/hPullEJetBest"; histnames[10][1] = "MyZH5CFit/hPullThJetBest"; histnames[11][1] = "MyZH5CFit/hPullPhJetBest"; - + bool logy[nhist] = {true, true, true, true, false, false, false, false, true, false, false, false}; - + TString axistitle[nhist]; axistitle[0] = "Jet mass / GeV"; axistitle[1] = "Number of iterations"; axistitle[2] = "Fit probability"; axistitle[3] = "Photon Energy / GeV"; - + axistitle[4] = "H mass / GeV (best)"; axistitle[5] = "H mass / GeV (all)"; axistitle[6] = "H mass / GeV (best, no fit)"; @@ -70,130 +67,136 @@ void ZH5CFit_compare (const char* reffilename = "ZH5CFit_OPAL.root", axistitle[9] = "pull E_jet, best perm"; axistitle[10] = "pull #theta_jet, best perm"; axistitle[11] = "pull #phi_jet, best perm"; - - double leg_left[nhist] = {0.4, 0.4, 0.25, 0.25, 0.6, 0.6, 0.6, 0.5, 0.4, 0.25, 0.25, 0.25}; - double leg_right[nhist] = {0.9, 0.9, 0.9, 0.9, 1.0, 0.9, 1.0, 0.9, 0.9, 0.5, 0.5, 0.5}; - - TH1F *h[nhist][nfile]; - + + double leg_left[nhist] = {0.4, 0.4, 0.25, 0.25, 0.6, 0.6, 0.6, 0.5, 0.4, 0.25, 0.25, 0.25}; + double leg_right[nhist] = {0.9, 0.9, 0.9, 0.9, 1.0, 0.9, 1.0, 0.9, 0.9, 0.5, 0.5, 0.5}; + + TH1F* h[nhist][nfile]; + // read histos for (int ifile = 0; ifile < nfile; ++ifile) { if (!histfile[ifile]) { cout << "ERROR: couldn't open file " << histfile[ifile] << endl; - return; - } + return; + } for (int ihist = 0; ihist < nhist; ++ihist) { - cout << "reading histogram " << histnames[ihist][ifile] << " from ifile " << ifile << " with name " << histfile[ifile]->GetName() << endl; - h[ihist][ifile] = (TH1F *) histfile[ifile]->Get(histnames[ihist][ifile])->Clone(); + cout << "reading histogram " << histnames[ihist][ifile] << " from ifile " << ifile << " with name " + << histfile[ifile]->GetName() << endl; + h[ihist][ifile] = (TH1F*)histfile[ifile]->Get(histnames[ihist][ifile])->Clone(); if (!h[ihist][ifile]) { cout << "ERROR: couldn't find histogram" << endl; - return; - } + return; + } h[ihist][ifile]->StatOverflows(true); h[ihist][ifile]->SetXTitle(axistitle[ihist]); h[ihist][ifile]->SetYTitle("Events"); - if (h[ihist][ifile]->GetMinimum() > 1) h[ihist][ifile]->SetMinimum(1.); - if (ifile == 0){ // test histo - h[ihist][ifile]->SetMarkerColor(1); - h[ihist][ifile]->SetMarkerStyle(20); - h[ihist][ifile]->SetMarkerSize(0.5); - } - else if (ifile == 1) { // ref histo + if (h[ihist][ifile]->GetMinimum() > 1) + h[ihist][ifile]->SetMinimum(1.); + if (ifile == 0) { // test histo + h[ihist][ifile]->SetMarkerColor(1); + h[ihist][ifile]->SetMarkerStyle(20); + h[ihist][ifile]->SetMarkerSize(0.5); + } else if (ifile == 1) { // ref histo double norm = h[ihist][0]->GetEntries() / h[ihist][1]->GetEntries(); - cout << "scaling reference histogram by " << norm << endl; + cout << "scaling reference histogram by " << norm << endl; h[ihist][ifile]->Scale(norm); - h[ihist][ifile]->SetLineColor(2); - double max = h[ihist][0]->GetMaximum(); - if (h[ihist][1]->GetMaximum() > max) max = h[ihist][1]->GetMaximum(); - h[ihist][ifile]->SetMaximum(1.2*max); - //if (ihist == 2) h[ihist][ifile]->SetMinimum(10.); - //h[ihist][ifile]->SetHistLineWidth(4); + h[ihist][ifile]->SetLineColor(2); + double max = h[ihist][0]->GetMaximum(); + if (h[ihist][1]->GetMaximum() > max) + max = h[ihist][1]->GetMaximum(); + h[ihist][ifile]->SetMaximum(1.2 * max); + // if (ihist == 2) h[ihist][ifile]->SetMinimum(10.); + // h[ihist][ifile]->SetHistLineWidth(4); } } } - - + cout << "FINISHED READING HISTOGRAMS!" << endl; - + std::string legref = std::string("Reference: ") + std::string(reffilename); std::string legtest = std::string("Test file"); // draw - TCanvas *c1 = new TCanvas ("c1","compare",600,600); - c1->Divide(2,2); - TLegend *leg1[nhist]; + TCanvas* c1 = new TCanvas("c1", "compare", 600, 600); + c1->Divide(2, 2); + TLegend* leg1[nhist]; for (int ihist = 0; ihist < 4; ++ihist) { - c1->cd(ihist+1); - if (logy[ihist]) gPad->SetLogy(); - leg1[ihist] = new TLegend (leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); + c1->cd(ihist + 1); + if (logy[ihist]) + gPad->SetLogy(); + leg1[ihist] = new TLegend(leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); h[ihist][1]->Draw("hist"); - leg1[ihist]->AddEntry(h[ihist][1],legref.c_str(),"L"); + leg1[ihist]->AddEntry(h[ihist][1], legref.c_str(), "L"); h[ihist][0]->Draw("e0same"); - leg1[ihist]->AddEntry(h[ihist][0],legtest.c_str(),"P"); - - leg1[ihist]->Draw(); + leg1[ihist]->AddEntry(h[ihist][0], legtest.c_str(), "P"); + + leg1[ihist]->Draw(); } - - TCanvas *c2 = new TCanvas ("c2","masses",600,600); - c2->Divide(2,2); - TLegend *leg2[nhist]; + + TCanvas* c2 = new TCanvas("c2", "masses", 600, 600); + c2->Divide(2, 2); + TLegend* leg2[nhist]; for (int ihist = 4; ihist < 8; ++ihist) { - c2->cd(ihist-3); - if (logy[ihist]) gPad->SetLogy(); - leg2[ihist] = new TLegend (leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); + c2->cd(ihist - 3); + if (logy[ihist]) + gPad->SetLogy(); + leg2[ihist] = new TLegend(leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); h[ihist][1]->Draw("hist"); - leg2[ihist]->AddEntry(h[ihist][1],legref.c_str(),"L"); + leg2[ihist]->AddEntry(h[ihist][1], legref.c_str(), "L"); h[ihist][0]->Draw("e0same"); - leg2[ihist]->AddEntry(h[ihist][0],legtest.c_str(),"P"); - - leg2[ihist]->Draw(); + leg2[ihist]->AddEntry(h[ihist][0], legtest.c_str(), "P"); + + leg2[ihist]->Draw(); } - - TCanvas *c3 = new TCanvas ("c3","pulls",600,600); - c3->Divide(2,2); - TLegend *leg3[nhist]; + + TCanvas* c3 = new TCanvas("c3", "pulls", 600, 600); + c3->Divide(2, 2); + TLegend* leg3[nhist]; for (int ihist = 8; ihist < nhist; ++ihist) { - c3->cd(ihist-7); - if (logy[ihist]) gPad->SetLogy(); - //gStyle->SetOptStat(1); - //gStyle->SetOptFit(1); - leg3[ihist] = new TLegend (leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); - double max = h[ihist][0]->GetMaximum(); - if (h[ihist][1]->GetMaximum() > max) max = h[ihist][1]->GetMaximum(); - h[ihist][0]->SetMaximum (1.1*max); + c3->cd(ihist - 7); + if (logy[ihist]) + gPad->SetLogy(); + // gStyle->SetOptStat(1); + // gStyle->SetOptFit(1); + leg3[ihist] = new TLegend(leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); + double max = h[ihist][0]->GetMaximum(); + if (h[ihist][1]->GetMaximum() > max) + max = h[ihist][1]->GetMaximum(); + h[ihist][0]->SetMaximum(1.1 * max); h[ihist][0]->Draw("e0"); - if (ihist > 8) h[ihist][0]->Fit("gaus","R","",-1,1); + if (ihist > 8) + h[ihist][0]->Fit("gaus", "R", "", -1, 1); h[ihist][1]->Draw("histsame"); h[ihist][0]->Draw("e0same"); - leg3[ihist]->AddEntry(h[ihist][1],legref.c_str(),"L"); - leg3[ihist]->AddEntry(h[ihist][0],legtest.c_str(),"P"); - - leg3[ihist]->Draw(); - } - - // --------------- save to pdf file ---------------------------------- + leg3[ihist]->AddEntry(h[ihist][1], legref.c_str(), "L"); + leg3[ihist]->AddEntry(h[ihist][0], legtest.c_str(), "P"); - std::string epsFile1( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_1" ) + std::string( ".eps" ) ) ; - std::string pdfFile1( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_1" ) + std::string( ".pdf" ) ) ; - //std::stTVirtualPad::SetOptFitring cFile1 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_1" ) + std::string( ".C" ) ) ; - c1->Print( epsFile1.c_str() ) ; - c1->Print( pdfFile1.c_str() ) ; - //c1->Print( cFile1.c_str() ) ; - - std::string epsFile2( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + std::string( ".eps" ) ) ; - std::string pdfFile2( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + std::string( ".pdf" ) ) ; - //std::string cFile2 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + std::string( ".C" ) ) ; - c2->Print( epsFile2.c_str() ) ; - c2->Print( pdfFile2.c_str() ) ; - //c2->Print( cFile2.c_str() ) ; + leg3[ihist]->Draw(); + } - std::string epsFile3( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_3" ) + std::string( ".eps" ) ) ; - std::string pdfFile3( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_3" ) + std::string( ".pdf" ) ) ; - //std::string cFile3 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_3" ) + std::string( ".C" ) ) ; - c3->Print( epsFile3.c_str() ) ; - c3->Print( pdfFile3.c_str() ) ; - //c3->Print( cFile3.c_str() ) ; + // --------------- save to pdf file ---------------------------------- + std::string epsFile1(std::string("../plots/") + std::string(outfilename) + std::string("_1") + std::string(".eps")); + std::string pdfFile1(std::string("../plots/") + std::string(outfilename) + std::string("_1") + std::string(".pdf")); + // std::stTVirtualPad::SetOptFitring cFile1 ( std::string( "../plots/" ) + std::string( outfilename ) + + // std::string( "_1" ) + std::string( ".C" ) ) ; + c1->Print(epsFile1.c_str()); + c1->Print(pdfFile1.c_str()); + // c1->Print( cFile1.c_str() ) ; + std::string epsFile2(std::string("../plots/") + std::string(outfilename) + std::string("_2") + std::string(".eps")); + std::string pdfFile2(std::string("../plots/") + std::string(outfilename) + std::string("_2") + std::string(".pdf")); + // std::string cFile2 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + + // std::string( ".C" ) ) ; + c2->Print(epsFile2.c_str()); + c2->Print(pdfFile2.c_str()); + // c2->Print( cFile2.c_str() ) ; + std::string epsFile3(std::string("../plots/") + std::string(outfilename) + std::string("_3") + std::string(".eps")); + std::string pdfFile3(std::string("../plots/") + std::string(outfilename) + std::string("_3") + std::string(".pdf")); + // std::string cFile3 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_3" ) + + // std::string( ".C" ) ) ; + c3->Print(epsFile3.c_str()); + c3->Print(pdfFile3.c_str()); + // c3->Print( cFile3.c_str() ) ; } diff --git a/kinfit/macros/ZHWW5CFit_compare.C b/kinfit/macros/ZHWW5CFit_compare.C index 694d46c..c505052 100644 --- a/kinfit/macros/ZHWW5CFit_compare.C +++ b/kinfit/macros/ZHWW5CFit_compare.C @@ -1,152 +1,152 @@ ///////////////////////////////////////////////////////////////////////////////////////// -#include +#include - -void ZHWW5CFit_compare (const char* reffilename = "WW5CFit.root", - const char* testfilename = "../rootfiles/ZH5CFit_test.root", - const char* legtitle = "OPALFitter, WW/ZH -> 4jets", - const char* outfilename = "comparison_ZHWW5CFit") { +void ZHWW5CFit_compare(const char* reffilename = "WW5CFit.root", + const char* testfilename = "../rootfiles/ZH5CFit_test.root", + const char* legtitle = "OPALFitter, WW/ZH -> 4jets", + const char* outfilename = "comparison_ZHWW5CFit") { gStyle->SetOptTitle(0); - gStyle->SetTitleOffset(1.5,"y"); + gStyle->SetTitleOffset(1.5, "y"); gStyle->SetPadLeftMargin(0.2); - + const int nfile = 2; - TFile *histfile[nfile]; + TFile* histfile[nfile]; histfile[0] = new TFile(testfilename); histfile[1] = new TFile(reffilename); - - + const int nhist = 8; TString histnames[nhist][nfile]; histnames[0][0] = "MyZH5CFit/hJetMass"; - //histnames[0] = "MyZH5CFit/hFitError"; + // histnames[0] = "MyZH5CFit/hFitError"; histnames[1][0] = "MyZH5CFit/hNItBest"; histnames[2][0] = "MyZH5CFit/hFitProb"; histnames[3][0] = "MyZH5CFit/hPhotonEnergy"; - + histnames[4][0] = "MyZH5CFit/hRecHMassBest"; histnames[5][0] = "MyZH5CFit/hRecHMassAll"; histnames[6][0] = "MyZH5CFit/hRecHMassNoFitBest"; histnames[7][0] = "MyZH5CFit/hRecZMassNoFitBest"; - + histnames[0][1] = "MyWW5CFit/hJetMass"; - //histnames[0] = "MyZH5CFit/hFitError"; + // histnames[0] = "MyZH5CFit/hFitError"; histnames[1][1] = "MyWW5CFit/hNItBest"; histnames[2][1] = "MyWW5CFit/hFitProb"; histnames[3][1] = "MyWW5CFit/hPhotonEnergy"; - + histnames[4][1] = "MyWW5CFit/hRecWMassBest"; histnames[5][1] = "MyWW5CFit/hRecWMassAll"; histnames[6][1] = "MyWW5CFit/hRecWMassNoFitBest"; histnames[7][1] = "MyWW5CFit/hRecWMassNoFitBest"; - + bool logy[nhist] = {true, true, true, true, false, false, false, false}; - + TString axistitle[nhist]; axistitle[0] = "Jet mass / GeV"; -// axistitle[0] = "Error flag"; + // axistitle[0] = "Error flag"; axistitle[1] = "Number of iterations"; axistitle[2] = "Fit probability"; axistitle[3] = "Photon Energy / GeV"; - + axistitle[4] = "W/H mass / GeV (best)"; axistitle[5] = "W/H mass / GeV (all)"; axistitle[6] = "W/H mass / GeV (best, no fit)"; axistitle[7] = "W/Z mass / GeV (best, no fit)"; - - double leg_left[nhist] = {0.4, 0.4, 0.4, 0.4, 0.7, 0.6, 0.7, 0.6}; + + double leg_left[nhist] = {0.4, 0.4, 0.4, 0.4, 0.7, 0.6, 0.7, 0.6}; double leg_right[nhist] = {0.9, 0.9, 0.9, 0.9, 1.0, 0.9, 1.0, 0.9}; - - TH1F *h[nhist][nfile]; - + + TH1F* h[nhist][nfile]; + // read histos for (int ifile = 0; ifile < nfile; ++ifile) { if (!histfile[ifile]) { cout << "ERROR: couldn't open file " << histfile[ifile] << endl; - return; - } + return; + } for (int ihist = 0; ihist < nhist; ++ihist) { - cout << "reading histogram " << histnames[ihist][ifile] << " from ifile " << ifile << " with name " << histfile[ifile]->GetName() << endl; - h[ihist][ifile] = (TH1F *) histfile[ifile]->Get(histnames[ihist][ifile])->Clone(); + cout << "reading histogram " << histnames[ihist][ifile] << " from ifile " << ifile << " with name " + << histfile[ifile]->GetName() << endl; + h[ihist][ifile] = (TH1F*)histfile[ifile]->Get(histnames[ihist][ifile])->Clone(); if (!h[ihist][ifile]) { cout << "ERROR: couldn't find histogram" << endl; - return; - } + return; + } h[ihist][ifile]->StatOverflows(true); h[ihist][ifile]->SetXTitle(axistitle[ihist]); h[ihist][ifile]->SetYTitle("Events"); - if (ifile == 0){ // test histo - h[ihist][ifile]->SetMarkerColor(1); - h[ihist][ifile]->SetMarkerStyle(20); - h[ihist][ifile]->SetMarkerSize(0.5); - } - else if (ifile == 1) { // ref histo + if (ifile == 0) { // test histo + h[ihist][ifile]->SetMarkerColor(1); + h[ihist][ifile]->SetMarkerStyle(20); + h[ihist][ifile]->SetMarkerSize(0.5); + } else if (ifile == 1) { // ref histo double norm = h[ihist][0]->GetEntries() / h[ihist][1]->GetEntries(); - cout << "scaling reference histogram by " << norm << endl; + cout << "scaling reference histogram by " << norm << endl; h[ihist][ifile]->Scale(norm); - h[ihist][ifile]->SetLineColor(2); - double max = h[ihist][0]->GetMaximum(); - if (h[ihist][1]->GetMaximum() > max) max = h[ihist][1]->GetMaximum(); - h[ihist][ifile]->SetMaximum(1.2*max); - if (ihist == 3) h[ihist][ifile]->SetMinimum(1.); - //h[ihist][ifile]->SetHistLineWidth(4); - } + h[ihist][ifile]->SetLineColor(2); + double max = h[ihist][0]->GetMaximum(); + if (h[ihist][1]->GetMaximum() > max) + max = h[ihist][1]->GetMaximum(); + h[ihist][ifile]->SetMaximum(1.2 * max); + if (ihist == 3) + h[ihist][ifile]->SetMinimum(1.); + // h[ihist][ifile]->SetHistLineWidth(4); + } } } - - + cout << "FINISHED READING HISTOGRAMS!" << endl; // draw - TCanvas *c1 = new TCanvas ("c1","compare",600,600); - c1->Divide(2,2); - TLegend *leg1[nhist]; + TCanvas* c1 = new TCanvas("c1", "compare", 600, 600); + c1->Divide(2, 2); + TLegend* leg1[nhist]; for (int ihist = 0; ihist < 4; ++ihist) { - c1->cd(ihist+1); - if (logy[ihist]) gPad->SetLogy(); - leg1[ihist] = new TLegend (leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); + c1->cd(ihist + 1); + if (logy[ihist]) + gPad->SetLogy(); + leg1[ihist] = new TLegend(leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); h[ihist][1]->Draw("hist"); - leg1[ihist]->AddEntry(h[ihist][1],"Reference","L"); + leg1[ihist]->AddEntry(h[ihist][1], "Reference", "L"); h[ihist][0]->Draw("e0same"); - leg1[ihist]->AddEntry(h[ihist][0],"Test file","P"); - - leg1[ihist]->Draw(); + leg1[ihist]->AddEntry(h[ihist][0], "Test file", "P"); + + leg1[ihist]->Draw(); } - - TCanvas *c2 = new TCanvas ("c2","masses",600,600); - c2->Divide(2,2); - TLegend *leg2[nhist]; + + TCanvas* c2 = new TCanvas("c2", "masses", 600, 600); + c2->Divide(2, 2); + TLegend* leg2[nhist]; for (int ihist = 4; ihist < nhist; ++ihist) { - c2->cd(ihist-3); - if (logy[ihist]) gPad->SetLogy(); - leg2[ihist] = new TLegend (leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); + c2->cd(ihist - 3); + if (logy[ihist]) + gPad->SetLogy(); + leg2[ihist] = new TLegend(leg_left[ihist], 0.7, leg_right[ihist], 0.9, legtitle); h[ihist][1]->Draw("hist"); - leg2[ihist]->AddEntry(h[ihist][1],"Reference","L"); + leg2[ihist]->AddEntry(h[ihist][1], "Reference", "L"); h[ihist][0]->Draw("e0same"); - leg2[ihist]->AddEntry(h[ihist][0],"Test file","P"); - - leg2[ihist]->Draw(); - } - - // --------------- save to pdf file ---------------------------------- - - std::string epsFile1( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_1" ) + std::string( ".eps" ) ) ; - std::string pdfFile1( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_1" ) + std::string( ".pdf" ) ) ; - //std::string cFile1 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_1" ) + std::string( ".C" ) ) ; - c1->Print( epsFile1.c_str() ) ; - c1->Print( pdfFile1.c_str() ) ; - //c1->Print( cFile1.c_str() ) ; + leg2[ihist]->AddEntry(h[ihist][0], "Test file", "P"); - std::string epsFile2( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + std::string( ".eps" ) ) ; - std::string pdfFile2( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + std::string( ".pdf" ) ) ; - //std::string cFile2 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + std::string( ".C" ) ) ; - c2->Print( epsFile2.c_str() ) ; - c2->Print( pdfFile2.c_str() ) ; - //c2->Print( cFile2.c_str() ) ; + leg2[ihist]->Draw(); + } + // --------------- save to pdf file ---------------------------------- + std::string epsFile1(std::string("../plots/") + std::string(outfilename) + std::string("_1") + std::string(".eps")); + std::string pdfFile1(std::string("../plots/") + std::string(outfilename) + std::string("_1") + std::string(".pdf")); + // std::string cFile1 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_1" ) + + // std::string( ".C" ) ) ; + c1->Print(epsFile1.c_str()); + c1->Print(pdfFile1.c_str()); + // c1->Print( cFile1.c_str() ) ; + std::string epsFile2(std::string("../plots/") + std::string(outfilename) + std::string("_2") + std::string(".eps")); + std::string pdfFile2(std::string("../plots/") + std::string(outfilename) + std::string("_2") + std::string(".pdf")); + // std::string cFile2 ( std::string( "../plots/" ) + std::string( outfilename ) + std::string( "_2" ) + + // std::string( ".C" ) ) ; + c2->Print(epsFile2.c_str()); + c2->Print(pdfFile2.c_str()); + // c2->Print( cFile2.c_str() ) ; } diff --git a/kinfit/macros/rootlogon.C b/kinfit/macros/rootlogon.C index 9fa17f1..badfc25 100644 --- a/kinfit/macros/rootlogon.C +++ b/kinfit/macros/rootlogon.C @@ -1,86 +1,84 @@ { -//ild TStyle -TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); - -//set the background color to white -ildStyle->SetFillColor(10); -ildStyle->SetFrameFillColor(10); -ildStyle->SetCanvasColor(10); -ildStyle->SetPadColor(10); -ildStyle->SetTitleFillColor(0); -ildStyle->SetStatColor(10); - -//dont put a colored frame around the plots -ildStyle->SetFrameBorderMode(0); -ildStyle->SetCanvasBorderMode(0); -ildStyle->SetPadBorderMode(0); -ildStyle->SetLegendBorderSize(0); - -//use the primary color palette -ildStyle->SetPalette(1,0); - -//set the default line color for a histogram to be black -ildStyle->SetHistLineColor(kBlack); - -//set the default line color for a fit function to be red -ildStyle->SetFuncColor(kBlue); - -//make the axis labels black -ildStyle->SetLabelColor(kBlack,"xyz"); - -//set the default title color to be black -ildStyle->SetTitleColor(kBlack); - -//set the margins -ildStyle->SetPadBottomMargin(0.18); -ildStyle->SetPadTopMargin(0.08); -ildStyle->SetPadRightMargin(0.08); -ildStyle->SetPadLeftMargin(0.17); - -//set axis label and title text sizes -ildStyle->SetLabelFont(42,"xyz"); -ildStyle->SetLabelSize(0.06,"xyz"); -ildStyle->SetLabelOffset(0.015,"xyz"); -ildStyle->SetTitleFont(42,"xyz"); -ildStyle->SetTitleSize(0.07,"xyz"); -ildStyle->SetTitleOffset(1.1,"yz"); -ildStyle->SetTitleOffset(1.0,"x"); -ildStyle->SetStatFont(42); -ildStyle->SetStatFontSize(0.07); -ildStyle->SetTitleBorderSize(0); -ildStyle->SetStatBorderSize(0); -ildStyle->SetTextFont(42); - -//set line widths -ildStyle->SetFrameLineWidth(2); -ildStyle->SetFuncWidth(2); -ildStyle->SetHistLineWidth(2); - -//set the number of divisions to show -ildStyle->SetNdivisions(506, "xy"); - -//turn off xy grids -ildStyle->SetPadGridX(0); -ildStyle->SetPadGridY(0); - -//set the tick mark style -ildStyle->SetPadTickX(1); -ildStyle->SetPadTickY(1); - -//turn off stats -ildStyle->SetOptStat(0); -ildStyle->SetOptFit(0); - -//marker settings -ildStyle->SetMarkerStyle(20); -ildStyle->SetMarkerSize(0.7); -ildStyle->SetLineWidth(2); - -//done -ildStyle->cd(); -gROOT->ForceStyle(); -gStyle->ls(); - + // ild TStyle + TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); + + // set the background color to white + ildStyle->SetFillColor(10); + ildStyle->SetFrameFillColor(10); + ildStyle->SetCanvasColor(10); + ildStyle->SetPadColor(10); + ildStyle->SetTitleFillColor(0); + ildStyle->SetStatColor(10); + + // dont put a colored frame around the plots + ildStyle->SetFrameBorderMode(0); + ildStyle->SetCanvasBorderMode(0); + ildStyle->SetPadBorderMode(0); + ildStyle->SetLegendBorderSize(0); + + // use the primary color palette + ildStyle->SetPalette(1, 0); + + // set the default line color for a histogram to be black + ildStyle->SetHistLineColor(kBlack); + + // set the default line color for a fit function to be red + ildStyle->SetFuncColor(kBlue); + + // make the axis labels black + ildStyle->SetLabelColor(kBlack, "xyz"); + + // set the default title color to be black + ildStyle->SetTitleColor(kBlack); + + // set the margins + ildStyle->SetPadBottomMargin(0.18); + ildStyle->SetPadTopMargin(0.08); + ildStyle->SetPadRightMargin(0.08); + ildStyle->SetPadLeftMargin(0.17); + + // set axis label and title text sizes + ildStyle->SetLabelFont(42, "xyz"); + ildStyle->SetLabelSize(0.06, "xyz"); + ildStyle->SetLabelOffset(0.015, "xyz"); + ildStyle->SetTitleFont(42, "xyz"); + ildStyle->SetTitleSize(0.07, "xyz"); + ildStyle->SetTitleOffset(1.1, "yz"); + ildStyle->SetTitleOffset(1.0, "x"); + ildStyle->SetStatFont(42); + ildStyle->SetStatFontSize(0.07); + ildStyle->SetTitleBorderSize(0); + ildStyle->SetStatBorderSize(0); + ildStyle->SetTextFont(42); + + // set line widths + ildStyle->SetFrameLineWidth(2); + ildStyle->SetFuncWidth(2); + ildStyle->SetHistLineWidth(2); + + // set the number of divisions to show + ildStyle->SetNdivisions(506, "xy"); + + // turn off xy grids + ildStyle->SetPadGridX(0); + ildStyle->SetPadGridY(0); + + // set the tick mark style + ildStyle->SetPadTickX(1); + ildStyle->SetPadTickY(1); + + // turn off stats + ildStyle->SetOptStat(0); + ildStyle->SetOptFit(0); + + // marker settings + ildStyle->SetMarkerStyle(20); + ildStyle->SetMarkerSize(0.7); + ildStyle->SetLineWidth(2); + + // done + ildStyle->cd(); + gROOT->ForceStyle(); + gStyle->ls(); } - diff --git a/pi0/include/pi0Tree.h b/pi0/include/pi0Tree.h index 434653d..a0c6810 100644 --- a/pi0/include/pi0Tree.h +++ b/pi0/include/pi0Tree.h @@ -3,50 +3,48 @@ #include +#include "UTIL/LCIterator.h" +#include "UTIL/LCRelationNavigator.h" +#include "UTIL/LCTrackerConf.h" +#include "UTIL/Operators.h" #include -#include #include #include +#include #include -#include "UTIL/LCRelationNavigator.h" -#include "UTIL/LCIterator.h" -#include "UTIL/Operators.h" #include -#include "UTIL/LCTrackerConf.h" #include // STUFF needed for GEAR -#include +#include "gear/BField.h" #include -#include #include -#include "gear/BField.h" +#include +#include #include #include -using namespace lcio ; -using namespace marlin ; -using namespace std ; +using namespace lcio; +using namespace marlin; +using namespace std; /** Pi0Tree processor * checks correctness of found pi0 * authors: Jenny List -*/ + */ class Pi0Tree : public Processor { - - public: - - virtual Processor* newProcessor() { return new Pi0Tree ; } - - Pi0Tree(const Pi0Tree&) = delete ; - Pi0Tree& operator=(const Pi0Tree&) = delete ; +public: + virtual Processor* newProcessor() { return new Pi0Tree; } + + Pi0Tree(const Pi0Tree&) = delete; + Pi0Tree& operator=(const Pi0Tree&) = delete; + + Pi0Tree(); - Pi0Tree() ; - /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ @@ -54,72 +52,58 @@ class Pi0Tree : public Processor { /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; - + virtual void processRunHeader(LCRunHeader* run); + /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; - - - virtual void check( LCEvent * evt ) ; - - - /** Called after data processing for clean up. - */ - virtual void end() ; - - + virtual void processEvent(LCEvent* evt); + virtual void check(LCEvent* evt); - protected: + /** Called after data processing for clean up. + */ + virtual void end(); +protected: /** Input collection name. */ - std::string _trueToReco {}; - std::string _recoToTrue {}; - std::string _mcParticleCollectionName {}; - std::string _gammaGammaParticleCollectionName {}; + std::string _trueToReco{}; + std::string _recoToTrue{}; + std::string _mcParticleCollectionName{}; + std::string _gammaGammaParticleCollectionName{}; - int nEvt {}; + int nEvt{}; - float _bField {}; - - - private: + float _bField{}; +private: // declaration of trees - TTree *pi0Tree {}; - int nMCPi0{}; - + TTree* pi0Tree{}; + int nMCPi0{}; + vector trueE{}; vector trueP{}; - vector truePt {}; - vector trueTheta {}; - vector truePhi {}; - vector truePDG{}; - vector trueMother{}; - vector daughtersSeen{}; // found photons? - vector isSeen{}; // both photons point to PFOs ? - vector isSeenAsPhotons{}; // both photons point to photon PFOs? - vector weightToPhotons{}; // sum of weigths - - int nRecoPi0{}; - vector nTruePhotons{}; - vector nTrueMeson{}; - vector isTrue{}; // 1= one photon from true meson 2= both photons from true meson - vector recoE{}; // energy of gammagamma candidate (after constrained fit) - vector pfoE{}; // energy of the two photons - vector trueEofSeen{}; // energy of the true meson + vector truePt{}; + vector trueTheta{}; + vector truePhi{}; + vector truePDG{}; + vector trueMother{}; + vector daughtersSeen{}; // found photons? + vector isSeen{}; // both photons point to PFOs ? + vector isSeenAsPhotons{}; // both photons point to photon PFOs? + vector weightToPhotons{}; // sum of weigths + + int nRecoPi0{}; + vector nTruePhotons{}; + vector nTrueMeson{}; + vector isTrue{}; // 1= one photon from true meson 2= both photons from true meson + vector recoE{}; // energy of gammagamma candidate (after constrained fit) + vector pfoE{}; // energy of the two photons + vector trueEofSeen{}; // energy of the true meson vector recoMass{}; vector pfoMass{}; vector trueMassofSeen{}; vector truePDGofSeen{}; - - -} ; - +}; #endif - - - diff --git a/pi0/macros/plotERes.C b/pi0/macros/plotERes.C index 60e7044..aa32676 100644 --- a/pi0/macros/plotERes.C +++ b/pi0/macros/plotERes.C @@ -1,13 +1,12 @@ #include -#include "TTree.h" #include "TFile.h" #include "TH1F.h" #include "TString.h" +#include "TTree.h" using namespace std; - void plotERes(const char* _filename) { gROOT->SetStyle("ildStyle"); ildStyle->SetOptTitle(0); @@ -19,85 +18,84 @@ void plotERes(const char* _filename) { ildStyle->SetCanvasColor(0); ildStyle->SetTitleColor(1); ildStyle->SetStatColor(0); -// ildStyle->SetOptStat(1110010); + // ildStyle->SetOptStat(1110010); ildStyle->SetOptStat(1110); ildStyle->SetOptFit(111); - + ildStyle->SetPadBottomMargin(0.15); ildStyle->SetPadTopMargin(0.10); ildStyle->SetPadRightMargin(0.025); ildStyle->SetPadLeftMargin(0.1); - + ildStyle->SetMarkerStyle(20); ildStyle->SetMarkerSize(0.625); - TFile *treefile = new TFile(_filename); - TTree *tree = (TTree*) treefile->Get("pi0Tree"); - - TH1F *h1 = new TH1F("h1","h1;(E_PFO-E_truth)/E_truth[%], correct ggp's",100,-30.,50.); - TH1F *h2 = new TH1F("h2","h2;(E_FIT-E_truth)/E_truth[%], correct ggp's",100,-30.,50.); - TH1F *h3 = new TH1F("h3","h3;(E_PFO-E_truth)/E_truth[%], all ggp's",100,-30.,50.); - TH1F *h4 = new TH1F("h4","h4;(E_FIT-E_truth)/E_truth[%], all ggp's",100,-30.,50.); - TH1F *h5 = new TH1F("h5","h5;(E_PFO-E_truth)/E_truth[%], wrong ggp's",100,-30.,50.); - TH1F *h6 = new TH1F("h6","h6;(E_FIT-E_truth)/E_truth[%], wrong ggp's",100,-30.,50.); - - TCanvas *c1 = new TCanvas("c1","correct",600,600); - c1->Divide(1,2); + TFile* treefile = new TFile(_filename); + TTree* tree = (TTree*)treefile->Get("pi0Tree"); + + TH1F* h1 = new TH1F("h1", "h1;(E_PFO-E_truth)/E_truth[%], correct ggp's", 100, -30., 50.); + TH1F* h2 = new TH1F("h2", "h2;(E_FIT-E_truth)/E_truth[%], correct ggp's", 100, -30., 50.); + TH1F* h3 = new TH1F("h3", "h3;(E_PFO-E_truth)/E_truth[%], all ggp's", 100, -30., 50.); + TH1F* h4 = new TH1F("h4", "h4;(E_FIT-E_truth)/E_truth[%], all ggp's", 100, -30., 50.); + TH1F* h5 = new TH1F("h5", "h5;(E_PFO-E_truth)/E_truth[%], wrong ggp's", 100, -30., 50.); + TH1F* h6 = new TH1F("h6", "h6;(E_FIT-E_truth)/E_truth[%], wrong ggp's", 100, -30., 50.); + + TCanvas* c1 = new TCanvas("c1", "correct", 600, 600); + c1->Divide(1, 2); c1->cd(1); - tree->Draw("(pfoE-trueEofSeen)/trueEofSeen*100.>>h1","isTrue"); + tree->Draw("(pfoE-trueEofSeen)/trueEofSeen*100.>>h1", "isTrue"); h1->SetLineColor(1); h1->SetMaximum(300); - h1->Fit("gaus","ME","",-15.,15.); + h1->Fit("gaus", "ME", "", -15., 15.); c1->cd(2); - tree->Draw("(recoE-trueEofSeen)/trueEofSeen*100.>>h2","isTrue"); + tree->Draw("(recoE-trueEofSeen)/trueEofSeen*100.>>h2", "isTrue"); h2->SetLineColor(4); h2->SetMaximum(300); - h2->Fit("gaus","ME","",-5.,5.); - + h2->Fit("gaus", "ME", "", -5., 5.); + TString outfile1 = "../Results/pi0cand_e2e2h_Eres_correctGGParticles"; - //cout << outfile << endl; - c1->Print(TString(outfile1+".eps")); - c1->Print(TString(outfile1+".ps")); - c1->Print(TString(outfile1+".pdf")); + // cout << outfile << endl; + c1->Print(TString(outfile1 + ".eps")); + c1->Print(TString(outfile1 + ".ps")); + c1->Print(TString(outfile1 + ".pdf")); - TCanvas *c2 = new TCanvas("c2","all",600,600); - c2->Divide(1,2); + TCanvas* c2 = new TCanvas("c2", "all", 600, 600); + c2->Divide(1, 2); c2->cd(1); - tree->Draw("(pfoE-trueEofSeen)/trueEofSeen*100.>>h3",""); + tree->Draw("(pfoE-trueEofSeen)/trueEofSeen*100.>>h3", ""); h3->SetLineColor(1); h3->SetMaximum(500); - h3->Fit("gaus","ME","",-10.,10.); + h3->Fit("gaus", "ME", "", -10., 10.); c2->cd(2); - tree->Draw("(recoE-trueEofSeen)/trueEofSeen*100.>>h4",""); + tree->Draw("(recoE-trueEofSeen)/trueEofSeen*100.>>h4", ""); h4->SetLineColor(4); h4->SetMaximum(500); - h4->Fit("gaus","ME","",-5.,5.); + h4->Fit("gaus", "ME", "", -5., 5.); TString outfile2 = "../Results/pi0cand_e2e2h_Eres_allGGParticles"; - //cout << outfile << endl; - c2->Print(TString(outfile2+".eps")); - c2->Print(TString(outfile2+".ps")); - c2->Print(TString(outfile2+".pdf")); + // cout << outfile << endl; + c2->Print(TString(outfile2 + ".eps")); + c2->Print(TString(outfile2 + ".ps")); + c2->Print(TString(outfile2 + ".pdf")); - TCanvas *c3 = new TCanvas("c3","wrong",600,600); - c3->Divide(1,2); + TCanvas* c3 = new TCanvas("c3", "wrong", 600, 600); + c3->Divide(1, 2); c3->cd(1); - tree->Draw("(pfoE-trueEofSeen)/trueEofSeen*100.>>h5","!isTrue"); + tree->Draw("(pfoE-trueEofSeen)/trueEofSeen*100.>>h5", "!isTrue"); h5->SetLineColor(1); h5->SetMaximum(250); - h5->Fit("gaus","ME","",-20.,20.); + h5->Fit("gaus", "ME", "", -20., 20.); c3->cd(2); - tree->Draw("(recoE-trueEofSeen)/trueEofSeen*100.>>h6","!isTrue"); + tree->Draw("(recoE-trueEofSeen)/trueEofSeen*100.>>h6", "!isTrue"); h6->SetLineColor(4); h6->SetMaximum(250); - h6->Fit("gaus","ME","",-20.,20.); + h6->Fit("gaus", "ME", "", -20., 20.); TString outfile3 = "../Results/pi0cand_e2e2h_Eres_wrongGGParticles"; - //cout << outfile << endl; - c3->Print(TString(outfile3+".eps")); - c3->Print(TString(outfile3+".ps")); - c3->Print(TString(outfile3+".pdf")); + // cout << outfile << endl; + c3->Print(TString(outfile3 + ".eps")); + c3->Print(TString(outfile3 + ".ps")); + c3->Print(TString(outfile3 + ".pdf")); return; - } diff --git a/pi0/macros/plotEffi.C b/pi0/macros/plotEffi.C index 5c81e69..7771f7d 100644 --- a/pi0/macros/plotEffi.C +++ b/pi0/macros/plotEffi.C @@ -1,13 +1,12 @@ #include -#include "TTree.h" #include "TFile.h" #include "TH1F.h" #include "TString.h" +#include "TTree.h" using namespace std; - void plotEffi(const char* _filename) { gROOT->SetStyle("ildStyle"); ildStyle->SetOptTitle(0); @@ -19,64 +18,61 @@ void plotEffi(const char* _filename) { ildStyle->SetCanvasColor(0); ildStyle->SetTitleColor(1); ildStyle->SetStatColor(0); -// ildStyle->SetOptStat(1110010); + // ildStyle->SetOptStat(1110010); ildStyle->SetOptStat(0); ildStyle->SetOptFit(111); - + ildStyle->SetPadBottomMargin(0.175); ildStyle->SetPadTopMargin(0.10); ildStyle->SetPadRightMargin(0.025); ildStyle->SetPadLeftMargin(0.12); - + ildStyle->SetMarkerStyle(20); ildStyle->SetMarkerSize(0.625); - TFile *treefile = new TFile(_filename); - TTree *tree = (TTree*) treefile->Get("pi0Tree"); - - TH1F *h1 = new TH1F("h1","h1;E[GeV], seen", 10,0.,50.); - TH1F *h2 = new TH1F("h2","h2;E[GeV], all", 10,0.,50.); - TH1F *h3 = new TH1F("h3","h3;E_{#pi^{0}/#eta/#eta'} [GeV];efficiency", 10,0.,50.); -// TH1F *h3 = new TH1F("h3","h3;E_{#pi^{0}cand.} [GeV];efficiency", 10,0.,50.); - h3->Sumw2(); + TFile* treefile = new TFile(_filename); + TTree* tree = (TTree*)treefile->Get("pi0Tree"); + + TH1F* h1 = new TH1F("h1", "h1;E[GeV], seen", 10, 0., 50.); + TH1F* h2 = new TH1F("h2", "h2;E[GeV], all", 10, 0., 50.); + TH1F* h3 = new TH1F("h3", "h3;E_{#pi^{0}/#eta/#eta'} [GeV];efficiency", 10, 0., 50.); + // TH1F *h3 = new TH1F("h3","h3;E_{#pi^{0}cand.} [GeV];efficiency", 10,0.,50.); + h3->Sumw2(); h3->GetXaxis()->SetTitleOffset(1.2); h3->GetYaxis()->SetTitleOffset(0.75); h3->SetMaximum(0.75); - - TH1F *h11 = new TH1F("h11","h11;E[GeV], seen", 12,0.,12.); - TH1F *h12 = new TH1F("h12","h12;E[GeV], all", 12,0.,12.); -// TH1F *h13 = new TH1F("h13","h13;E_{#pi^{0}cand.} [GeV];efficiency", 12,0.,12.); - TH1F *h13 = new TH1F("h13","h13;E_{#pi^{0}/#eta/#eta'} [GeV];efficiency", 12,0.,12.); - h13->Sumw2(); + + TH1F* h11 = new TH1F("h11", "h11;E[GeV], seen", 12, 0., 12.); + TH1F* h12 = new TH1F("h12", "h12;E[GeV], all", 12, 0., 12.); + // TH1F *h13 = new TH1F("h13","h13;E_{#pi^{0}cand.} [GeV];efficiency", 12,0.,12.); + TH1F* h13 = new TH1F("h13", "h13;E_{#pi^{0}/#eta/#eta'} [GeV];efficiency", 12, 0., 12.); + h13->Sumw2(); h13->GetXaxis()->SetTitleOffset(1.2); h13->GetYaxis()->SetTitleOffset(0.75); h13->SetMaximum(0.75); - + // ``findable'' mesons: both photons reconstructed as one photon each - tree->Draw("pfoE>>h1","isTrue"); - tree->Draw("trueE>>h2","isSeenAsPhotons==2&&weightToPhotons>1.5&&abs(cos(trueTheta))<0.995"); - h3->Divide(h1,h2,1,1,"B"); - h3->Fit("pol0","ME","",5.,50.); - - tree->Draw("pfoE>>h11","isTrue"); - tree->Draw("trueE>>h12","isSeenAsPhotons==2&&weightToPhotons>1.5&&abs(cos(trueTheta))<0.995"); - h13->Divide(h11,h12,1,1,"B"); + tree->Draw("pfoE>>h1", "isTrue"); + tree->Draw("trueE>>h2", "isSeenAsPhotons==2&&weightToPhotons>1.5&&abs(cos(trueTheta))<0.995"); + h3->Divide(h1, h2, 1, 1, "B"); + h3->Fit("pol0", "ME", "", 5., 50.); + + tree->Draw("pfoE>>h11", "isTrue"); + tree->Draw("trueE>>h12", "isSeenAsPhotons==2&&weightToPhotons>1.5&&abs(cos(trueTheta))<0.995"); + h13->Divide(h11, h12, 1, 1, "B"); - - TCanvas *c1 = new TCanvas("c1","effi",600,600); - c1->Divide(1,2); + TCanvas* c1 = new TCanvas("c1", "effi", 600, 600); + c1->Divide(1, 2); c1->cd(1); h3->Draw("E0"); c1->cd(2); h13->Draw("E0"); - - TString outfile1 = "../Results/pi0_e2e2h_Effi_correctGGParticles"; - //cout << outfile << endl; - c1->Print(TString(outfile1+".eps")); - c1->Print(TString(outfile1+".ps")); - c1->Print(TString(outfile1+".pdf")); + TString outfile1 = "../Results/pi0_e2e2h_Effi_correctGGParticles"; + // cout << outfile << endl; + c1->Print(TString(outfile1 + ".eps")); + c1->Print(TString(outfile1 + ".ps")); + c1->Print(TString(outfile1 + ".pdf")); return; - } diff --git a/pi0/macros/rootlogon.C b/pi0/macros/rootlogon.C index 5891074..c0987f8 100644 --- a/pi0/macros/rootlogon.C +++ b/pi0/macros/rootlogon.C @@ -1,86 +1,84 @@ { -//ild TStyle -TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); - -//set the background color to white -ildStyle->SetFillColor(10); -ildStyle->SetFrameFillColor(10); -ildStyle->SetCanvasColor(10); -ildStyle->SetPadColor(10); -ildStyle->SetTitleFillColor(0); -ildStyle->SetStatColor(10); - -//dont put a colored frame around the plots -ildStyle->SetFrameBorderMode(0); -ildStyle->SetCanvasBorderMode(0); -ildStyle->SetPadBorderMode(0); -ildStyle->SetLegendBorderSize(0); - -//use the primary color palette -ildStyle->SetPalette(1,0); - -//set the default line color for a histogram to be black -ildStyle->SetHistLineColor(kBlack); - -//set the default line color for a fit function to be red -ildStyle->SetFuncColor(kRed); - -//make the axis labels black -ildStyle->SetLabelColor(kBlack,"xyz"); - -//set the default title color to be black -ildStyle->SetTitleColor(kBlack); - -//set the margins -ildStyle->SetPadBottomMargin(0.18); -ildStyle->SetPadTopMargin(0.08); -ildStyle->SetPadRightMargin(0.08); -ildStyle->SetPadLeftMargin(0.17); - -//set axis label and title text sizes -ildStyle->SetLabelFont(42,"xyz"); -ildStyle->SetLabelSize(0.06,"xyz"); -ildStyle->SetLabelOffset(0.015,"xyz"); -ildStyle->SetTitleFont(42,"xyz"); -ildStyle->SetTitleSize(0.07,"xyz"); -ildStyle->SetTitleOffset(1.1,"yz"); -ildStyle->SetTitleOffset(1.0,"x"); -ildStyle->SetStatFont(42); -ildStyle->SetStatFontSize(0.07); -ildStyle->SetTitleBorderSize(0); -ildStyle->SetStatBorderSize(0); -ildStyle->SetTextFont(42); - -//set line widths -ildStyle->SetFrameLineWidth(2); -ildStyle->SetFuncWidth(2); -ildStyle->SetHistLineWidth(2); - -//set the number of divisions to show -ildStyle->SetNdivisions(506, "xy"); - -//turn off xy grids -ildStyle->SetPadGridX(0); -ildStyle->SetPadGridY(0); - -//set the tick mark style -ildStyle->SetPadTickX(1); -ildStyle->SetPadTickY(1); - -//turn off stats -ildStyle->SetOptStat(0); -ildStyle->SetOptFit(0); - -//marker settings -ildStyle->SetMarkerStyle(20); -ildStyle->SetMarkerSize(0.7); -ildStyle->SetLineWidth(2); - -//done -ildStyle->cd(); -gROOT->ForceStyle(); -gStyle->ls(); - + // ild TStyle + TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); + + // set the background color to white + ildStyle->SetFillColor(10); + ildStyle->SetFrameFillColor(10); + ildStyle->SetCanvasColor(10); + ildStyle->SetPadColor(10); + ildStyle->SetTitleFillColor(0); + ildStyle->SetStatColor(10); + + // dont put a colored frame around the plots + ildStyle->SetFrameBorderMode(0); + ildStyle->SetCanvasBorderMode(0); + ildStyle->SetPadBorderMode(0); + ildStyle->SetLegendBorderSize(0); + + // use the primary color palette + ildStyle->SetPalette(1, 0); + + // set the default line color for a histogram to be black + ildStyle->SetHistLineColor(kBlack); + + // set the default line color for a fit function to be red + ildStyle->SetFuncColor(kRed); + + // make the axis labels black + ildStyle->SetLabelColor(kBlack, "xyz"); + + // set the default title color to be black + ildStyle->SetTitleColor(kBlack); + + // set the margins + ildStyle->SetPadBottomMargin(0.18); + ildStyle->SetPadTopMargin(0.08); + ildStyle->SetPadRightMargin(0.08); + ildStyle->SetPadLeftMargin(0.17); + + // set axis label and title text sizes + ildStyle->SetLabelFont(42, "xyz"); + ildStyle->SetLabelSize(0.06, "xyz"); + ildStyle->SetLabelOffset(0.015, "xyz"); + ildStyle->SetTitleFont(42, "xyz"); + ildStyle->SetTitleSize(0.07, "xyz"); + ildStyle->SetTitleOffset(1.1, "yz"); + ildStyle->SetTitleOffset(1.0, "x"); + ildStyle->SetStatFont(42); + ildStyle->SetStatFontSize(0.07); + ildStyle->SetTitleBorderSize(0); + ildStyle->SetStatBorderSize(0); + ildStyle->SetTextFont(42); + + // set line widths + ildStyle->SetFrameLineWidth(2); + ildStyle->SetFuncWidth(2); + ildStyle->SetHistLineWidth(2); + + // set the number of divisions to show + ildStyle->SetNdivisions(506, "xy"); + + // turn off xy grids + ildStyle->SetPadGridX(0); + ildStyle->SetPadGridY(0); + + // set the tick mark style + ildStyle->SetPadTickX(1); + ildStyle->SetPadTickY(1); + + // turn off stats + ildStyle->SetOptStat(0); + ildStyle->SetOptFit(0); + + // marker settings + ildStyle->SetMarkerStyle(20); + ildStyle->SetMarkerSize(0.7); + ildStyle->SetLineWidth(2); + + // done + ildStyle->cd(); + gROOT->ForceStyle(); + gStyle->ls(); } - diff --git a/singlePhotonVal/include/validateDST_SinglePhoton.h b/singlePhotonVal/include/validateDST_SinglePhoton.h index f83f484..6a4941b 100644 --- a/singlePhotonVal/include/validateDST_SinglePhoton.h +++ b/singlePhotonVal/include/validateDST_SinglePhoton.h @@ -7,62 +7,64 @@ #include "TH2F.h" #include "TH3F.h" -using namespace marlin ; - +using namespace marlin; class validateDST_SinglePhotonProcessor : public Processor { - - public: - - virtual Processor* newProcessor() { return new validateDST_SinglePhotonProcessor ; } - validateDST_SinglePhotonProcessor( const validateDST_SinglePhotonProcessor&) = delete ; - validateDST_SinglePhotonProcessor& operator=(const validateDST_SinglePhotonProcessor& ) = delete; +public: + virtual Processor* newProcessor() { return new validateDST_SinglePhotonProcessor; } + + validateDST_SinglePhotonProcessor(const validateDST_SinglePhotonProcessor&) = delete; + validateDST_SinglePhotonProcessor& operator=(const validateDST_SinglePhotonProcessor&) = delete; + + validateDST_SinglePhotonProcessor(); - validateDST_SinglePhotonProcessor() ; - /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ - virtual void init() ; - + virtual void init(); + /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; - + virtual void processRunHeader(LCRunHeader* run); + /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; + virtual void processEvent(LCEvent* evt); + + virtual void check(LCEvent* evt); - virtual void check( LCEvent * evt ) ; - /** Called after data processing for clean up. */ - virtual void end() ; - - - protected: + virtual void end(); +protected: StringVec _infiles{}; std::string _outfile{}; - TFile* _fout = nullptr ; - - TH1F* _h_allMC_en = nullptr ; - TH1F* _h_allMC_phi = nullptr ; - TH1F* _h_allMC_costh = nullptr ; - TH2F* _h_allMC_endcapxy = nullptr ; - TH2F* _h_mcDecPt = nullptr ; - - std::map < int, std::map < int, TH1F* > > enHistos{}; - std::map < int, std::map < int, TH2F* > > enHistos2d{}; - - enum{ivar_npfo=0, ivar_npfo22, ivar_npfoCosth, ivar_enCosth, ivar_totenCosth, ivar_barenPhi, ivar_bartotenPhi, - ivar_posendEnX, ivar_posendEnY, ivar_negendEnX, ivar_negendEnY}; - + TFile* _fout = nullptr; + + TH1F* _h_allMC_en = nullptr; + TH1F* _h_allMC_phi = nullptr; + TH1F* _h_allMC_costh = nullptr; + TH2F* _h_allMC_endcapxy = nullptr; + TH2F* _h_mcDecPt = nullptr; + + std::map> enHistos{}; + std::map> enHistos2d{}; + + enum { + ivar_npfo = 0, + ivar_npfo22, + ivar_npfoCosth, + ivar_enCosth, + ivar_totenCosth, + ivar_barenPhi, + ivar_bartotenPhi, + ivar_posendEnX, + ivar_posendEnY, + ivar_negendEnX, + ivar_negendEnY + }; }; - #endif - - - diff --git a/trackerHitCtr/include/TrackerHitCounter.h b/trackerHitCtr/include/TrackerHitCounter.h index 96d9aba..2c6756e 100644 --- a/trackerHitCtr/include/TrackerHitCounter.h +++ b/trackerHitCtr/include/TrackerHitCounter.h @@ -1,8 +1,8 @@ #ifndef TrackerHitCounter_h #define TrackerHitCounter_h 1 -#include "marlin/Processor.h" #include "DD4hep/DD4hepUnits.h" +#include "marlin/Processor.h" #include /** TrackerHitCounter: Marlin processor that counts SimTrackerHits in tracker detector @@ -13,113 +13,103 @@ class LayerHitCounter { public: - LayerHitCounter() : - _area(1.), _nHits(0), - _nRuns(0), _nHitsRun(0), _mu2nHitsRun(0), - _nEvents(0), _nHitsEvent(0), _mu2nHitsEvent(0) - - {} - - LayerHitCounter(double area) : - _area(area), _nHits(0), - _nRuns(0), _nHitsRun(0), _mu2nHitsRun(0), - _nEvents(0), _nHitsEvent(0), _mu2nHitsEvent(0) - {} - - virtual ~LayerHitCounter() {} - - int getNHits() const { return _nHits; } - double getHitsPerCm2() const { return double(_nHits)/(_area/dd4hep::cm2); } - - double getHitsPerRun() const { return double(_nHits)/_nRuns; } - double getStDevHitsPerRun() const { return sqrt(_mu2nHitsRun/_nRuns - pow(_nHits/_nRuns, 2)); } - double getHitsPerCm2PerRun() const { return getHitsPerRun()/(_area/dd4hep::cm2); } - double getStDevHitsPerCm2PerRun() const { return getStDevHitsPerRun()/(_area/dd4hep::cm2); } - - double getHitsPerEvent() const { return double(_nHits)/_nEvents; } - double getStDevHitsPerEvent() const { return sqrt(_mu2nHitsEvent/_nEvents - pow(_nHits/_nEvents, 2)); } - double getHitsPerCm2PerEvent() const { return getHitsPerEvent()/(_area/dd4hep::cm2); } - double getStDevHitsPerCm2PerEvent() const { return getStDevHitsPerEvent()/(_area/dd4hep::cm2); } - - bool isAreaAvailable() const { return (_area > 0.); } - - void addHit() { _nHits++; _nHitsRun++; _nHitsEvent++; } - - void markRun() { - _nRuns++; - _mu2nHitsRun += _nHitsRun*_nHitsRun; - _nHitsRun = 0; - /* streamlog_out(DEBUG) << "LayerHitCounter marking Run #" << _nRuns - << ". Nhits = " << _nHits << ".\n"; */ - } - void markEvent() { - _nEvents++; - _mu2nHitsEvent+= _nHitsEvent*_nHitsEvent; - _nHitsEvent = 0; - /* streamlog_out(DEBUG) << "LayerHitCounter marking Run #" << _nRuns - << ". Nhits = " << _nHits << ".\n"; */ - } + LayerHitCounter() + : _area(1.), _nHits(0), _nRuns(0), _nHitsRun(0), _mu2nHitsRun(0), _nEvents(0), _nHitsEvent(0), _mu2nHitsEvent(0) + + {} + + LayerHitCounter(double area) + : _area(area), _nHits(0), _nRuns(0), _nHitsRun(0), _mu2nHitsRun(0), _nEvents(0), _nHitsEvent(0), + _mu2nHitsEvent(0) {} + + virtual ~LayerHitCounter() {} + + int getNHits() const { return _nHits; } + double getHitsPerCm2() const { return double(_nHits) / (_area / dd4hep::cm2); } + + double getHitsPerRun() const { return double(_nHits) / _nRuns; } + double getStDevHitsPerRun() const { return sqrt(_mu2nHitsRun / _nRuns - pow(_nHits / _nRuns, 2)); } + double getHitsPerCm2PerRun() const { return getHitsPerRun() / (_area / dd4hep::cm2); } + double getStDevHitsPerCm2PerRun() const { return getStDevHitsPerRun() / (_area / dd4hep::cm2); } + + double getHitsPerEvent() const { return double(_nHits) / _nEvents; } + double getStDevHitsPerEvent() const { return sqrt(_mu2nHitsEvent / _nEvents - pow(_nHits / _nEvents, 2)); } + double getHitsPerCm2PerEvent() const { return getHitsPerEvent() / (_area / dd4hep::cm2); } + double getStDevHitsPerCm2PerEvent() const { return getStDevHitsPerEvent() / (_area / dd4hep::cm2); } + + bool isAreaAvailable() const { return (_area > 0.); } + + void addHit() { + _nHits++; + _nHitsRun++; + _nHitsEvent++; + } + + void markRun() { + _nRuns++; + _mu2nHitsRun += _nHitsRun * _nHitsRun; + _nHitsRun = 0; + /* streamlog_out(DEBUG) << "LayerHitCounter marking Run #" << _nRuns + << ". Nhits = " << _nHits << ".\n"; */ + } + void markEvent() { + _nEvents++; + _mu2nHitsEvent += _nHitsEvent * _nHitsEvent; + _nHitsEvent = 0; + /* streamlog_out(DEBUG) << "LayerHitCounter marking Run #" << _nRuns + << ". Nhits = " << _nHits << ".\n"; */ + } private: - const double _area; - int _nHits; - int _nRuns; - int _nHitsRun; - double _mu2nHitsRun; - int _nEvents; - int _nHitsEvent; - double _mu2nHitsEvent; + const double _area; + int _nHits; + int _nRuns; + int _nHitsRun; + double _mu2nHitsRun; + int _nEvents; + int _nHitsEvent; + double _mu2nHitsEvent; }; - typedef std::map SystemHitCounter; typedef SystemHitCounter::iterator HitCtrLayerIter; typedef std::map HitCtrMap; typedef HitCtrMap::iterator HitCtrMapIter; - class TrackerHitCounter : public marlin::Processor { public: + virtual Processor* newProcessor() { return new TrackerHitCounter; } - virtual Processor* newProcessor() { return new TrackerHitCounter ; } - - - TrackerHitCounter() ; - - /** Read and report the areas of tracker elements. - * Construct the corresponding hit counters. - */ - virtual void init() ; + TrackerHitCounter(); - /// Count runs - virtual void processRunHeader( LCRunHeader* run ) ; + /** Read and report the areas of tracker elements. + * Construct the corresponding hit counters. + */ + virtual void init(); - /// Count hits in subsystems - virtual void processEvent( LCEvent * evt ) ; + /// Count runs + virtual void processRunHeader(LCRunHeader* run); - /// do nothing - virtual void check( LCEvent * evt ) ; + /// Count hits in subsystems + virtual void processEvent(LCEvent* evt); - /// report hits and clean up. - virtual void end() ; + /// do nothing + virtual void check(LCEvent* evt); + /// report hits and clean up. + virtual void end(); protected: + void markEvent(); + void markRun(); - void markEvent(); - void markRun(); + HitCtrMap _hitCounters{}; - HitCtrMap _hitCounters{} ; - - StringVec m_trkHitCollNames{} ; - - int _nRun{} ; - int _nEvt{} ; -} ; + StringVec m_trkHitCollNames{}; + int _nRun{}; + int _nEvt{}; +}; #endif // TrackerHitCounter_h - - - diff --git a/tracking/include/DDDiagnostics.h b/tracking/include/DDDiagnostics.h index 35e7f0e..689768d 100644 --- a/tracking/include/DDDiagnostics.h +++ b/tracking/include/DDDiagnostics.h @@ -1,49 +1,49 @@ #ifndef DDDiagnostics_h #define DDDiagnostics_h 1 -#include #include +#include #include +#include "UTIL/LCIterator.h" +#include "UTIL/LCRelationNavigator.h" +#include "UTIL/LCTrackerConf.h" +#include "UTIL/Operators.h" #include -#include -#include -#include #include #include -#include "UTIL/LCRelationNavigator.h" -#include "UTIL/LCIterator.h" -#include "UTIL/Operators.h" +#include +#include +#include #include -#include "UTIL/LCTrackerConf.h" -#include #include +#include -#include "DD4hep/Detector.h" #include "DD4hep/DD4hepUnits.h" #include "DD4hep/DetType.h" -#include "DDRec/DetectorData.h" +#include "DD4hep/Detector.h" #include "DD4hep/DetectorSelector.h" +#include "DDRec/DetectorData.h" #include "TROOT.h" -#include -#include -#include -#include -#include +#include "lcio.h" +#include #include #include +#include +#include +#include #include -#include -#include -#include "lcio.h" -#include -#include +#include +#include #include +#include +#include +#include -using namespace lcio ; -using namespace marlin ; -using namespace std ; +using namespace lcio; +using namespace marlin; +using namespace std; /** DDDiagnostics processor * feels a ROOT tree with track - mcparticle info @@ -51,21 +51,17 @@ using namespace std ; * creates canvases with finding efficiency - pulls * authors: Yorgos Voutsinas, Alonso Guerrero Llorente * update: to get DD4hep geometry information -*/ + */ class DDDiagnostics : public Processor { - - public: - - - virtual Processor* newProcessor() { return new DDDiagnostics ; } - - - DDDiagnostics() ; + +public: + virtual Processor* newProcessor() { return new DDDiagnostics; } + + DDDiagnostics(); DDDiagnostics(const DDDiagnostics&) = delete; DDDiagnostics& operator=(const DDDiagnostics&) = delete; - /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ @@ -73,48 +69,45 @@ class DDDiagnostics : public Processor { /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; - + virtual void processRunHeader(LCRunHeader* run); + /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; - - - virtual void check( LCEvent * evt ) ; - - + virtual void processEvent(LCEvent* evt); + + virtual void check(LCEvent* evt); + /** Called after data processing for clean up. */ - virtual void end() ; + virtual void end(); /** Initialise the ROOT TTRee. */ - void initTree(void) ; + void initTree(void); /** Initialise the ROOT TH1F and so on ... */ - void initHist(void) ; + void initHist(void); /** Finalise the ROOT, and fill the TCanvas. */ - void fillCanvas(void) ; + void fillCanvas(void); /** Initialise the all the vectors. */ - void clearVec(void) ; + void clearVec(void); /** Initialise the all the parameters for marlin. */ - void initParameters(void) ; - - protected: + void initParameters(void); +protected: /** Input collection name. */ std::string _trueToReco = ""; std::string _recoToTrue = ""; std::string _mcParticleCollectionName = ""; - StringVec _simTrkHitCollectionNames = {}; + StringVec _simTrkHitCollectionNames = {}; std::string _trackColName = ""; std::string _sitTrackerHits = ""; std::string _sitTrkHitRelations = ""; @@ -141,18 +134,17 @@ class DDDiagnostics : public Processor { bool _reqInnVXDHit = false; bool _fillBigTTree = false; - private: - +private: // declaration of trees - TTree *EvalTree = NULL; + TTree* EvalTree = NULL; vector foundTrk = {}; vector TrackSiHits = {}; - vector MarlinTrkHits = {}; - vector VXDHits = {}; - vector SITHits = {}; - vector FTDHits = {}; - vector TPCHits = {}; - vector foundTrkChi2OverNdof = {}; + vector MarlinTrkHits = {}; + vector VXDHits = {}; + vector SITHits = {}; + vector FTDHits = {}; + vector TPCHits = {}; + vector foundTrkChi2OverNdof = {}; vector PtReco = {}; vector CosThetaReco = {}; vector PtMCP = {}; @@ -177,52 +169,49 @@ class DDDiagnostics : public Processor { int MarlinTracks = 0; - TH1F *OmegaPull = NULL; - TH1F *PhiPull = NULL; - TH1F *TanLambdaPull = NULL; - TH1F *d0pull = NULL; - TH1F *z0pull = NULL; - - TH1F *OmegaResidual = NULL; - TH1F *PhiResidual = NULL; - TH1F *TanLambdaResidual = NULL; - TH1F *d0Residual = NULL; - TH1F *z0Residual = NULL; - - static const int nBins = 13 ; - - TH1F *hist_pt_t = NULL; - TH1F *hist_pt_f = NULL; - TH1F *hist_p_t = NULL; - TH1F *hist_p_f = NULL; - TH1F *hist_th_t = NULL; - TH1F *hist_th_f = NULL; - TH1F *hist_thm_t = NULL; - TH1F *hist_thm_f = NULL; - TH2F *hist_2d_t = NULL; - TH2F *hist_2d_f = NULL; - TH2F *hist_2d = NULL; - - - TCanvas *pulls = NULL; - TCanvas *residuals = NULL; - TCanvas *eff = NULL; - TCanvas *effPM = NULL; - TCanvas *eff2d = NULL; - TCanvas *eff2d_t = NULL; - TCanvas *eff2d_f = NULL; - - TF1 *myfunc = NULL; - - TGraphAsymmErrors *gpt = NULL; - TGraphAsymmErrors *gp = NULL; - TGraphAsymmErrors *gth = NULL; - TGraphAsymmErrors *gthm = NULL; - - double PI = 3.1415926535897; + TH1F* OmegaPull = NULL; + TH1F* PhiPull = NULL; + TH1F* TanLambdaPull = NULL; + TH1F* d0pull = NULL; + TH1F* z0pull = NULL; + + TH1F* OmegaResidual = NULL; + TH1F* PhiResidual = NULL; + TH1F* TanLambdaResidual = NULL; + TH1F* d0Residual = NULL; + TH1F* z0Residual = NULL; + + static const int nBins = 13; + + TH1F* hist_pt_t = NULL; + TH1F* hist_pt_f = NULL; + TH1F* hist_p_t = NULL; + TH1F* hist_p_f = NULL; + TH1F* hist_th_t = NULL; + TH1F* hist_th_f = NULL; + TH1F* hist_thm_t = NULL; + TH1F* hist_thm_f = NULL; + TH2F* hist_2d_t = NULL; + TH2F* hist_2d_f = NULL; + TH2F* hist_2d = NULL; + + TCanvas* pulls = NULL; + TCanvas* residuals = NULL; + TCanvas* eff = NULL; + TCanvas* effPM = NULL; + TCanvas* eff2d = NULL; + TCanvas* eff2d_t = NULL; + TCanvas* eff2d_f = NULL; + + TF1* myfunc = NULL; + + TGraphAsymmErrors* gpt = NULL; + TGraphAsymmErrors* gp = NULL; + TGraphAsymmErrors* gth = NULL; + TGraphAsymmErrors* gthm = NULL; + + double PI = 3.1415926535897; double TWOPI = 6.2831853071794; - -} ; - +}; #endif diff --git a/tracking/include/Residuals.h b/tracking/include/Residuals.h index 437954b..5968f60 100644 --- a/tracking/include/Residuals.h +++ b/tracking/include/Residuals.h @@ -1,120 +1,111 @@ #ifndef Residuals_h #define Residuals_h 1 -#include "marlin/Processor.h" -#include "lcio.h" -#include -#include -#include #include "EVENT/LCIO.h" +#include "EVENT/Track.h" +#include "lcio.h" +#include "marlin/Processor.h" #include -#include -#include #include -#include "EVENT/Track.h" -#include -#include #include +#include +#include +#include #include #include -#include +#include #include +#include +#include +#include +#include -#include "UTIL/LCTrackerConf.h" #include "UTIL/ILDConf.h" +#include "UTIL/LCTrackerConf.h" #include // ----- include for verbosity dependend logging --------- -#include "marlin/VerbosityLevels.h" #include "marlin/Exceptions.h" +#include "marlin/VerbosityLevels.h" #include -#include -#include -#include +#include "lcio.h" +#include #include #include +#include +#include +#include #include -#include -#include -#include "lcio.h" -#include -#include +#include #include -#include +#include +#include +#include -#include "MarlinTrk/IMarlinTrkSystem.h" -#include "MarlinTrk/IMarlinTrack.h" #include "MarlinTrk/Factory.h" +#include "MarlinTrk/IMarlinTrack.h" +#include "MarlinTrk/IMarlinTrkSystem.h" #include "MarlinTrk/MarlinTrkUtils.h" - -#include "aidaTT/IBField.hh" #include "aidaTT/ConstantSolenoidBField.hh" -#include "aidaTT/analyticalPropagation.hh" -#include "aidaTT/simplifiedPropagation.hh" +#include "aidaTT/DD4hepGeometry.hh" #include "aidaTT/GBLInterface.hh" -#include "aidaTT/fitResults.hh" -#include "aidaTT/Vector5.hh" -#include "aidaTT/utilities.hh" +#include "aidaTT/IBField.hh" #include "aidaTT/LCIOPersistency.hh" #include "aidaTT/Vector3D.hh" -#include "aidaTT/DD4hepGeometry.hh" +#include "aidaTT/Vector5.hh" +#include "aidaTT/analyticalPropagation.hh" +#include "aidaTT/fitResults.hh" +#include "aidaTT/simplifiedPropagation.hh" +#include "aidaTT/utilities.hh" #include "DD4hep/DD4hepUnits.h" - -using namespace lcio ; -using namespace marlin ; +using namespace lcio; +using namespace marlin; using namespace std; -namespace MarlinTrk{ - class IMarlinTrkSystem ; +namespace MarlinTrk { +class IMarlinTrkSystem; } -//using namespace aida; +// using namespace aida; class Residuals : public Processor { - - public: - +public: + virtual Processor* newProcessor() { return new Residuals; } - virtual Processor* newProcessor() { return new Residuals ; } - - - Residuals() ; + Residuals(); Residuals(const Residuals&) = delete; Residuals& operator=(const Residuals&) = delete; - + /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ - virtual void init() ; - + virtual void init(); + /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; - + virtual void processRunHeader(LCRunHeader* run); + /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; - - - virtual void check( LCEvent * evt ) ; - - + virtual void processEvent(LCEvent* evt); + + virtual void check(LCEvent* evt); + /** Called after data processing for clean up. */ - virtual void end() ; - - private: + virtual void end(); +private: /** Input collection name. */ std::string _trks = ""; MarlinTrk::IMarlinTrkSystem* _trkSystem = NULL; - TTree *ResiduTree = NULL; + TTree* ResiduTree = NULL; vector TrackHitResidualsU = {}; vector TrackHitResidualsV = {}; vector DetLayer = {}; @@ -128,12 +119,8 @@ class Residuals : public Processor { bool _sortRad = false; float _bField = 0.0; - std::map< long, const aidaTT::ISurface* > surfMap = {}; - std::string _trkSystemName =""; - -} ; + std::map surfMap = {}; + std::string _trkSystemName = ""; +}; #endif - - - diff --git a/tracking/include/Skim.h b/tracking/include/Skim.h index 5ce8887..a9cab45 100644 --- a/tracking/include/Skim.h +++ b/tracking/include/Skim.h @@ -1,52 +1,41 @@ #ifndef Skim_h -#define Skim_h +#define Skim_h #include "marlin/Processor.h" +#include "lcio.h" #include #include -#include "lcio.h" - - - -using namespace lcio ; +using namespace lcio; class Skim : public marlin::Processor { - public: - - virtual Processor* newProcessor() { return new Skim ; } - - - Skim() ; - + virtual Processor* newProcessor() { return new Skim; } + + Skim(); + /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ - virtual void init() ; - + virtual void init(); + /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; + virtual void processRunHeader(LCRunHeader* run); - /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; - virtual void check( LCEvent * evt ) ; - + virtual void processEvent(LCEvent* evt); + virtual void check(LCEvent* evt); + /** Called after data processing for clean up. */ - virtual void end() ; - - - -protected: - - void keepMCParticle( MCParticle* mcp, bool save_parents=true ) ; + virtual void end(); +protected: + void keepMCParticle(MCParticle* mcp, bool save_parents = true); std::string _mcpColName = ""; std::string _mcpSkimColName = ""; @@ -56,9 +45,6 @@ class Skim : public marlin::Processor { double _thetaMin = 0.0; double _thetaMax = 0.0; - -} ; - - +}; #endif diff --git a/tracking/macros/BadTracks.C b/tracking/macros/BadTracks.C index e962139..c1f9f7f 100644 --- a/tracking/macros/BadTracks.C +++ b/tracking/macros/BadTracks.C @@ -1,12 +1,11 @@ -void BadTracks() -{ - TFile *f1 = new TFile("../scripts/ildperf.root", "read"); - TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - TTree *t1 = (TTree*) d1->Get("EvalTree"); +void BadTracks() { + TFile* f1 = new TFile("../scripts/ildperf.root", "read"); + TDirectory* d1 = (TDirectory*)f1->Get("MyRecoMCTruthLinker"); + TTree* t1 = (TTree*)d1->Get("EvalTree"); - TCanvas *BadTrks = new TCanvas(); + TCanvas* BadTrks = new TCanvas(); BadTrks->cd(); - TH1F *h1 = new TH1F("h1","Ghosts Pt",4000,0,4000); + TH1F* h1 = new TH1F("h1", "Ghosts Pt", 4000, 0, 4000); t1->Draw("GhostsPt>>h1"); BadTrks->SetLogy(); } diff --git a/tracking/macros/ComparePulls.C b/tracking/macros/ComparePulls.C index 90061b2..d2dae8c 100644 --- a/tracking/macros/ComparePulls.C +++ b/tracking/macros/ComparePulls.C @@ -1,83 +1,79 @@ -void ComparePulls() -{ - //please modify the path accordingly to point to the desired file - TFile *f1 = new TFile("../Results/Analysis/analysis_MuonsAngle_85_Mom_1.root", "read"); - TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - TH1F *D0 = (TH1F*)d1->Get("d0pull"); - TH1F *Z0 = (TH1F*)d1->Get("z0pull"); - TH1F *Omega = (TH1F*)d1->Get("OmegaPull"); - TH1F *TanLambda = (TH1F*)d1->Get("TanLambdaPull"); - TH1F *Phi = (TH1F*)d1->Get("PhiPull"); +void ComparePulls() { + // please modify the path accordingly to point to the desired file + TFile* f1 = new TFile("../Results/Analysis/analysis_MuonsAngle_85_Mom_1.root", "read"); + TDirectory* d1 = (TDirectory*)f1->Get("MyRecoMCTruthLinker"); + TH1F* D0 = (TH1F*)d1->Get("d0pull"); + TH1F* Z0 = (TH1F*)d1->Get("z0pull"); + TH1F* Omega = (TH1F*)d1->Get("OmegaPull"); + TH1F* TanLambda = (TH1F*)d1->Get("TanLambdaPull"); + TH1F* Phi = (TH1F*)d1->Get("PhiPull"); - TFile *f2 = new TFile("../Results/Analysis/analysis_AntiMuonsAngle_85_Mom_1.root", "read"); - TDirectory *d2 = (TDirectory*) f2->Get("MyRecoMCTruthLinker"); - TH1F *D02 = (TH1F*)d2->Get("d0pull"); - TH1F *Z02 = (TH1F*)d2->Get("z0pull"); - TH1F *Omega2 = (TH1F*)d2->Get("OmegaPull"); - TH1F *TanLambda2 = (TH1F*)d2->Get("TanLambdaPull"); - TH1F *Phi2 = (TH1F*)d2->Get("PhiPull"); + TFile* f2 = new TFile("../Results/Analysis/analysis_AntiMuonsAngle_85_Mom_1.root", "read"); + TDirectory* d2 = (TDirectory*)f2->Get("MyRecoMCTruthLinker"); + TH1F* D02 = (TH1F*)d2->Get("d0pull"); + TH1F* Z02 = (TH1F*)d2->Get("z0pull"); + TH1F* Omega2 = (TH1F*)d2->Get("OmegaPull"); + TH1F* TanLambda2 = (TH1F*)d2->Get("TanLambdaPull"); + TH1F* Phi2 = (TH1F*)d2->Get("PhiPull"); - TCanvas *rescomp = new TCanvas("rescomp","Track par. pulls",800,800); - TPad *pad1 = new TPad("pad1","",0,0,1,1); - TPad *pad2 = new TPad("pad2","",0,0,1,1); + TCanvas* rescomp = new TCanvas("rescomp", "Track par. pulls", 800, 800); + TPad* pad1 = new TPad("pad1", "", 0, 0, 1, 1); + TPad* pad2 = new TPad("pad2", "", 0, 0, 1, 1); - rescomp->Divide(3,2); + rescomp->Divide(3, 2); - //pad1->cd(); + // pad1->cd(); rescomp->cd(1); Omega->Draw(); - //pad1->Update(); - TF1 *OmegaFit = Omega->GetFunction("gaus"); - TPaveStats *ps1 = (TPaveStats*)Omega->GetListOfFunctions()->FindObject("stats"); - ps1->SetX1NDC(0.4); ps1->SetX2NDC(0.6); + // pad1->Update(); + TF1* OmegaFit = Omega->GetFunction("gaus"); + TPaveStats* ps1 = (TPaveStats*)Omega->GetListOfFunctions()->FindObject("stats"); + ps1->SetX1NDC(0.4); + ps1->SetX2NDC(0.6); ps1->SetTextColor(kBlue); OmegaFit->SetLineColor(kBlue); - //pad2->cd(); + // pad2->cd(); Omega2->Draw("same"); - //pad2->Update(); + // pad2->Update(); Omega2->SetLineColor(kRed); - TPaveStats *ps2 = (TPaveStats*)Omega2->GetListOfFunctions()->FindObject("stats"); - ps2->SetX1NDC(0.65); ps2->SetX2NDC(0.85); + TPaveStats* ps2 = (TPaveStats*)Omega2->GetListOfFunctions()->FindObject("stats"); + ps2->SetX1NDC(0.65); + ps2->SetX2NDC(0.85); ps2->SetTextColor(kRed); rescomp->cd(2); Phi->Draw(); - //Phi->SetLineColor(kRed); - TF1 *PhiFit = Phi->GetFunction("gaus"); + // Phi->SetLineColor(kRed); + TF1* PhiFit = Phi->GetFunction("gaus"); PhiFit->SetLineColor(kBlue); Phi2->Draw("same"); Phi2->SetLineColor(kRed); rescomp->cd(3); TanLambda->Draw(); - TF1 *TanLambdaFit = TanLambda->GetFunction("gaus"); + TF1* TanLambdaFit = TanLambda->GetFunction("gaus"); TanLambdaFit->SetLineColor(kBlue); TanLambda2->Draw("same"); TanLambda2->SetLineColor(kRed); rescomp->cd(4); D0->Draw(); - TF1 *D0Fit = D0->GetFunction("gaus"); + TF1* D0Fit = D0->GetFunction("gaus"); D0Fit->SetLineColor(kBlue); D02->SetLineColor(kRed); D02->Draw("same"); rescomp->cd(5); Z0->Draw(); - TF1 *Z0Fit = Z0->GetFunction("gaus"); + TF1* Z0Fit = Z0->GetFunction("gaus"); Z0Fit->SetLineColor(kBlue); Z02->SetLineColor(kRed); Z02->Draw("same"); - rescomp->cd(6); - leg = new TLegend(0.2,0.26,0.75,0.88); - leg->AddEntry(Phi,"Muons 5 GeV","l"); - leg->AddEntry(Phi2,"Anti-muons 5 GeV","l"); + leg = new TLegend(0.2, 0.26, 0.75, 0.88); + leg->AddEntry(Phi, "Muons 5 GeV", "l"); + leg->AddEntry(Phi2, "Anti-muons 5 GeV", "l"); leg->Draw(); - - - - } diff --git a/tracking/macros/CompareResiduals.C b/tracking/macros/CompareResiduals.C index a50bd97..0886e7c 100644 --- a/tracking/macros/CompareResiduals.C +++ b/tracking/macros/CompareResiduals.C @@ -1,25 +1,24 @@ -void CompareResiduals() -{ +void CompareResiduals() { - TFile *f1 = new TFile("first.root", "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - TH1F *D0 = (TH1F*)f1->Get("d0Residual"); - TH1F *Z0 = (TH1F*)f1->Get("z0Residual"); - TH1F *Omega = (TH1F*)f1->Get("OmegaResidual"); - TH1F *TanLambda = (TH1F*)f1->Get("TanLambdaResidual"); - TH1F *Phi = (TH1F*)f1->Get("PhiResidual"); + TFile* f1 = new TFile("first.root", "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + TH1F* D0 = (TH1F*)f1->Get("d0Residual"); + TH1F* Z0 = (TH1F*)f1->Get("z0Residual"); + TH1F* Omega = (TH1F*)f1->Get("OmegaResidual"); + TH1F* TanLambda = (TH1F*)f1->Get("TanLambdaResidual"); + TH1F* Phi = (TH1F*)f1->Get("PhiResidual"); - TFile *f2 = new TFile("second.root", "read"); - //TDirectory *d2 = (TDirectory*) f2->Get("MyRecoMCTruthLinker"); - TH1F *D02 = (TH1F*)f2->Get("d0Residual"); - TH1F *Z02 = (TH1F*)f2->Get("z0Residual"); - TH1F *Omega2 = (TH1F*)f2->Get("OmegaResidual"); - TH1F *TanLambda2 = (TH1F*)f2->Get("TanLambdaResidual"); - TH1F *Phi2 = (TH1F*)f2->Get("PhiResidual"); + TFile* f2 = new TFile("second.root", "read"); + // TDirectory *d2 = (TDirectory*) f2->Get("MyRecoMCTruthLinker"); + TH1F* D02 = (TH1F*)f2->Get("d0Residual"); + TH1F* Z02 = (TH1F*)f2->Get("z0Residual"); + TH1F* Omega2 = (TH1F*)f2->Get("OmegaResidual"); + TH1F* TanLambda2 = (TH1F*)f2->Get("TanLambdaResidual"); + TH1F* Phi2 = (TH1F*)f2->Get("PhiResidual"); - TCanvas *rescomp = new TCanvas("rescomp","Track par. residuals",800,800); + TCanvas* rescomp = new TCanvas("rescomp", "Track par. residuals", 800, 800); - rescomp->Divide(3,2); + rescomp->Divide(3, 2); rescomp->cd(1); Omega->Draw(); @@ -48,12 +47,8 @@ void CompareResiduals() rescomp->cd(6); - leg = new TLegend(0.2,0.26,0.75,0.88); - leg->AddEntry(Phi,"starting helix","l"); - leg->AddEntry(Phi2,"helix refitted with aida","l"); + leg = new TLegend(0.2, 0.26, 0.75, 0.88); + leg->AddEntry(Phi, "starting helix", "l"); + leg->AddEntry(Phi2, "helix refitted with aida", "l"); leg->Draw(); - - - - } diff --git a/tracking/macros/D0Resolution.C b/tracking/macros/D0Resolution.C index 94579c8..77d2d3e 100644 --- a/tracking/macros/D0Resolution.C +++ b/tracking/macros/D0Resolution.C @@ -1,36 +1,35 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 8 #define SIZE_PA 4 -//#define SIZE_M 1 -//#define SIZE_PA 1 +// #define SIZE_M 1 +// #define SIZE_PA 1 -//TGraph *Muon_plot[SIZE_PA]; +// TGraph *Muon_plot[SIZE_PA]; double sigma[SIZE_M][SIZE_PA], error_sigma[SIZE_M][SIZE_PA]; int Mom[SIZE_M] = {1, 3, 5, 10, 15, 25, 50, 100}; -float Momentum[SIZE_M] = {1, 3, 5, 10, 15, 25, 50, 100}; +float Momentum[SIZE_M] = {1, 3, 5, 10, 15, 25, 50, 100}; float zeros[SIZE_M]; int PA[SIZE_PA] = {10, 20, 40, 85}; /* int Mom[SIZE_M] = {1}; -float Momentum[SIZE_M] = {1}; +float Momentum[SIZE_M] = {1}; float zeros[SIZE_M]; int PA[SIZE_PA] = {10}; */ @@ -38,83 +37,76 @@ int PA[SIZE_PA] = {10}; float LimAxis; int color, marker; -void D0Resolution(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void D0Resolution() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { - TFile *f = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TTree *EvalTree = (TTree*)f->Get("EvalTree"); - TTree *EvalTree; + TFile* f = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + // TTree *EvalTree = (TTree*)f->Get("EvalTree"); + TTree* EvalTree; f->GetObject("EvalTree", EvalTree); - printf( " I am studying file analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); + printf(" I am studying file analysis_MuonsAngle_%d_Mom_%d.root ", PA[ii], Mom[i]); - vector *recoD0 = 0; - vector *trueD0 = 0; - - //Loading the branches in EvalTree + vector* recoD0 = 0; + vector* trueD0 = 0; + + // Loading the branches in EvalTree EvalTree->SetBranchAddress("recoD0", &recoD0); EvalTree->SetBranchAddress("trueD0", &trueD0); - EvalTree->SetBranchStatus("*",0); //disable all branches - EvalTree->SetBranchStatus("recoD0",1); - EvalTree->SetBranchStatus("trueD0",1); - - //getting the correct size of the axis for a good fitting - if ( (Momentum[i]/PA[ii]) > 1 || (Mom[i] == 15 && PA[ii] == 10) ){ - LimAxis = 0.04; - } - else if ((Mom[i] == 1 && PA[ii] == 20) || (Mom[i] == 3 && PA[ii] == 10) || (Mom[i] == 5 && PA[ii] == 10) ){ - LimAxis = 1.0; - } - else if (Mom[i] == 1 && PA[ii] == 10){ - LimAxis = 3.0; + EvalTree->SetBranchStatus("*", 0); // disable all branches + EvalTree->SetBranchStatus("recoD0", 1); + EvalTree->SetBranchStatus("trueD0", 1); + + // getting the correct size of the axis for a good fitting + if ((Momentum[i] / PA[ii]) > 1 || (Mom[i] == 15 && PA[ii] == 10)) { + LimAxis = 0.04; + } else if ((Mom[i] == 1 && PA[ii] == 20) || (Mom[i] == 3 && PA[ii] == 10) || (Mom[i] == 5 && PA[ii] == 10)) { + LimAxis = 1.0; + } else if (Mom[i] == 1 && PA[ii] == 10) { + LimAxis = 3.0; + } else { + LimAxis = 0.07; } - else{ - LimAxis = 0.07; - } - - - TH1F* h1 = new TH1F("h1","Impact Parameter Resolution",100, (-1)*LimAxis, LimAxis); - - Long64_t nentries = EvalTree->GetEntriesFast(); - for (Long64_t jentry=0; jentryGetEntry(jentry); - for (int unsigned k = 0; k < recoD0->size(); k++){ - float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); - h1->Fill( DistanceResolution ); - } + + TH1F* h1 = new TH1F("h1", "Impact Parameter Resolution", 100, (-1) * LimAxis, LimAxis); + + Long64_t nentries = EvalTree->GetEntriesFast(); + for (Long64_t jentry = 0; jentry < nentries; jentry++) { + EvalTree->GetEntry(jentry); + for (int unsigned k = 0; k < recoD0->size(); k++) { + float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); + h1->Fill(DistanceResolution); + } } - + h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); sigma[i][ii] = (fit1->GetParameter(2)); - error_sigma[i][ii] = (fit1->GetParError(2)); + error_sigma[i][ii] = (fit1->GetParError(2)); + + // std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; - //std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; - - - }//loop for each .root files, here I have collected sigma and its error - }//polar angle loop + } // loop for each .root files, here I have collected sigma and its error + } // polar angle loop - float sigma20[SIZE_M]; float error20[SIZE_M]; float r_error20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma20[kk] = sigma[kk][1]; error20[kk] = error_sigma[kk][1]; - r_error20[kk] = 100*(error_sigma[kk][1]/sigma[kk][1]); - } - + r_error20[kk] = 100 * (error_sigma[kk][1] / sigma[kk][1]); + } float sigma40[SIZE_M]; float error40[SIZE_M]; float r_error40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma40[kk] = sigma[kk][2]; error40[kk] = error_sigma[kk][2]; } @@ -122,7 +114,7 @@ void D0Resolution(){ float sigma10[SIZE_M]; float error10[SIZE_M]; float r_error10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma10[kk] = sigma[kk][0]; error10[kk] = error_sigma[kk][0]; } @@ -130,67 +122,64 @@ void D0Resolution(){ float sigma85[SIZE_M]; float error85[SIZE_M]; float r_error85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma85[kk] = sigma[kk][3]; error85[kk] = error_sigma[kk][3]; } - - - TCanvas *c_two = new TCanvas("IPResolution","IP Resolution",200,10,700,500); - //c_two -> Divide(1,2); - - //c_two->cd(1); - TGraphErrors *Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); - Muon_plot40 -> SetTitle("Impact Parameter Resolution"); - Muon_plot40 -> SetMarkerColor(2); - Muon_plot40 -> SetMarkerStyle(21); - Muon_plot40 -> SetMarkerSize(1); - Muon_plot40 -> GetXaxis() -> SetTitle("p_{T} (GeV)"); - Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{d0}(#mum)"); - Muon_plot40 -> SetMinimum( pow(10,-3) ); - Muon_plot40 -> SetMaximum( 0.8 ); - Muon_plot40 -> Draw("AP"); - - //c_two->cd(1); - TGraphErrors *Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); - Muon_plot20 -> SetTitle("Distance Resolution"); - Muon_plot20 -> SetMarkerColor(4); - Muon_plot20 -> SetMarkerStyle(22); - Muon_plot20 -> SetMarkerSize(1); - Muon_plot20 -> GetXaxis() -> SetTitle("p_{T} (GeV)"); - Muon_plot20 -> GetYaxis() -> SetTitle("#sigma_{d0}(#mum)"); - Muon_plot20 -> Draw("P"); - - TGraphErrors *Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); - Muon_plot10 -> SetTitle("Distance Resolution"); - Muon_plot10 -> SetMarkerColor(6); - Muon_plot10 -> SetMarkerStyle(22); - Muon_plot10 -> SetMarkerSize(1); - Muon_plot10 -> GetXaxis() -> SetTitle("p_{T} (GeV)"); - Muon_plot10 -> GetYaxis() -> SetTitle("#sigma_{d0}(#mum)"); - Muon_plot10 -> Draw("P"); - - //c_two->cd(1); - TGraphErrors *Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85 ); - Muon_plot85 -> SetTitle("Impact Parameter Resolution"); - Muon_plot85 -> SetMarkerColor(1); - Muon_plot85 -> SetMarkerStyle(20); - Muon_plot85 -> SetMarkerSize(1); - Muon_plot85 -> GetXaxis() -> SetTitle("p_{T} (GeV)"); - Muon_plot85 -> GetYaxis() -> SetTitle("#sigma_{d0}(#mum)"); - Muon_plot85 -> Draw("P"); + TCanvas* c_two = new TCanvas("IPResolution", "IP Resolution", 200, 10, 700, 500); + // c_two -> Divide(1,2); + + // c_two->cd(1); + TGraphErrors* Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); + Muon_plot40->SetTitle("Impact Parameter Resolution"); + Muon_plot40->SetMarkerColor(2); + Muon_plot40->SetMarkerStyle(21); + Muon_plot40->SetMarkerSize(1); + Muon_plot40->GetXaxis()->SetTitle("p_{T} (GeV)"); + Muon_plot40->GetYaxis()->SetTitle("#sigma_{d0}(#mum)"); + Muon_plot40->SetMinimum(pow(10, -3)); + Muon_plot40->SetMaximum(0.8); + Muon_plot40->Draw("AP"); + + // c_two->cd(1); + TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); + Muon_plot20->SetTitle("Distance Resolution"); + Muon_plot20->SetMarkerColor(4); + Muon_plot20->SetMarkerStyle(22); + Muon_plot20->SetMarkerSize(1); + Muon_plot20->GetXaxis()->SetTitle("p_{T} (GeV)"); + Muon_plot20->GetYaxis()->SetTitle("#sigma_{d0}(#mum)"); + Muon_plot20->Draw("P"); + + TGraphErrors* Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); + Muon_plot10->SetTitle("Distance Resolution"); + Muon_plot10->SetMarkerColor(6); + Muon_plot10->SetMarkerStyle(22); + Muon_plot10->SetMarkerSize(1); + Muon_plot10->GetXaxis()->SetTitle("p_{T} (GeV)"); + Muon_plot10->GetYaxis()->SetTitle("#sigma_{d0}(#mum)"); + Muon_plot10->Draw("P"); + + // c_two->cd(1); + TGraphErrors* Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); + Muon_plot85->SetTitle("Impact Parameter Resolution"); + Muon_plot85->SetMarkerColor(1); + Muon_plot85->SetMarkerStyle(20); + Muon_plot85->SetMarkerSize(1); + Muon_plot85->GetXaxis()->SetTitle("p_{T} (GeV)"); + Muon_plot85->GetYaxis()->SetTitle("#sigma_{d0}(#mum)"); + Muon_plot85->Draw("P"); c_two->SetLogx(); c_two->SetLogy(); c_two->SetTickx(1); c_two->SetTicky(1); - TLegend *leg = new TLegend(0.6,0.7,0.75,0.95); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot10,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot20,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot40,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot85,"#theta = 85^{o}","p"); + TLegend* leg = new TLegend(0.6, 0.7, 0.75, 0.95); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot10, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot20, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot40, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot85, "#theta = 85^{o}", "p"); leg->Draw(); - } diff --git a/tracking/macros/D0ResolutionL5.C b/tracking/macros/D0ResolutionL5.C index 37b86bc..dde09ec 100644 --- a/tracking/macros/D0ResolutionL5.C +++ b/tracking/macros/D0ResolutionL5.C @@ -1,142 +1,139 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 8 #define SIZE_PA 4 -//#define SIZE_M 1 -//#define SIZE_PA 1 +// #define SIZE_M 1 +// #define SIZE_PA 1 -//TGraph *Muon_plot[SIZE_PA]; +// TGraph *Muon_plot[SIZE_PA]; double sigma[SIZE_M][SIZE_PA], error_sigma[SIZE_M][SIZE_PA]; int Mom[SIZE_M] = {1, 3, 5, 10, 15, 25, 50, 100}; -float Momentum[SIZE_M] = {1, 3, 5, 10, 15, 25, 50, 100}; +float Momentum[SIZE_M] = {1, 3, 5, 10, 15, 25, 50, 100}; float zeros[SIZE_M]; int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void D0ResolutionL5(){ +void D0ResolutionL5() { - TCanvas *D0_fit = new TCanvas("D0 fit","D0 fit",800,800); + TCanvas* D0_fit = new TCanvas("D0 fit", "D0 fit", 800, 800); D0_fit->Print("D0_fit_ILD_l5_v02.pdf["); - for (int ll = 0; ll < SIZE_M; ll++){ + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { - TFile *f = new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TTree *EvalTree = (TTree*)f->Get("EvalTree"); - TTree *EvalTree; + TFile* f = + new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + // TTree *EvalTree = (TTree*)f->Get("EvalTree"); + TTree* EvalTree; f->GetObject("EvalTree", EvalTree); - printf( " I am studying file analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); + printf(" I am studying file analysis_MuonsAngle_%d_Mom_%d.root ", PA[ii], Mom[i]); - vector *recoD0 = 0; - vector *trueD0 = 0; - - //Loading the branches in EvalTree + vector* recoD0 = 0; + vector* trueD0 = 0; + + // Loading the branches in EvalTree EvalTree->SetBranchAddress("recoD0", &recoD0); EvalTree->SetBranchAddress("trueD0", &trueD0); - EvalTree->SetBranchStatus("*",0); //disable all branches - EvalTree->SetBranchStatus("recoD0",1); - EvalTree->SetBranchStatus("trueD0",1); - - //getting the correct size of the axis for a good fitting + EvalTree->SetBranchStatus("*", 0); // disable all branches + EvalTree->SetBranchStatus("recoD0", 1); + EvalTree->SetBranchStatus("trueD0", 1); + + // getting the correct size of the axis for a good fitting /* if ( (Momentum[i]/PA[ii]) > 1 || (Mom[i] == 15 && PA[ii] == 10) ){ - LimAxis = 0.04; + LimAxis = 0.04; } else if ((Mom[i] == 1 && PA[ii] == 20) || (Mom[i] == 3 && PA[ii] == 10) || (Mom[i] == 5 && PA[ii] == 10) ){ - LimAxis = 1.0; + LimAxis = 1.0; } else if (Mom[i] == 1 && PA[ii] == 10){ - LimAxis = 3.0; + LimAxis = 3.0; } else{ - LimAxis = 0.07; + LimAxis = 0.07; } */ - if (PA[ii] < 11 ){ - LimAxis = 10.0/Mom[i]; - } - else if (PA[ii] < 20 ){ - LimAxis = 5.0/Mom[i]; - } - else if (PA[ii] >= 20 && PA[ii] < 90){ - if( Mom[i] > 10 ){ - LimAxis = 0.5/Mom[i]; - }else { - LimAxis = 0.2/Mom[i]; - } - }else if (PA[ii] == 90 ){ - if( Mom[i] > 9 ){ - LimAxis = 2.0/Mom[i]; - }else { - LimAxis = 0.2/Mom[i]; - } + if (PA[ii] < 11) { + LimAxis = 10.0 / Mom[i]; + } else if (PA[ii] < 20) { + LimAxis = 5.0 / Mom[i]; + } else if (PA[ii] >= 20 && PA[ii] < 90) { + if (Mom[i] > 10) { + LimAxis = 0.5 / Mom[i]; + } else { + LimAxis = 0.2 / Mom[i]; + } + } else if (PA[ii] == 90) { + if (Mom[i] > 9) { + LimAxis = 2.0 / Mom[i]; + } else { + LimAxis = 0.2 / Mom[i]; + } } std::string dummy("Title: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); - std::sprintf( &dummy[0] , "Title: MuonsAngle_%d_Mom_%d" , PA[ii], Mom[i] ) ; - - TH1F* h1 = new TH1F("h1","Impact Parameter Resolution",100, (-1)*LimAxis, LimAxis); - - Long64_t nentries = EvalTree->GetEntriesFast(); - for (Long64_t jentry=0; jentryGetEntry(jentry); - for (int unsigned k = 0; k < recoD0->size(); k++){ - float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); - h1->Fill( DistanceResolution ); - } + std::sprintf(&dummy[0], "Title: MuonsAngle_%d_Mom_%d", PA[ii], Mom[i]); + + TH1F* h1 = new TH1F("h1", "Impact Parameter Resolution", 100, (-1) * LimAxis, LimAxis); + + Long64_t nentries = EvalTree->GetEntriesFast(); + for (Long64_t jentry = 0; jentry < nentries; jentry++) { + EvalTree->GetEntry(jentry); + for (int unsigned k = 0; k < recoD0->size(); k++) { + float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); + h1->Fill(DistanceResolution); + } } - + h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); sigma[i][ii] = (fit1->GetParameter(2)); - error_sigma[i][ii] = (fit1->GetParError(2)); + error_sigma[i][ii] = (fit1->GetParError(2)); - //std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; - - D0_fit->Print("D0_fit_ILD_l5_v02.pdf",&dummy[0]); + // std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; - }//loop for each .root files, here I have collected sigma and its error - }//polar angle loop + D0_fit->Print("D0_fit_ILD_l5_v02.pdf", &dummy[0]); + + } // loop for each .root files, here I have collected sigma and its error + } // polar angle loop D0_fit->Print("D0_fit_ILD_l5_v02.pdf]"); - + float sigma20[SIZE_M]; float error20[SIZE_M]; float r_error20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma20[kk] = sigma[kk][1]; error20[kk] = error_sigma[kk][1]; - r_error20[kk] = 100*(error_sigma[kk][1]/sigma[kk][1]); - } - + r_error20[kk] = 100 * (error_sigma[kk][1] / sigma[kk][1]); + } float sigma40[SIZE_M]; float error40[SIZE_M]; float r_error40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma40[kk] = sigma[kk][2]; error40[kk] = error_sigma[kk][2]; } @@ -144,7 +141,7 @@ void D0ResolutionL5(){ float sigma10[SIZE_M]; float error10[SIZE_M]; float r_error10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma10[kk] = sigma[kk][0]; error10[kk] = error_sigma[kk][0]; } @@ -152,85 +149,86 @@ void D0ResolutionL5(){ float sigma85[SIZE_M]; float error85[SIZE_M]; float r_error85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma85[kk] = sigma[kk][3]; error85[kk] = error_sigma[kk][3]; } - - - TCanvas *c_two = new TCanvas("IPResolution","IP Resolution",200,10,700,700); - //c_two -> Divide(1,2); - - //c_two->cd(1); - TGraphErrors *Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); - Muon_plot40 -> SetTitle("Impact Parameter Resolution"); - Muon_plot40 -> SetMarkerColor(2); - Muon_plot40 -> SetMarkerStyle(21); - Muon_plot40 -> SetMarkerSize(1); - Muon_plot40 -> GetXaxis() -> SetTitle("Momentum (GeV)"); - Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{d0}(mm)"); - Muon_plot40 -> SetMinimum( pow(10,-3) ); - Muon_plot40 -> SetMaximum( 0.8 ); - Muon_plot40 -> Draw("AP"); - - //c_two->cd(1); - TGraphErrors *Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); - Muon_plot20 -> SetTitle("Distance Resolution"); - Muon_plot20 -> SetMarkerColor(4); - Muon_plot20 -> SetMarkerStyle(22); - Muon_plot20 -> SetMarkerSize(1); - Muon_plot20 -> GetXaxis() -> SetTitle("Momentum (GeV)"); - Muon_plot20 -> GetYaxis() -> SetTitle("#sigma_{d0}(mm)"); - Muon_plot20 -> Draw("P"); - - TGraphErrors *Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); - Muon_plot10 -> SetTitle("Distance Resolution"); - Muon_plot10 -> SetMarkerColor(6); - Muon_plot10 -> SetMarkerStyle(22); - Muon_plot10 -> SetMarkerSize(1); - Muon_plot10 -> GetXaxis() -> SetTitle("Momentum (GeV)"); - Muon_plot10 -> GetYaxis() -> SetTitle("#sigma_{d0}(mm)"); - Muon_plot10 -> Draw("P"); - - //c_two->cd(1); - TGraphErrors *Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85 ); - Muon_plot85 -> SetTitle("Impact Parameter Resolution"); - Muon_plot85 -> SetMarkerColor(1); - Muon_plot85 -> SetMarkerStyle(20); - Muon_plot85 -> SetMarkerSize(1); - Muon_plot85 -> GetXaxis() -> SetTitle("Momentum (GeV)"); - Muon_plot85 -> GetYaxis() -> SetTitle("#sigma_{d0}(mm)"); - Muon_plot85 -> Draw("P"); + TCanvas* c_two = new TCanvas("IPResolution", "IP Resolution", 200, 10, 700, 700); + // c_two -> Divide(1,2); + + // c_two->cd(1); + TGraphErrors* Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); + Muon_plot40->SetTitle("Impact Parameter Resolution"); + Muon_plot40->SetMarkerColor(2); + Muon_plot40->SetMarkerStyle(21); + Muon_plot40->SetMarkerSize(1); + Muon_plot40->GetXaxis()->SetTitle("Momentum (GeV)"); + Muon_plot40->GetYaxis()->SetTitle("#sigma_{d0}(mm)"); + Muon_plot40->SetMinimum(pow(10, -3)); + Muon_plot40->SetMaximum(0.8); + Muon_plot40->Draw("AP"); + + // c_two->cd(1); + TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); + Muon_plot20->SetTitle("Distance Resolution"); + Muon_plot20->SetMarkerColor(4); + Muon_plot20->SetMarkerStyle(22); + Muon_plot20->SetMarkerSize(1); + Muon_plot20->GetXaxis()->SetTitle("Momentum (GeV)"); + Muon_plot20->GetYaxis()->SetTitle("#sigma_{d0}(mm)"); + Muon_plot20->Draw("P"); + + TGraphErrors* Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); + Muon_plot10->SetTitle("Distance Resolution"); + Muon_plot10->SetMarkerColor(6); + Muon_plot10->SetMarkerStyle(22); + Muon_plot10->SetMarkerSize(1); + Muon_plot10->GetXaxis()->SetTitle("Momentum (GeV)"); + Muon_plot10->GetYaxis()->SetTitle("#sigma_{d0}(mm)"); + Muon_plot10->Draw("P"); + + // c_two->cd(1); + TGraphErrors* Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); + Muon_plot85->SetTitle("Impact Parameter Resolution"); + Muon_plot85->SetMarkerColor(1); + Muon_plot85->SetMarkerStyle(20); + Muon_plot85->SetMarkerSize(1); + Muon_plot85->GetXaxis()->SetTitle("Momentum (GeV)"); + Muon_plot85->GetYaxis()->SetTitle("#sigma_{d0}(mm)"); + Muon_plot85->Draw("P"); c_two->SetLogx(); c_two->SetLogy(); c_two->SetTickx(1); c_two->SetTicky(1); - TLegend *leg = new TLegend(0.65,0.70,0.80,0.89); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot10,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot20,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot40,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot85,"#theta = 85^{o}","p"); + TLegend* leg = new TLegend(0.65, 0.70, 0.80, 0.89); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot10, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot20, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot40, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot85, "#theta = 85^{o}", "p"); leg->Draw(); - TF1 *fpr10 = new TF1("fpr10","sqrt( 25.e-6 + 1.e-4/(x*x*0.17364817766*0.17364817766) )",0.5,200.0); //for theta =10 degree - fpr10->SetLineColor(6); - //fpr10->Draw("same"); + TF1* fpr10 = + new TF1("fpr10", "sqrt( 25.e-6 + 1.e-4/(x*x*0.17364817766*0.17364817766) )", 0.5, 200.0); // for theta =10 degree + fpr10->SetLineColor(6); + // fpr10->Draw("same"); - TF1 *fpr20 = new TF1("fpr20","sqrt( 25.e-6 + 1.e-4/(x*x*0.34202014332*sqrt(0.34202014332)) )",0.5,200.0); //for theta =20 degree - fpr20->SetLineColor(4); - //fpr20->Draw("same"); + TF1* fpr20 = new TF1("fpr20", "sqrt( 25.e-6 + 1.e-4/(x*x*0.34202014332*sqrt(0.34202014332)) )", 0.5, + 200.0); // for theta =20 degree + fpr20->SetLineColor(4); + // fpr20->Draw("same"); - TF1 *fpr40 = new TF1("fpr40","sqrt( 25.e-6 + 1.e-4/(x*x*0.64278760968*sqrt(0.64278760968)) )",0.5,200.0); //for theta =40 degree - fpr40->SetLineColor(2); - //fpr40->Draw("same"); + TF1* fpr40 = new TF1("fpr40", "sqrt( 25.e-6 + 1.e-4/(x*x*0.64278760968*sqrt(0.64278760968)) )", 0.5, + 200.0); // for theta =40 degree + fpr40->SetLineColor(2); + // fpr40->Draw("same"); - TF1 *fpr85 = new TF1("fpr85","sqrt( 25.e-6 + 1.e-4/(x*x*0.99619469809*sqrt(0.99619469809)) )",0.5,200.0); //for theta =85 degree - fpr85->SetLineColor(1); - //fpr85->Draw("same"); + TF1* fpr85 = new TF1("fpr85", "sqrt( 25.e-6 + 1.e-4/(x*x*0.99619469809*sqrt(0.99619469809)) )", 0.5, + 200.0); // for theta =85 degree + fpr85->SetLineColor(1); + // fpr85->Draw("same"); c_two->SaveAs("IPResolution_ILD_l5_v02.png"); - } diff --git a/tracking/macros/D0Resolution_comp.C b/tracking/macros/D0Resolution_comp.C index 2a1af77..be6afc4 100644 --- a/tracking/macros/D0Resolution_comp.C +++ b/tracking/macros/D0Resolution_comp.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 8 @@ -27,320 +26,293 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void D0Resolution_comp(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void D0Resolution_comp() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - - TFile *f = new TFile(Form("/afs/desy.de/group/flc/pool/voutsina/SingleMuonTracks/DBD/Analysis/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - TTree *EvalTree = (TTree*)f->Get("MyRecoMCTruthLinker/EvalTree"); - - printf( " I am studying file analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); - - vector *recoD0; - vector *trueD0; - - //Loading the branches in EvalTree + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + + TFile* f = new TFile( + Form("/afs/desy.de/group/flc/pool/voutsina/SingleMuonTracks/DBD/Analysis/analysis_MuonsAngle_%d_Mom_%d.root", + PA[ii], Mom[i]), + "read"); + TTree* EvalTree = (TTree*)f->Get("MyRecoMCTruthLinker/EvalTree"); + + printf(" I am studying file analysis_MuonsAngle_%d_Mom_%d.root ", PA[ii], Mom[i]); + + vector* recoD0; + vector* trueD0; + + // Loading the branches in EvalTree EvalTree->SetBranchAddress("recoD0", &recoD0); EvalTree->SetBranchAddress("trueD0", &trueD0); - - int num_entries = EvalTree->GetEntries(); - - //getting the correct size of the axis for a good fitting - if ( (Momentum[i]/PA[ii]) > 1 || (Mom[i] == 15 && PA[ii] == 10) || (Mom[i] == 10 && PA[ii] == 20)){ - LimAxis = 0.04; - } - else if ((Mom[i] == 1 && PA[ii] == 20) || (Mom[i] == 3 && PA[ii] == 10) || (Mom[i] == 5 && PA[ii] == 10) ){ - LimAxis = 1.0; - } - else if (Mom[i] == 1 && PA[ii] == 10){ - LimAxis = 3.0; - } - else{ - LimAxis = 0.07; + + int num_entries = EvalTree->GetEntries(); + + // getting the correct size of the axis for a good fitting + if ((Momentum[i] / PA[ii]) > 1 || (Mom[i] == 15 && PA[ii] == 10) || (Mom[i] == 10 && PA[ii] == 20)) { + LimAxis = 0.04; + } else if ((Mom[i] == 1 && PA[ii] == 20) || (Mom[i] == 3 && PA[ii] == 10) || (Mom[i] == 5 && PA[ii] == 10)) { + LimAxis = 1.0; + } else if (Mom[i] == 1 && PA[ii] == 10) { + LimAxis = 3.0; + } else { + LimAxis = 0.07; } - - - TH1F* h1 = new TH1F("h1","Impact Parameter Resolution",100, (-1)*LimAxis, LimAxis); - - for (int j = 0; j < num_entries; j++ ){ - EvalTree->GetEntry(j); - for (int unsigned k = 0; k < recoD0->size(); k++){ - float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); - h1->Fill( DistanceResolution ); - } + + TH1F* h1 = new TH1F("h1", "Impact Parameter Resolution", 100, (-1) * LimAxis, LimAxis); + + for (int j = 0; j < num_entries; j++) { + EvalTree->GetEntry(j); + for (int unsigned k = 0; k < recoD0->size(); k++) { + float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); + h1->Fill(DistanceResolution); + } } - + h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); sigma[i][ii] = (fit1->GetParameter(2)); - error_sigma[i][ii] = (fit1->GetParError(2)); - - //std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; - - - }//loop for each .root files, here I have collected sigma and its error - }//polar angle loop - - - - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - - TFile *fnew = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - TTree *EvalTreeNew = (TTree*)fnew->Get("EvalTree"); - printf( " I am studying file /nfs/dust/ilc/user/voutsina/testarea/CodeTest/fitting/ILDPerformance/trunk/tracking/Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); - - vector *recoD0; - vector *trueD0; - - //Loading the branches in EvalTree + error_sigma[i][ii] = (fit1->GetParError(2)); + + // std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; + + } // loop for each .root files, here I have collected sigma and its error + } // polar angle loop + + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + + TFile* fnew = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + TTree* EvalTreeNew = (TTree*)fnew->Get("EvalTree"); + printf(" I am studying file " + "/nfs/dust/ilc/user/voutsina/testarea/CodeTest/fitting/ILDPerformance/trunk/tracking/Results/Analysis/" + "analysis_MuonsAngle_%d_Mom_%d.root ", + PA[ii], Mom[i]); + + vector* recoD0; + vector* trueD0; + + // Loading the branches in EvalTree EvalTreeNew->SetBranchAddress("recoD0", &recoD0); EvalTreeNew->SetBranchAddress("trueD0", &trueD0); - - int num_entries = EvalTreeNew->GetEntries(); - - //getting the correct size of the axis for a good fitting - if ( (Momentum[i]/PA[ii]) > 1 || (Mom[i] == 15 && PA[ii] == 10) || (Mom[i] == 10 && PA[ii] == 20)){ - LimAxis = 0.04; - } - else if ((Mom[i] == 1 && PA[ii] == 20) || (Mom[i] == 3 && PA[ii] == 10) || (Mom[i] == 5 && PA[ii] == 10) ){ - LimAxis = 1.0; - } - else if (Mom[i] == 1 && PA[ii] == 10){ - LimAxis = 3.0; - } - else{ - LimAxis = 0.07; - } - - - TH1F* h1 = new TH1F("h1","Impact Parameter Resolution",100, (-1)*LimAxis, LimAxis); - - for (int j = 0; j < num_entries; j++ ){ - EvalTreeNew->GetEntry(j); - for (int unsigned k = 0; k < recoD0->size(); k++){ - float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); - h1->Fill( DistanceResolution ); - } + + int num_entries = EvalTreeNew->GetEntries(); + + // getting the correct size of the axis for a good fitting + if ((Momentum[i] / PA[ii]) > 1 || (Mom[i] == 15 && PA[ii] == 10) || (Mom[i] == 10 && PA[ii] == 20)) { + LimAxis = 0.04; + } else if ((Mom[i] == 1 && PA[ii] == 20) || (Mom[i] == 3 && PA[ii] == 10) || (Mom[i] == 5 && PA[ii] == 10)) { + LimAxis = 1.0; + } else if (Mom[i] == 1 && PA[ii] == 10) { + LimAxis = 3.0; + } else { + LimAxis = 0.07; } - - h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); - sigma_new[i][ii] = (fit1->GetParameter(2)); - error_new_sigma_new[i][ii] = (fit1->GetParError(2)); - - //std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; - }//loop for each .root files, here I have collected sigma and its error - }//polar angle loop + TH1F* h1 = new TH1F("h1", "Impact Parameter Resolution", 100, (-1) * LimAxis, LimAxis); + for (int j = 0; j < num_entries; j++) { + EvalTreeNew->GetEntry(j); + for (int unsigned k = 0; k < recoD0->size(); k++) { + float DistanceResolution = (recoD0->at(k) - trueD0->at(k)); + h1->Fill(DistanceResolution); + } + } + h1->Fit("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); + sigma_new[i][ii] = (fit1->GetParameter(2)); + error_new_sigma_new[i][ii] = (fit1->GetParError(2)); + // std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; + } // loop for each .root files, here I have collected sigma and its error + } // polar angle loop - - float sigma20[SIZE_M]; - float error20[SIZE_M]; - float r_error20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + float sigma20[SIZE_M]; + float error20[SIZE_M]; + float r_error20[SIZE_M]; + for (int kk = 0; kk < SIZE_M; kk++) { sigma20[kk] = sigma[kk][1]; error20[kk] = error_sigma[kk][1]; - r_error20[kk] = 100*(error_sigma[kk][1]/sigma[kk][1]); - std::cout << " polar angle = 20, momentum " << Momentum[kk] << " kk " << kk << " sigma20 " << sigma20[kk] << " error " << error20[kk] << std::endl ; - } + r_error20[kk] = 100 * (error_sigma[kk][1] / sigma[kk][1]); + std::cout << " polar angle = 20, momentum " << Momentum[kk] << " kk " << kk << " sigma20 " << sigma20[kk] + << " error " << error20[kk] << std::endl; + } float sigma10[SIZE_M]; float error10[SIZE_M]; float r_error10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma10[kk] = sigma[kk][0]; error10[kk] = error_sigma[kk][0]; - //std::cout << " polar angle = 10, momentum " << Momentum[kk] << " kk " << kk << " sigma10 " << sigma10[kk] << " error " << error10[kk] << std::endl ; + // std::cout << " polar angle = 10, momentum " << Momentum[kk] << " kk " << kk << " sigma10 " << sigma10[kk] << " + // error " << error10[kk] << std::endl ; } - + float sigma40[SIZE_M]; float error40[SIZE_M]; float r_error40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma40[kk] = sigma[kk][2]; error40[kk] = error_sigma[kk][2]; - r_error40[kk] = 100*(error_sigma[kk][2]/sigma[kk][2]); - //std::cout << " polar angle = 40, momentum " << Momentum[kk] << " kk " << kk << " sigma40 " << sigma40[kk] << " error " << error40[kk] << std::endl ; + r_error40[kk] = 100 * (error_sigma[kk][2] / sigma[kk][2]); + // std::cout << " polar angle = 40, momentum " << Momentum[kk] << " kk " << kk << " sigma40 " << sigma40[kk] << " + // error " << error40[kk] << std::endl ; } float sigma85[SIZE_M]; float error85[SIZE_M]; float r_error85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma85[kk] = sigma[kk][3]; error85[kk] = error_sigma[kk][3]; - r_error85[kk] = 100*(error_sigma[kk][3]/sigma[kk][3]); - //std::cout << " polar angle = 85, momentum " << Momentum[kk] << " kk " << kk << " sigma85 " << sigma85[kk] << " error " << error85[kk] << std::endl ; - + r_error85[kk] = 100 * (error_sigma[kk][3] / sigma[kk][3]); + // std::cout << " polar angle = 85, momentum " << Momentum[kk] << " kk " << kk << " sigma85 " << sigma85[kk] << " + // error " << error85[kk] << std::endl ; } - - float sigma_new20[SIZE_M]; - float error_new20[SIZE_M]; - float r_error_new20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + float sigma_new20[SIZE_M]; + float error_new20[SIZE_M]; + float r_error_new20[SIZE_M]; + for (int kk = 0; kk < SIZE_M; kk++) { sigma_new20[kk] = sigma_new[kk][1]; error_new20[kk] = error_new_sigma_new[kk][1]; - r_error_new20[kk] = 100*(error_new_sigma_new[kk][1]/sigma_new[kk][1]); - std::cout << " polar angle = 20, momentum " << Momentum[kk] << " kk " << kk << " sigma_new20 " << sigma_new20[kk] << " error " << error_new20[kk] << std::endl ; - } + r_error_new20[kk] = 100 * (error_new_sigma_new[kk][1] / sigma_new[kk][1]); + std::cout << " polar angle = 20, momentum " << Momentum[kk] << " kk " << kk << " sigma_new20 " << sigma_new20[kk] + << " error " << error_new20[kk] << std::endl; + } float sigma_new10[SIZE_M]; float error_new10[SIZE_M]; float r_error_new10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma_new10[kk] = sigma_new[kk][0]; error_new10[kk] = error_new_sigma_new[kk][0]; - //std::cout << " polar angle = 10, momentum " << Momentum[kk] << " kk " << kk << " sigma_new10 " << sigma_new10[kk] << " error " << error_new10[kk] << std::endl ; + // std::cout << " polar angle = 10, momentum " << Momentum[kk] << " kk " << kk << " sigma_new10 " << sigma_new10[kk] + // << " error " << error_new10[kk] << std::endl ; } - + float sigma_new40[SIZE_M]; float error_new40[SIZE_M]; float r_error_new40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma_new40[kk] = sigma_new[kk][2]; error_new40[kk] = error_new_sigma_new[kk][2]; - r_error_new40[kk] = 100*(error_new_sigma_new[kk][2]/sigma_new[kk][2]); - //std::cout << " polar angle = 40, momentum " << Momentum[kk] << " kk " << kk << " sigma_new40 " << sigma_new40[kk] << " error " << error_new40[kk] << std::endl ; + r_error_new40[kk] = 100 * (error_new_sigma_new[kk][2] / sigma_new[kk][2]); + // std::cout << " polar angle = 40, momentum " << Momentum[kk] << " kk " << kk << " sigma_new40 " << sigma_new40[kk] + // << " error " << error_new40[kk] << std::endl ; } float sigma_new85[SIZE_M]; float error_new85[SIZE_M]; float r_error_new85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma_new85[kk] = sigma_new[kk][3]; error_new85[kk] = error_new_sigma_new[kk][3]; - r_error_new85[kk] = 100*(error_new_sigma_new[kk][3]/sigma_new[kk][3]); - //std::cout << " polar angle = 85, momentum " << Momentum[kk] << " kk " << kk << " sigma_new85 " << sigma_new85[kk] << " error " << error_new85[kk] << std::endl ; - + r_error_new85[kk] = 100 * (error_new_sigma_new[kk][3] / sigma_new[kk][3]); + // std::cout << " polar angle = 85, momentum " << Momentum[kk] << " kk " << kk << " sigma_new85 " << sigma_new85[kk] + // << " error " << error_new85[kk] << std::endl ; } - - - - - - - TCanvas *c_two = new TCanvas("IPResolutionBar","IP Resolution",200,10,700,500); - //c_two->Divide(1,2); - //c_two->cd(1); - //TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); - - TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); - Muon_plot20 -> SetTitle("IP Resolution"); - Muon_plot20 -> SetMarkerColor(4); - Muon_plot20 -> SetMarkerStyle(23); - Muon_plot20 -> SetMarkerSize(1); - Muon_plot20 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot20 -> GetYaxis() -> SetTitle("#sigma_{d0}(#mum)"); - Muon_plot20 -> SetMinimum( pow(10,-4) ); - //Muon_plot20 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot20 -> SetMaximum(1. ); - Muon_plot20 -> Draw("AP"); - - TGraphErrors *Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); - Muon_plot40 -> SetTitle("IP Resolution"); - Muon_plot40 -> SetMarkerColor(2); - Muon_plot40 -> SetMarkerStyle(23); - Muon_plot40 -> SetMarkerSize(1); - //Muon_plot40 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot40 -> SetMinimum( pow(10,-5) ); - //Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot40 -> Draw("P"); - - TGraphErrors *Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); - Muon_plot10 -> SetTitle("IP Resolution"); - Muon_plot10 -> SetMarkerColor(6); - Muon_plot10 -> SetMarkerStyle(23); - Muon_plot10 -> SetMarkerSize(1); - Muon_plot10 -> Draw("P"); - - TGraphErrors *Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); - Muon_plot85 -> SetTitle("IP Resolution"); - Muon_plot85 -> SetMarkerColor(1); - Muon_plot85 -> SetMarkerStyle(23); - Muon_plot85 -> SetMarkerSize(1); - //Muon_plot85 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot85 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot85 -> SetMinimum( pow(10,-5) ); - // Muon_plot85 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot85 -> Draw("P"); - - - - - TGraphErrors* Muon_plot_new20 = new TGraphErrors(SIZE_M, Momentum, sigma_new20, zeros, error_new20); - - Muon_plot_new20 -> SetTitle("IP Resolution"); - Muon_plot_new20 -> SetMarkerColor(4); - Muon_plot_new20 -> SetMarkerStyle(32); - Muon_plot_new20 -> SetMarkerSize(1); - //Muon_plot_new20 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot_new20 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot_new20 -> SetMinimum( pow(10,-5) ); - //Muon_plot_new20 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot_new20 -> Draw("P"); - - TGraphErrors *Muon_plot_new40 = new TGraphErrors(SIZE_M, Momentum, sigma_new40, zeros, error_new40); - Muon_plot_new40 -> SetTitle("IP Resolution"); - Muon_plot_new40 -> SetMarkerColor(2); - Muon_plot_new40 -> SetMarkerStyle(32); - Muon_plot_new40 -> SetMarkerSize(1); - //Muon_plot_new40 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot_new40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot_new40 -> SetMinimum( pow(10,-5) ); - //Muon_plot_new40 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot_new40 -> Draw("P"); - - TGraphErrors *Muon_plot_new10 = new TGraphErrors(SIZE_M, Momentum, sigma_new10, zeros, error_new10); - Muon_plot_new10 -> SetTitle("IP Resolution"); - Muon_plot_new10 -> SetMarkerColor(6); - Muon_plot_new10 -> SetMarkerStyle(32); - Muon_plot_new10 -> SetMarkerSize(1); - Muon_plot_new10 -> Draw("P"); - - TGraphErrors *Muon_plot_new85 = new TGraphErrors(SIZE_M, Momentum, sigma_new85, zeros, error_new85); - Muon_plot_new85 -> SetTitle("IP Resolution"); - Muon_plot_new85 -> SetMarkerColor(1); - Muon_plot_new85 -> SetMarkerStyle(32); - Muon_plot_new85 -> SetMarkerSize(1); - Muon_plot_new85 -> Draw("P"); - - - - + TCanvas* c_two = new TCanvas("IPResolutionBar", "IP Resolution", 200, 10, 700, 500); + // c_two->Divide(1,2); + // c_two->cd(1); + // TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); + + TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); + Muon_plot20->SetTitle("IP Resolution"); + Muon_plot20->SetMarkerColor(4); + Muon_plot20->SetMarkerStyle(23); + Muon_plot20->SetMarkerSize(1); + Muon_plot20->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot20->GetYaxis()->SetTitle("#sigma_{d0}(#mum)"); + Muon_plot20->SetMinimum(pow(10, -4)); + // Muon_plot20 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot20->SetMaximum(1.); + Muon_plot20->Draw("AP"); + + TGraphErrors* Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); + Muon_plot40->SetTitle("IP Resolution"); + Muon_plot40->SetMarkerColor(2); + Muon_plot40->SetMarkerStyle(23); + Muon_plot40->SetMarkerSize(1); + // Muon_plot40 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot40 -> SetMinimum( pow(10,-5) ); + // Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot40->Draw("P"); + + TGraphErrors* Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); + Muon_plot10->SetTitle("IP Resolution"); + Muon_plot10->SetMarkerColor(6); + Muon_plot10->SetMarkerStyle(23); + Muon_plot10->SetMarkerSize(1); + Muon_plot10->Draw("P"); + + TGraphErrors* Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); + Muon_plot85->SetTitle("IP Resolution"); + Muon_plot85->SetMarkerColor(1); + Muon_plot85->SetMarkerStyle(23); + Muon_plot85->SetMarkerSize(1); + // Muon_plot85 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot85 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot85 -> SetMinimum( pow(10,-5) ); + // Muon_plot85 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot85->Draw("P"); + + TGraphErrors* Muon_plot_new20 = new TGraphErrors(SIZE_M, Momentum, sigma_new20, zeros, error_new20); + + Muon_plot_new20->SetTitle("IP Resolution"); + Muon_plot_new20->SetMarkerColor(4); + Muon_plot_new20->SetMarkerStyle(32); + Muon_plot_new20->SetMarkerSize(1); + // Muon_plot_new20 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot_new20 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot_new20 -> SetMinimum( pow(10,-5) ); + // Muon_plot_new20 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot_new20->Draw("P"); + + TGraphErrors* Muon_plot_new40 = new TGraphErrors(SIZE_M, Momentum, sigma_new40, zeros, error_new40); + Muon_plot_new40->SetTitle("IP Resolution"); + Muon_plot_new40->SetMarkerColor(2); + Muon_plot_new40->SetMarkerStyle(32); + Muon_plot_new40->SetMarkerSize(1); + // Muon_plot_new40 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot_new40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot_new40 -> SetMinimum( pow(10,-5) ); + // Muon_plot_new40 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot_new40->Draw("P"); + + TGraphErrors* Muon_plot_new10 = new TGraphErrors(SIZE_M, Momentum, sigma_new10, zeros, error_new10); + Muon_plot_new10->SetTitle("IP Resolution"); + Muon_plot_new10->SetMarkerColor(6); + Muon_plot_new10->SetMarkerStyle(32); + Muon_plot_new10->SetMarkerSize(1); + Muon_plot_new10->Draw("P"); + + TGraphErrors* Muon_plot_new85 = new TGraphErrors(SIZE_M, Momentum, sigma_new85, zeros, error_new85); + Muon_plot_new85->SetTitle("IP Resolution"); + Muon_plot_new85->SetMarkerColor(1); + Muon_plot_new85->SetMarkerStyle(32); + Muon_plot_new85->SetMarkerSize(1); + Muon_plot_new85->Draw("P"); c_two->SetLogx(); c_two->SetLogy(); c_two->SetTickx(1); c_two->SetTicky(1); - TLegend *leg = new TLegend(0.6,0.7,0.75,0.95); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot10,"#theta = 10^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot20,"#theta = 20^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot40,"#theta = 40^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot85,"#theta = 85^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot_new10,"#theta = 10^{o} DD4hep/DDKalTest","p"); - leg->AddEntry(Muon_plot_new20,"#theta = 20^{o} DD4hep/DDKalTest","p"); - leg->AddEntry(Muon_plot_new40,"#theta = 40^{o} DD4hep/DDKalTest","p"); - leg->AddEntry(Muon_plot_new85,"#theta = 85^{o} DD4hep/DDKalTest","p"); + TLegend* leg = new TLegend(0.6, 0.7, 0.75, 0.95); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot10, "#theta = 10^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot20, "#theta = 20^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot40, "#theta = 40^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot85, "#theta = 85^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot_new10, "#theta = 10^{o} DD4hep/DDKalTest", "p"); + leg->AddEntry(Muon_plot_new20, "#theta = 20^{o} DD4hep/DDKalTest", "p"); + leg->AddEntry(Muon_plot_new40, "#theta = 40^{o} DD4hep/DDKalTest", "p"); + leg->AddEntry(Muon_plot_new85, "#theta = 85^{o} DD4hep/DDKalTest", "p"); leg->Draw(); - } - - - - - - - - diff --git a/tracking/macros/Efficiency.C b/tracking/macros/Efficiency.C index 9ce8611..7bdab5f 100644 --- a/tracking/macros/Efficiency.C +++ b/tracking/macros/Efficiency.C @@ -1,8 +1,6 @@ -void Efficiency() -{ - TFile *f1 = new TFile("../scripts/ildperf.root", "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - TCanvas *eff = (TCanvas*) f1->Get("eff"); +void Efficiency() { + TFile* f1 = new TFile("../scripts/ildperf.root", "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + TCanvas* eff = (TCanvas*)f1->Get("eff"); eff->Draw(); - } diff --git a/tracking/macros/EfficiencyL5.C b/tracking/macros/EfficiencyL5.C index b157155..f424670 100644 --- a/tracking/macros/EfficiencyL5.C +++ b/tracking/macros/EfficiencyL5.C @@ -1,6 +1,7 @@ -void EfficiencyL5(){ +void EfficiencyL5() { - TFile* fttbar = new TFile("../Results/Analysis/ILD_l5_v02/analysis_ILD_l5_v02_E0500-TDR_ws.Pyycyyc.Gwhizard-1.95.eR.pL.I36919.05.root"); + TFile* fttbar = new TFile( + "../Results/Analysis/ILD_l5_v02/analysis_ILD_l5_v02_E0500-TDR_ws.Pyycyyc.Gwhizard-1.95.eR.pL.I36919.05.root"); /* TCanvas *eff = (TCanvas*) f->Get("eff"); @@ -12,18 +13,17 @@ void EfficiencyL5(){ effPM->SaveAs("trkEff_v02_ILD_l5_v02.png"); */ - //////// vs pt // no overlay - TH1F *h_reconstructable_pt_noOverlay = (TH1F*) fttbar->Get("hist_pt_t"); - TH1F *h_reconstructed_pt_noOverlay = (TH1F*) fttbar->Get("hist_pt_f"); + TH1F* h_reconstructable_pt_noOverlay = (TH1F*)fttbar->Get("hist_pt_t"); + TH1F* h_reconstructed_pt_noOverlay = (TH1F*)fttbar->Get("hist_pt_f"); - TEfficiency *h_efficiency_pt_noOverlay = 0; + TEfficiency* h_efficiency_pt_noOverlay = 0; - if(TEfficiency::CheckConsistency(*h_reconstructed_pt_noOverlay,*h_reconstructable_pt_noOverlay)){ - h_efficiency_pt_noOverlay = new TEfficiency(*h_reconstructed_pt_noOverlay,*h_reconstructable_pt_noOverlay); + if (TEfficiency::CheckConsistency(*h_reconstructed_pt_noOverlay, *h_reconstructable_pt_noOverlay)) { + h_efficiency_pt_noOverlay = new TEfficiency(*h_reconstructed_pt_noOverlay, *h_reconstructable_pt_noOverlay); } //////// @@ -32,21 +32,20 @@ void EfficiencyL5(){ // no overlay - TH1F *h_reconstructable_theta_noOverlay = (TH1F*) fttbar->Get("hist_th_t"); - TH1F *h_reconstructed_theta_noOverlay = (TH1F*) fttbar->Get("hist_th_f"); + TH1F* h_reconstructable_theta_noOverlay = (TH1F*)fttbar->Get("hist_th_t"); + TH1F* h_reconstructed_theta_noOverlay = (TH1F*)fttbar->Get("hist_th_f"); - TEfficiency *h_efficiency_theta_noOverlay = 0; + TEfficiency* h_efficiency_theta_noOverlay = 0; - if(TEfficiency::CheckConsistency(*h_reconstructed_theta_noOverlay,*h_reconstructable_theta_noOverlay)){ - h_efficiency_theta_noOverlay = new TEfficiency(*h_reconstructed_theta_noOverlay,*h_reconstructable_theta_noOverlay); + if (TEfficiency::CheckConsistency(*h_reconstructed_theta_noOverlay, *h_reconstructable_theta_noOverlay)) { + h_efficiency_theta_noOverlay = + new TEfficiency(*h_reconstructed_theta_noOverlay, *h_reconstructable_theta_noOverlay); } - - //////// PLOTTING // vs pt - TCanvas *c_pt = new TCanvas(); + TCanvas* c_pt = new TCanvas(); c_pt->SetLogx(); h_efficiency_pt_noOverlay->SetTitle(";p_{T} [GeV/c];Tracking efficiency"); h_efficiency_pt_noOverlay->SetLineColor(kRed); @@ -58,22 +57,21 @@ void EfficiencyL5(){ auto graph_pt_noOverlay = h_efficiency_pt_noOverlay->GetPaintedGraph(); - graph_pt_noOverlay->GetYaxis()->SetRangeUser(0.0,1.03); - graph_pt_noOverlay->GetXaxis()->SetLimits(0.1,100.0); + graph_pt_noOverlay->GetYaxis()->SetRangeUser(0.0, 1.03); + graph_pt_noOverlay->GetXaxis()->SetLimits(0.1, 100.0); graph_pt_noOverlay->GetXaxis()->SetTitleOffset(1.2); gPad->Update(); - auto legend0_pt = new TLegend(0.461153,0.242604,0.906015,0.363905); + auto legend0_pt = new TLegend(0.461153, 0.242604, 0.906015, 0.363905); legend0_pt->SetHeader("t#bar{t} @ 500GeV ILD_l5_v02"); - legend0_pt->AddEntry(h_efficiency_pt_noOverlay,"No background","epl"); + legend0_pt->AddEntry(h_efficiency_pt_noOverlay, "No background", "epl"); legend0_pt->Draw(); c_pt->SaveAs("trkEff_pt_ttbar_ILD_l5_v02.png"); - - // vs theta - TCanvas *c_theta = new TCanvas(); + // vs theta + TCanvas* c_theta = new TCanvas(); h_efficiency_theta_noOverlay->SetTitle(";cos(#theta) ;Tracking efficiency"); h_efficiency_theta_noOverlay->SetLineColor(kRed); h_efficiency_theta_noOverlay->SetMarkerColor(kRed); @@ -84,17 +82,16 @@ void EfficiencyL5(){ auto graph_theta_noOverlay = h_efficiency_theta_noOverlay->GetPaintedGraph(); - graph_theta_noOverlay->GetYaxis()->SetRangeUser(0.7,1.01); - graph_theta_noOverlay->GetXaxis()->SetLimits(0.0,1.0); + graph_theta_noOverlay->GetYaxis()->SetRangeUser(0.7, 1.01); + graph_theta_noOverlay->GetXaxis()->SetLimits(0.0, 1.0); graph_theta_noOverlay->GetXaxis()->SetTitleOffset(1.2); gPad->Update(); - auto legend0_theta = new TLegend(0.461153,0.242604,0.906015,0.363905); + auto legend0_theta = new TLegend(0.461153, 0.242604, 0.906015, 0.363905); legend0_theta->SetHeader("t#bar{t} @ 500GeV ILD_l5_v02"); - legend0_theta->AddEntry(h_efficiency_theta_noOverlay,"No background","epl"); + legend0_theta->AddEntry(h_efficiency_theta_noOverlay, "No background", "epl"); legend0_theta->Draw(); c_theta->SaveAs("trkEff_theta_ttbar_ILD_l5_v02.png"); - } diff --git a/tracking/macros/PResolution.C b/tracking/macros/PResolution.C index 8fee908..a63a409 100644 --- a/tracking/macros/PResolution.C +++ b/tracking/macros/PResolution.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 8 @@ -26,173 +25,162 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void PResolution(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void PResolution() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - TFile *f = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TTree *EvalTree = (TTree*)f->Get("EvalTree"); - TTree *EvalTree; - f->GetObject("EvalTree", EvalTree); - - printf( " I am studying file analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); - - vector *PtReco = 0; - vector *PtMCP = 0; - - EvalTree->SetBranchAddress("PtReco", &PtReco); - EvalTree->SetBranchAddress("PtMCP", &PtMCP); - - EvalTree->SetBranchStatus("*",0); //disable all branches - EvalTree->SetBranchStatus("PtReco",1); - EvalTree->SetBranchStatus("PtMCP",1); - - - //getting the correct size of the axis for a good fitting - if (PA[ii] == 85){ //axis for polar angle 85 - if ( (Mom[i]/1.0) > 100){ - LimAxis = 1/(10*Mom[i]/1.0); - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 40){ //axis for polar angle 40 - if ( (Mom[i]/1.0) > 100 && Mom[i] != 300 && Mom[i] != 500){ //I need alternative axis for 300 and 500 GeV. - LimAxis = 1/(10*Mom[i]/1.0); - } - else if (Mom[i] == 300 || Mom[i] == 500){ - LimAxis = 0.0015; - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 20 ){ //axis for polar angle 20 - if ( Mom[i] == 1 ){ LimAxis = 0.3; } - else{ - LimAxis = 0.01; - } - } - else if (PA[ii] == 20 ){ - LimAxis = 0.04; - } - - TH1F* h1 = new TH1F("h1","Momentum Resolution",100, (-1)*LimAxis, LimAxis); - - Long64_t nentries = EvalTree->GetEntriesFast(); - for (Long64_t jentry=0; jentryGetEntry(jentry); - for (int unsigned k = 0; k < PtReco->size(); k++){ - float MomentumResolution = (PtReco->at(k) - PtMCP->at(k))/pow(PtMCP->at(k), 2); - h1->Fill( MomentumResolution); - } - } - - h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); - sigma[i][ii] = fit1->GetParameter(2); - error_sigma[i][ii] = fit1->GetParError(2); - - //std::cout << " sigma " << sigma[i][ii] <Get("EvalTree"); + TTree* EvalTree; + f->GetObject("EvalTree", EvalTree); + + printf(" I am studying file analysis_MuonsAngle_%d_Mom_%d.root ", PA[ii], Mom[i]); + + vector* PtReco = 0; + vector* PtMCP = 0; + + EvalTree->SetBranchAddress("PtReco", &PtReco); + EvalTree->SetBranchAddress("PtMCP", &PtMCP); + + EvalTree->SetBranchStatus("*", 0); // disable all branches + EvalTree->SetBranchStatus("PtReco", 1); + EvalTree->SetBranchStatus("PtMCP", 1); + + // getting the correct size of the axis for a good fitting + if (PA[ii] == 85) { // axis for polar angle 85 + if ((Mom[i] / 1.0) > 100) { + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 40) { // axis for polar angle 40 + if ((Mom[i] / 1.0) > 100 && Mom[i] != 300 && Mom[i] != 500) { // I need alternative axis for 300 and 500 GeV. + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else if (Mom[i] == 300 || Mom[i] == 500) { + LimAxis = 0.0015; + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 20) { // axis for polar angle 20 + if (Mom[i] == 1) { + LimAxis = 0.3; + } else { + LimAxis = 0.01; + } + } else if (PA[ii] == 20) { + LimAxis = 0.04; + } + + TH1F* h1 = new TH1F("h1", "Momentum Resolution", 100, (-1) * LimAxis, LimAxis); + + Long64_t nentries = EvalTree->GetEntriesFast(); + for (Long64_t jentry = 0; jentry < nentries; jentry++) { + EvalTree->GetEntry(jentry); + for (int unsigned k = 0; k < PtReco->size(); k++) { + float MomentumResolution = (PtReco->at(k) - PtMCP->at(k)) / pow(PtMCP->at(k), 2); + h1->Fill(MomentumResolution); + } + } + + h1->Fit("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); + sigma[i][ii] = fit1->GetParameter(2); + error_sigma[i][ii] = fit1->GetParError(2); + + // std::cout << " sigma " << sigma[i][ii] <Divide(1,2); - //c_two->cd(1); - //TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); - - TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); - Muon_plot20 -> SetTitle("Momentum Resolution"); - Muon_plot20 -> SetMarkerColor(4); - Muon_plot20 -> SetMarkerStyle(22); - Muon_plot20 -> SetMarkerSize(1); - Muon_plot20 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot20 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - Muon_plot20 -> SetMinimum( pow(10,-5) ); - Muon_plot20 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot20 -> Draw("AP"); - - TGraphErrors *Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); - Muon_plot40 -> SetTitle("Momentum Resolution"); - Muon_plot40 -> SetMarkerColor(2); - Muon_plot40 -> SetMarkerStyle(21); - Muon_plot40 -> SetMarkerSize(1); - //Muon_plot40 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot40 -> SetMinimum( pow(10,-5) ); - //Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot40 -> Draw("P"); - - TGraphErrors *Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); - Muon_plot10 -> SetTitle("Momentum Resolution"); - Muon_plot10 -> SetMarkerColor(6); - Muon_plot10 -> SetMarkerStyle(20); - Muon_plot10 -> SetMarkerSize(1); - Muon_plot10 -> Draw("P"); - - TGraphErrors *Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); - Muon_plot85 -> SetTitle("Momentum Resolution"); - Muon_plot85 -> SetMarkerColor(1); - Muon_plot85 -> SetMarkerStyle(20); - Muon_plot85 -> SetMarkerSize(1); - Muon_plot85 -> Draw("P"); + TCanvas* c_two = new TCanvas("MomentumResolutionBar", "Momentum Resolution", 200, 10, 700, 500); + // c_two->Divide(1,2); + // c_two->cd(1); + // TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); + + TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); + Muon_plot20->SetTitle("Momentum Resolution"); + Muon_plot20->SetMarkerColor(4); + Muon_plot20->SetMarkerStyle(22); + Muon_plot20->SetMarkerSize(1); + Muon_plot20->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot20->GetYaxis()->SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + Muon_plot20->SetMinimum(pow(10, -5)); + Muon_plot20->SetMaximum(2 * pow(10, -1)); + Muon_plot20->Draw("AP"); + + TGraphErrors* Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); + Muon_plot40->SetTitle("Momentum Resolution"); + Muon_plot40->SetMarkerColor(2); + Muon_plot40->SetMarkerStyle(21); + Muon_plot40->SetMarkerSize(1); + // Muon_plot40 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot40 -> SetMinimum( pow(10,-5) ); + // Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot40->Draw("P"); + + TGraphErrors* Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); + Muon_plot10->SetTitle("Momentum Resolution"); + Muon_plot10->SetMarkerColor(6); + Muon_plot10->SetMarkerStyle(20); + Muon_plot10->SetMarkerSize(1); + Muon_plot10->Draw("P"); + + TGraphErrors* Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); + Muon_plot85->SetTitle("Momentum Resolution"); + Muon_plot85->SetMarkerColor(1); + Muon_plot85->SetMarkerStyle(20); + Muon_plot85->SetMarkerSize(1); + Muon_plot85->Draw("P"); c_two->SetLogx(); c_two->SetLogy(); c_two->SetTickx(1); c_two->SetTicky(1); - TLegend *leg = new TLegend(0.6,0.7,0.75,0.95); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot10,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot20,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot40,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot85,"#theta = 85^{o}","p"); + TLegend* leg = new TLegend(0.6, 0.7, 0.75, 0.95); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot10, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot20, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot40, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot85, "#theta = 85^{o}", "p"); leg->Draw(); - } diff --git a/tracking/macros/PResolutionL5.C b/tracking/macros/PResolutionL5.C index 28cf033..684c63d 100644 --- a/tracking/macros/PResolutionL5.C +++ b/tracking/macros/PResolutionL5.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 8 @@ -26,201 +25,196 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void PResolutionL5(){ +void PResolutionL5() { - TCanvas *PR_fit = new TCanvas("PR fit","PR fit",800,800); + TCanvas* PR_fit = new TCanvas("PR fit", "PR fit", 800, 800); PR_fit->Print("PR_fit_ILD_l5_v02.pdf["); - for (int ll = 0; ll < SIZE_M; ll++){ + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - TFile *f = new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TTree *EvalTree = (TTree*)f->Get("EvalTree"); - TTree *EvalTree; - f->GetObject("EvalTree", EvalTree); - - printf( " I am studying file analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); - - vector *PtReco = 0; - vector *PtMCP = 0; - - EvalTree->SetBranchAddress("PtReco", &PtReco); - EvalTree->SetBranchAddress("PtMCP", &PtMCP); - - EvalTree->SetBranchStatus("*",0); //disable all branches - EvalTree->SetBranchStatus("PtReco",1); - EvalTree->SetBranchStatus("PtMCP",1); - - - //getting the correct size of the axis for a good fitting - if (PA[ii] == 85){ //axis for polar angle 85 - if ( (Mom[i]/1.0) > 100){ - LimAxis = 1/(10*Mom[i]/1.0); - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 40){ //axis for polar angle 40 - if ( (Mom[i]/1.0) > 100 && Mom[i] != 300 && Mom[i] != 500){ //I need alternative axis for 300 and 500 GeV. - LimAxis = 1/(10*Mom[i]/1.0); - } - else if (Mom[i] == 300 || Mom[i] == 500){ - LimAxis = 0.0015; - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 20 ){ //axis for polar angle 20 - if ( Mom[i] == 1 ){ LimAxis = 0.3; } - else{ - LimAxis = 1.0/10.0/Mom[i]; - } - } - else if (PA[ii] < 20 ){ - LimAxis = 1.0/Mom[i]; - } - - std::string dummy("Title: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); - std::sprintf( &dummy[0] , "Title: MuonsAngle_%d_Mom_%d" , PA[ii], Mom[i] ) ; - - TH1F* h1 = new TH1F("h1","Momentum Resolution",100, (-1)*LimAxis, LimAxis); - - Long64_t nentries = EvalTree->GetEntriesFast(); - for (Long64_t jentry=0; jentryGetEntry(jentry); - for (int unsigned k = 0; k < PtReco->size(); k++){ - float MomentumResolution = (PtReco->at(k) - PtMCP->at(k))/pow(PtMCP->at(k), 2); - h1->Fill( MomentumResolution); - } - } - - h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); - sigma[i][ii] = fit1->GetParameter(2); - error_sigma[i][ii] = fit1->GetParError(2); - - //std::cout << " sigma " << sigma[i][ii] <Print("PR_fit_ILD_l5_v02.pdf",&dummy[0]); - - }//loop for each .root files, here I have collected sigma and its error - }//polar angle loop - + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + TFile* f = + new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + // TTree *EvalTree = (TTree*)f->Get("EvalTree"); + TTree* EvalTree; + f->GetObject("EvalTree", EvalTree); + + printf(" I am studying file analysis_MuonsAngle_%d_Mom_%d.root ", PA[ii], Mom[i]); + + vector* PtReco = 0; + vector* PtMCP = 0; + + EvalTree->SetBranchAddress("PtReco", &PtReco); + EvalTree->SetBranchAddress("PtMCP", &PtMCP); + + EvalTree->SetBranchStatus("*", 0); // disable all branches + EvalTree->SetBranchStatus("PtReco", 1); + EvalTree->SetBranchStatus("PtMCP", 1); + + // getting the correct size of the axis for a good fitting + if (PA[ii] == 85) { // axis for polar angle 85 + if ((Mom[i] / 1.0) > 100) { + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 40) { // axis for polar angle 40 + if ((Mom[i] / 1.0) > 100 && Mom[i] != 300 && Mom[i] != 500) { // I need alternative axis for 300 and 500 GeV. + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else if (Mom[i] == 300 || Mom[i] == 500) { + LimAxis = 0.0015; + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 20) { // axis for polar angle 20 + if (Mom[i] == 1) { + LimAxis = 0.3; + } else { + LimAxis = 1.0 / 10.0 / Mom[i]; + } + } else if (PA[ii] < 20) { + LimAxis = 1.0 / Mom[i]; + } + + std::string dummy("Title: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); + std::sprintf(&dummy[0], "Title: MuonsAngle_%d_Mom_%d", PA[ii], Mom[i]); + + TH1F* h1 = new TH1F("h1", "Momentum Resolution", 100, (-1) * LimAxis, LimAxis); + + Long64_t nentries = EvalTree->GetEntriesFast(); + for (Long64_t jentry = 0; jentry < nentries; jentry++) { + EvalTree->GetEntry(jentry); + for (int unsigned k = 0; k < PtReco->size(); k++) { + float MomentumResolution = (PtReco->at(k) - PtMCP->at(k)) / pow(PtMCP->at(k), 2); + h1->Fill(MomentumResolution); + } + } + + h1->Fit("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); + sigma[i][ii] = fit1->GetParameter(2); + error_sigma[i][ii] = fit1->GetParError(2); + + // std::cout << " sigma " << sigma[i][ii] <Print("PR_fit_ILD_l5_v02.pdf", &dummy[0]); + + } // loop for each .root files, here I have collected sigma and its error + } // polar angle loop + PR_fit->Print("PR_fit_ILD_l5_v02.pdf]"); - float sigma20[SIZE_M]; - float error20[SIZE_M]; - float r_error20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + float sigma20[SIZE_M]; + float error20[SIZE_M]; + float r_error20[SIZE_M]; + for (int kk = 0; kk < SIZE_M; kk++) { sigma20[kk] = sigma[kk][1]; error20[kk] = error_sigma[kk][1]; - r_error20[kk] = 100*(error_sigma[kk][1]/sigma[kk][1]); - } + r_error20[kk] = 100 * (error_sigma[kk][1] / sigma[kk][1]); + } float sigma10[SIZE_M]; float error10[SIZE_M]; float r_error10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma10[kk] = sigma[kk][0]; error10[kk] = error_sigma[kk][0]; } - + float sigma40[SIZE_M]; float error40[SIZE_M]; float r_error40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma40[kk] = sigma[kk][2]; error40[kk] = error_sigma[kk][2]; - r_error40[kk] = 100*(error_sigma[kk][2]/sigma[kk][2]); + r_error40[kk] = 100 * (error_sigma[kk][2] / sigma[kk][2]); } float sigma85[SIZE_M]; float error85[SIZE_M]; float r_error85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigma85[kk] = sigma[kk][3]; error85[kk] = error_sigma[kk][3]; - r_error85[kk] = 100*(error_sigma[kk][3]/sigma[kk][3]); - std::cout << " polar angle = 85, momentum " << Momentum[kk] << " kk " << kk << " sigma85 " << sigma85[kk] << std::endl ; - + r_error85[kk] = 100 * (error_sigma[kk][3] / sigma[kk][3]); + std::cout << " polar angle = 85, momentum " << Momentum[kk] << " kk " << kk << " sigma85 " << sigma85[kk] + << std::endl; } - - - - TCanvas *c_two = new TCanvas("MomentumResolutionBar","Momentum Resolution",200,10,700,700); - //c_two->Divide(1,2); - //c_two->cd(1); - //TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); - - TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); - Muon_plot20 -> SetTitle("Momentum Resolution"); - Muon_plot20 -> SetMarkerColor(4); - Muon_plot20 -> SetMarkerStyle(22); - Muon_plot20 -> SetMarkerSize(1); - Muon_plot20 -> GetXaxis() -> SetTitle("Momentum (GeV)"); - Muon_plot20 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - Muon_plot20 -> SetMinimum( pow(10,-5) ); - Muon_plot20 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot20 -> Draw("AP"); - - TGraphErrors *Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); - Muon_plot40 -> SetTitle("Momentum Resolution"); - Muon_plot40 -> SetMarkerColor(2); - Muon_plot40 -> SetMarkerStyle(21); - Muon_plot40 -> SetMarkerSize(1); - //Muon_plot40 -> GetXaxis() -> SetTitle("Momentum (GeV)"); - //Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot40 -> SetMinimum( pow(10,-5) ); - //Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot40 -> Draw("P"); - - TGraphErrors *Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); - Muon_plot10 -> SetTitle("Momentum Resolution"); - Muon_plot10 -> SetMarkerColor(6); - Muon_plot10 -> SetMarkerStyle(20); - Muon_plot10 -> SetMarkerSize(1); - Muon_plot10 -> Draw("P"); - - TGraphErrors *Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); - Muon_plot85 -> SetTitle("Momentum Resolution"); - Muon_plot85 -> SetMarkerColor(1); - Muon_plot85 -> SetMarkerStyle(20); - Muon_plot85 -> SetMarkerSize(1); - Muon_plot85 -> Draw("P"); + TCanvas* c_two = new TCanvas("MomentumResolutionBar", "Momentum Resolution", 200, 10, 700, 700); + // c_two->Divide(1,2); + // c_two->cd(1); + // TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); + + TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); + Muon_plot20->SetTitle("Momentum Resolution"); + Muon_plot20->SetMarkerColor(4); + Muon_plot20->SetMarkerStyle(22); + Muon_plot20->SetMarkerSize(1); + Muon_plot20->GetXaxis()->SetTitle("Momentum (GeV)"); + Muon_plot20->GetYaxis()->SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + Muon_plot20->SetMinimum(pow(10, -5)); + Muon_plot20->SetMaximum(2 * pow(10, -1)); + Muon_plot20->Draw("AP"); + + TGraphErrors* Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); + Muon_plot40->SetTitle("Momentum Resolution"); + Muon_plot40->SetMarkerColor(2); + Muon_plot40->SetMarkerStyle(21); + Muon_plot40->SetMarkerSize(1); + // Muon_plot40 -> GetXaxis() -> SetTitle("Momentum (GeV)"); + // Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot40 -> SetMinimum( pow(10,-5) ); + // Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot40->Draw("P"); + + TGraphErrors* Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); + Muon_plot10->SetTitle("Momentum Resolution"); + Muon_plot10->SetMarkerColor(6); + Muon_plot10->SetMarkerStyle(20); + Muon_plot10->SetMarkerSize(1); + Muon_plot10->Draw("P"); + + TGraphErrors* Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); + Muon_plot85->SetTitle("Momentum Resolution"); + Muon_plot85->SetMarkerColor(1); + Muon_plot85->SetMarkerStyle(20); + Muon_plot85->SetMarkerSize(1); + Muon_plot85->Draw("P"); c_two->SetLogx(); c_two->SetLogy(); c_two->SetTickx(1); c_two->SetTicky(1); - TLegend *leg = new TLegend(0.65,0.70,0.80,0.89); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot10,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot20,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot40,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot85,"#theta = 85^{o}","p"); + TLegend* leg = new TLegend(0.65, 0.70, 0.80, 0.89); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot10, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot20, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot40, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot85, "#theta = 85^{o}", "p"); leg->Draw(); - TF1 *fpr10 = new TF1("fpr10","sqrt( 4.e-10 + 1.e-6/(x*x*0.17364817766*0.17364817766) )",0.5,200.0); //for theta =10 degree - fpr10->SetLineColor(6); - //fpr10->Draw("same"); + TF1* fpr10 = + new TF1("fpr10", "sqrt( 4.e-10 + 1.e-6/(x*x*0.17364817766*0.17364817766) )", 0.5, 200.0); // for theta =10 degree + fpr10->SetLineColor(6); + // fpr10->Draw("same"); - TF1 *fpr20 = new TF1("fpr20","sqrt( 4.e-10 + 1.e-6/(x*x*0.34202014332*0.34202014332) )",0.5,200.0); //for theta =20 degree - fpr20->SetLineColor(4); - //fpr20->Draw("same"); + TF1* fpr20 = + new TF1("fpr20", "sqrt( 4.e-10 + 1.e-6/(x*x*0.34202014332*0.34202014332) )", 0.5, 200.0); // for theta =20 degree + fpr20->SetLineColor(4); + // fpr20->Draw("same"); - TF1 *fpr40 = new TF1("fpr40","sqrt( 4.e-10 + 1.e-6/(x*0.64278760968*x*0.64278760968*0.64278760968*0.64278760968) )",0.5,200.0); //for theta =40 degree - fpr40->SetLineColor(2); - //fpr40->Draw("same"); + TF1* fpr40 = new TF1("fpr40", "sqrt( 4.e-10 + 1.e-6/(x*0.64278760968*x*0.64278760968*0.64278760968*0.64278760968) )", + 0.5, 200.0); // for theta =40 degree + fpr40->SetLineColor(2); + // fpr40->Draw("same"); - TF1 *fpr85 = new TF1("fpr85","sqrt( 4.e-10 + 1.e-6/(x*0.99619469809*x*0.99619469809*0.99619469809*0.99619469809) )",0.5,200.0); //for theta =85 degree - fpr85->SetLineColor(1); - //fpr85->Draw("same"); + TF1* fpr85 = new TF1("fpr85", "sqrt( 4.e-10 + 1.e-6/(x*0.99619469809*x*0.99619469809*0.99619469809*0.99619469809) )", + 0.5, 200.0); // for theta =85 degree + fpr85->SetLineColor(1); + // fpr85->Draw("same"); c_two->SaveAs("PResolution_ILD_l5_v02.png"); - } diff --git a/tracking/macros/PResolution_comp.C b/tracking/macros/PResolution_comp.C index 4708887..fe212e5 100644 --- a/tracking/macros/PResolution_comp.C +++ b/tracking/macros/PResolution_comp.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 8 @@ -27,357 +26,323 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void PResolution_comp(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void PResolution_comp() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - TFile *f = new TFile(Form("/afs/desy.de/group/flc/pool/voutsina/SingleMuonTracks/DBD/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - TTree *EvalTree = (TTree*)f->Get("MyRecoMCTruthLinker/EvalTree"); - - printf( " I am studying file analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); - - vector *PtReco; - vector *PtMCP; - + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + TFile* f = + new TFile(Form("/afs/desy.de/group/flc/pool/voutsina/SingleMuonTracks/DBD/analysis_MuonsAngle_%d_Mom_%d.root", + PA[ii], Mom[i]), + "read"); + TTree* EvalTree = (TTree*)f->Get("MyRecoMCTruthLinker/EvalTree"); + + printf(" I am studying file analysis_MuonsAngle_%d_Mom_%d.root ", PA[ii], Mom[i]); + + vector* PtReco; + vector* PtMCP; + EvalTree->SetBranchAddress("PtReco", &PtReco); EvalTree->SetBranchAddress("PtMCP", &PtMCP); - - int num_entries = EvalTree->GetEntries(); + + int num_entries = EvalTree->GetEntries(); EvalTree->GetEntry(0); - - - //getting the correct size of the axis for a good fitting - if (PA[ii] == 85){ //axis for polar angle 85 - if ( (Mom[i]/1.0) > 100){ - LimAxis = 1/(10*Mom[i]/1.0); - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 40){ //axis for polar angle 40 - if ( (Mom[i]/1.0) > 100 && Mom[i] != 300 && Mom[i] != 500){ //I need alternative axis for 300 and 500 GeV. - LimAxis = 1/(10*Mom[i]/1.0); - } - else if (Mom[i] == 300 || Mom[i] == 500){ - LimAxis = 0.0015; - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 20 ){ //axis for polar angle 20 - if ( Mom[i] == 1 ){ LimAxis = 0.3; } - else{ - LimAxis = 0.01; - } - } - else if (PA[ii] == 20 ){ - LimAxis = 0.04; - } - else if (PA[ii] == 10 ){ - LimAxis = 0.5; + + // getting the correct size of the axis for a good fitting + if (PA[ii] == 85) { // axis for polar angle 85 + if ((Mom[i] / 1.0) > 100) { + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 40) { // axis for polar angle 40 + if ((Mom[i] / 1.0) > 100 && Mom[i] != 300 && Mom[i] != 500) { // I need alternative axis for 300 and 500 GeV. + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else if (Mom[i] == 300 || Mom[i] == 500) { + LimAxis = 0.0015; + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 20) { // axis for polar angle 20 + if (Mom[i] == 1) { + LimAxis = 0.3; + } else { + LimAxis = 0.01; + } + } else if (PA[ii] == 20) { + LimAxis = 0.04; + } else if (PA[ii] == 10) { + LimAxis = 0.5; } - TH1F* h1 = new TH1F("h1","Momentum Resolution",100, (-1)*LimAxis, LimAxis); - - for (int j = 0; j < num_entries; j++ ){ - EvalTree->GetEntry(j); - for (int unsigned k = 0; k < PtReco->size(); k++){ - float MomentumResolution = (PtReco->at(k) - PtMCP->at(k))/pow(PtMCP->at(k), 2); - h1->Fill( MomentumResolution); - } + TH1F* h1 = new TH1F("h1", "Momentum Resolution", 100, (-1) * LimAxis, LimAxis); + + for (int j = 0; j < num_entries; j++) { + EvalTree->GetEntry(j); + for (int unsigned k = 0; k < PtReco->size(); k++) { + float MomentumResolution = (PtReco->at(k) - PtMCP->at(k)) / pow(PtMCP->at(k), 2); + h1->Fill(MomentumResolution); + } } - + h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); sigma[i][ii] = fit1->GetParameter(2); - error_sigma[i][ii] = fit1->GetParError(2); - - //std::cout << " sigma " << sigma[i][ii] <GetParError(2); + // std::cout << " sigma " << sigma[i][ii] <Get("EvalTree"); - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ + // printf( " I am studying file + // /nfs/dust/ilc/user/voutsina/testarea/CodeTest/fitting/ILDPerformance/trunk/tracking/Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root + // ",PA[ii],Mom[i]); - TFile *fnew = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - TTree *EvalTreeNew = (TTree*)fnew->Get("EvalTree"); - - //printf( " I am studying file /nfs/dust/ilc/user/voutsina/testarea/CodeTest/fitting/ILDPerformance/trunk/tracking/Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root ",PA[ii],Mom[i]); + vector* PtReco; + vector* PtMCP; - vector *PtReco; - vector *PtMCP; - EvalTreeNew->SetBranchAddress("PtReco", &PtReco); EvalTreeNew->SetBranchAddress("PtMCP", &PtMCP); - - int num_entries = EvalTreeNew->GetEntries(); - + + int num_entries = EvalTreeNew->GetEntries(); + EvalTreeNew->GetEntry(0); - - - //getting the correct size of the axis for a good fitting - if (PA[ii] == 85){ //axis for polar angle 85 - if ( (Mom[i]/1.0) > 100){ - LimAxis = 1/(10*Mom[i]/1.0); - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 40){ //axis for polar angle 40 - if ( (Mom[i]/1.0) > 100 && Mom[i] != 300 && Mom[i] != 500){ //I need alternative axis for 300 and 500 GeV. - LimAxis = 1/(10*Mom[i]/1.0); - } - else if (Mom[i] == 300 || Mom[i] == 500){ - LimAxis = 0.0015; - } - else{ - LimAxis = 1/(100*Mom[i]/1.0); - } - } - else if (PA[ii] == 20 ){ //axis for polar angle 20 - if ( Mom[i] == 1 ){ LimAxis = 0.3; } - else{ - LimAxis = 0.01; - } - } - else if (PA[ii] == 20 ){ - LimAxis = 0.04; + + // getting the correct size of the axis for a good fitting + if (PA[ii] == 85) { // axis for polar angle 85 + if ((Mom[i] / 1.0) > 100) { + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 40) { // axis for polar angle 40 + if ((Mom[i] / 1.0) > 100 && Mom[i] != 300 && Mom[i] != 500) { // I need alternative axis for 300 and 500 GeV. + LimAxis = 1 / (10 * Mom[i] / 1.0); + } else if (Mom[i] == 300 || Mom[i] == 500) { + LimAxis = 0.0015; + } else { + LimAxis = 1 / (100 * Mom[i] / 1.0); + } + } else if (PA[ii] == 20) { // axis for polar angle 20 + if (Mom[i] == 1) { + LimAxis = 0.3; + } else { + LimAxis = 0.01; + } + } else if (PA[ii] == 20) { + LimAxis = 0.04; } - - else if (PA[ii] == 10 ){ - LimAxis = 0.5; + + else if (PA[ii] == 10) { + LimAxis = 0.5; } - - TH1F* h1 = new TH1F("h1","Momentum Resolution",100, (-1)*LimAxis, LimAxis); - - for (int j = 0; j < num_entries; j++ ){ - EvalTreeNew->GetEntry(j); - for (int unsigned k = 0; k < PtReco->size(); k++){ - float MomentumResolution = (PtReco->at(k) - PtMCP->at(k))/pow(PtMCP->at(k), 2); - h1->Fill( MomentumResolution); - } + + TH1F* h1 = new TH1F("h1", "Momentum Resolution", 100, (-1) * LimAxis, LimAxis); + + for (int j = 0; j < num_entries; j++) { + EvalTreeNew->GetEntry(j); + for (int unsigned k = 0; k < PtReco->size(); k++) { + float MomentumResolution = (PtReco->at(k) - PtMCP->at(k)) / pow(PtMCP->at(k), 2); + h1->Fill(MomentumResolution); + } } - + h1->Fit("gaus"); - TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); + TF1* fit1 = (TF1*)h1->GetFunction("gaus"); sigma_new[i][ii] = fit1->GetParameter(2); - error_new_sigma_new[i][ii] = fit1->GetParError(2); - - //std::cout << " sigma " << sigma[i][ii] <GetParError(2); + // std::cout << " sigma " << sigma[i][ii] <Divide(1,2); - //c_two->cd(1); - //TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); - - TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); - Muon_plot20 -> SetTitle("Momentum Resolution"); - Muon_plot20 -> SetMarkerColor(4); - Muon_plot20 -> SetMarkerStyle(23); - Muon_plot20 -> SetMarkerSize(1); - Muon_plot20 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot20 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - Muon_plot20 -> SetMinimum( pow(10,-5) ); - Muon_plot20 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot20 -> Draw("AP"); - - TGraphErrors *Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); - Muon_plot40 -> SetTitle("Momentum Resolution"); - Muon_plot40 -> SetMarkerColor(2); - Muon_plot40 -> SetMarkerStyle(23); - Muon_plot40 -> SetMarkerSize(1); - //Muon_plot40 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot40 -> SetMinimum( pow(10,-5) ); - //Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot40 -> Draw("P"); - - TGraphErrors *Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); - Muon_plot10 -> SetTitle("Momentum Resolution"); - Muon_plot10 -> SetMarkerColor(6); - Muon_plot10 -> SetMarkerStyle(23); - Muon_plot10 -> SetMarkerSize(1); - Muon_plot10 -> Draw("P"); - - TGraphErrors *Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); - Muon_plot85 -> SetTitle("Momentum Resolution"); - Muon_plot85 -> SetMarkerColor(1); - Muon_plot85 -> SetMarkerStyle(23); - Muon_plot85 -> SetMarkerSize(1); - Muon_plot85 -> Draw("P"); - - - - - TGraphErrors* Muon_plot_new20 = new TGraphErrors(SIZE_M, Momentum, sigma_new20, zeros, error_new20); - Muon_plot_new20 -> SetTitle("Momentum Resolution"); - Muon_plot_new20 -> SetMarkerColor(4); - Muon_plot_new20 -> SetMarkerStyle(32); - Muon_plot_new20 -> SetMarkerSize(1); - //Muon_plot_new20 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot_new20 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot_new20 -> SetMinimum( pow(10,-5) ); - //Muon_plot_new20 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot_new20 -> Draw("P"); - - TGraphErrors *Muon_plot_new40 = new TGraphErrors(SIZE_M, Momentum, sigma_new40, zeros, error_new40); - Muon_plot_new40 -> SetTitle("Momentum Resolution"); - Muon_plot_new40 -> SetMarkerColor(2); - Muon_plot_new40 -> SetMarkerStyle(32); - Muon_plot_new40 -> SetMarkerSize(1); - //Muon_plot_new40 -> GetXaxis() -> SetTitle("P (GeV)"); - //Muon_plot_new40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); - //Muon_plot_new40 -> SetMinimum( pow(10,-5) ); - //Muon_plot_new40 -> SetMaximum( 2*pow(10, -1) ); - Muon_plot_new40 -> Draw("P"); - - TGraphErrors *Muon_plot_new10 = new TGraphErrors(SIZE_M, Momentum, sigma_new10, zeros, error_new10); - Muon_plot_new10 -> SetTitle("Momentum Resolution"); - Muon_plot_new10 -> SetMarkerColor(6); - Muon_plot_new10 -> SetMarkerStyle(32); - Muon_plot_new10 -> SetMarkerSize(1); - Muon_plot_new10 -> Draw("P"); - - TGraphErrors *Muon_plot_new85 = new TGraphErrors(SIZE_M, Momentum, sigma_new85, zeros, error_new85); - Muon_plot_new85 -> SetTitle("Momentum Resolution"); - Muon_plot_new85 -> SetMarkerColor(1); - Muon_plot_new85 -> SetMarkerStyle(32); - Muon_plot_new85 -> SetMarkerSize(1); - Muon_plot_new85 -> Draw("P"); - - - - + TCanvas* c_two = new TCanvas("MomentumResolutionBar", "Momentum Resolution", 200, 10, 700, 500); + // c_two->Divide(1,2); + // c_two->cd(1); + // TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); + + TGraphErrors* Muon_plot20 = new TGraphErrors(SIZE_M, Momentum, sigma20, zeros, error20); + Muon_plot20->SetTitle("Momentum Resolution"); + Muon_plot20->SetMarkerColor(4); + Muon_plot20->SetMarkerStyle(23); + Muon_plot20->SetMarkerSize(1); + Muon_plot20->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot20->GetYaxis()->SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + Muon_plot20->SetMinimum(pow(10, -5)); + Muon_plot20->SetMaximum(2 * pow(10, -1)); + Muon_plot20->Draw("AP"); + + TGraphErrors* Muon_plot40 = new TGraphErrors(SIZE_M, Momentum, sigma40, zeros, error40); + Muon_plot40->SetTitle("Momentum Resolution"); + Muon_plot40->SetMarkerColor(2); + Muon_plot40->SetMarkerStyle(23); + Muon_plot40->SetMarkerSize(1); + // Muon_plot40 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot40 -> SetMinimum( pow(10,-5) ); + // Muon_plot40 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot40->Draw("P"); + + TGraphErrors* Muon_plot10 = new TGraphErrors(SIZE_M, Momentum, sigma10, zeros, error10); + Muon_plot10->SetTitle("Momentum Resolution"); + Muon_plot10->SetMarkerColor(6); + Muon_plot10->SetMarkerStyle(23); + Muon_plot10->SetMarkerSize(1); + Muon_plot10->Draw("P"); + + TGraphErrors* Muon_plot85 = new TGraphErrors(SIZE_M, Momentum, sigma85, zeros, error85); + Muon_plot85->SetTitle("Momentum Resolution"); + Muon_plot85->SetMarkerColor(1); + Muon_plot85->SetMarkerStyle(23); + Muon_plot85->SetMarkerSize(1); + Muon_plot85->Draw("P"); + + TGraphErrors* Muon_plot_new20 = new TGraphErrors(SIZE_M, Momentum, sigma_new20, zeros, error_new20); + Muon_plot_new20->SetTitle("Momentum Resolution"); + Muon_plot_new20->SetMarkerColor(4); + Muon_plot_new20->SetMarkerStyle(32); + Muon_plot_new20->SetMarkerSize(1); + // Muon_plot_new20 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot_new20 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot_new20 -> SetMinimum( pow(10,-5) ); + // Muon_plot_new20 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot_new20->Draw("P"); + + TGraphErrors* Muon_plot_new40 = new TGraphErrors(SIZE_M, Momentum, sigma_new40, zeros, error_new40); + Muon_plot_new40->SetTitle("Momentum Resolution"); + Muon_plot_new40->SetMarkerColor(2); + Muon_plot_new40->SetMarkerStyle(32); + Muon_plot_new40->SetMarkerSize(1); + // Muon_plot_new40 -> GetXaxis() -> SetTitle("P (GeV)"); + // Muon_plot_new40 -> GetYaxis() -> SetTitle("#sigma_{1/p_{T}}(GeV^{-1})"); + // Muon_plot_new40 -> SetMinimum( pow(10,-5) ); + // Muon_plot_new40 -> SetMaximum( 2*pow(10, -1) ); + Muon_plot_new40->Draw("P"); + + TGraphErrors* Muon_plot_new10 = new TGraphErrors(SIZE_M, Momentum, sigma_new10, zeros, error_new10); + Muon_plot_new10->SetTitle("Momentum Resolution"); + Muon_plot_new10->SetMarkerColor(6); + Muon_plot_new10->SetMarkerStyle(32); + Muon_plot_new10->SetMarkerSize(1); + Muon_plot_new10->Draw("P"); + + TGraphErrors* Muon_plot_new85 = new TGraphErrors(SIZE_M, Momentum, sigma_new85, zeros, error_new85); + Muon_plot_new85->SetTitle("Momentum Resolution"); + Muon_plot_new85->SetMarkerColor(1); + Muon_plot_new85->SetMarkerStyle(32); + Muon_plot_new85->SetMarkerSize(1); + Muon_plot_new85->Draw("P"); c_two->SetLogx(); c_two->SetLogy(); c_two->SetTickx(1); c_two->SetTicky(1); - TLegend *leg = new TLegend(0.6,0.7,0.75,0.95); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot10,"#theta = 10^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot20,"#theta = 20^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot40,"#theta = 40^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot85,"#theta = 85^{o} Mokka/KalTest","p"); - leg->AddEntry(Muon_plot_new10,"#theta = 10^{o} DD4hep/DDKalTest","p"); - leg->AddEntry(Muon_plot_new20,"#theta = 20^{o} DD4hep/DDKalTest","p"); - leg->AddEntry(Muon_plot_new40,"#theta = 40^{o} DD4hep/DDKalTest","p"); - leg->AddEntry(Muon_plot_new85,"#theta = 85^{o} DD4hep/DDKalTest","p"); + TLegend* leg = new TLegend(0.6, 0.7, 0.75, 0.95); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot10, "#theta = 10^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot20, "#theta = 20^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot40, "#theta = 40^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot85, "#theta = 85^{o} Mokka/KalTest", "p"); + leg->AddEntry(Muon_plot_new10, "#theta = 10^{o} DD4hep/DDKalTest", "p"); + leg->AddEntry(Muon_plot_new20, "#theta = 20^{o} DD4hep/DDKalTest", "p"); + leg->AddEntry(Muon_plot_new40, "#theta = 40^{o} DD4hep/DDKalTest", "p"); + leg->AddEntry(Muon_plot_new85, "#theta = 85^{o} DD4hep/DDKalTest", "p"); leg->Draw(); - } - - - - - - - - diff --git a/tracking/macros/PatRec.C b/tracking/macros/PatRec.C index 22e2d45..f3f1039 100644 --- a/tracking/macros/PatRec.C +++ b/tracking/macros/PatRec.C @@ -1,10 +1,9 @@ -void PatRec() -{ - TControlBar *bar2 = new TControlBar("vertical"); - bar2->AddButton("Residuals",".x ../macros/Residuals.C", "... >>Residuals<<"); - bar2->AddButton("Pulls",".x ../macros/Pulls.C", "... >>Pulls<<"); - bar2->AddButton("Efficiency",".x ../../tracking/macros/Efficiency.C", "... >>Efficiency<<"); - bar2->AddButton("Bad Tracks",".x ../macros/BadTracks.C", "... >>Bad Tracks<<"); - bar2->AddButton("Exit",".q", "... >>Exit<<"); +void PatRec() { + TControlBar* bar2 = new TControlBar("vertical"); + bar2->AddButton("Residuals", ".x ../macros/Residuals.C", "... >>Residuals<<"); + bar2->AddButton("Pulls", ".x ../macros/Pulls.C", "... >>Pulls<<"); + bar2->AddButton("Efficiency", ".x ../../tracking/macros/Efficiency.C", "... >>Efficiency<<"); + bar2->AddButton("Bad Tracks", ".x ../macros/BadTracks.C", "... >>Bad Tracks<<"); + bar2->AddButton("Exit", ".q", "... >>Exit<<"); bar2->Show(); } diff --git a/tracking/macros/Plots.C b/tracking/macros/Plots.C index 01d5daf..e0d121c 100644 --- a/tracking/macros/Plots.C +++ b/tracking/macros/Plots.C @@ -1,12 +1,11 @@ -void Plots() -{ - TControlBar *bar2 = new TControlBar("vertical"); - //bar2->AddButton("Residuals",".x ../macros/Residuals.C", "... >>Residuals<<"); - bar2->AddButton("Pulls",".x ../macros/Pulls.C", "... >>Pulls<<"); - bar2->AddButton("IPResolution",".x ../macros/D0Resolution.C", "... >>IP Resolution<<"); - bar2->AddButton("Momentum Resolution",".x ../macros/PResolution.C", "... >>Mom. Resolution<<"); - bar2->AddButton("#sigma=f(#theta, P)",".x ../macros/sigma.C", "... >>#sigma=f(#theta, P)<<"); - bar2->AddButton("#means=f(#theta, P)",".x ../macros/mean.C", "... >>#means=f(#theta, P)<<"); - bar2->AddButton("Exit",".q", "... >>Exit<<"); +void Plots() { + TControlBar* bar2 = new TControlBar("vertical"); + // bar2->AddButton("Residuals",".x ../macros/Residuals.C", "... >>Residuals<<"); + bar2->AddButton("Pulls", ".x ../macros/Pulls.C", "... >>Pulls<<"); + bar2->AddButton("IPResolution", ".x ../macros/D0Resolution.C", "... >>IP Resolution<<"); + bar2->AddButton("Momentum Resolution", ".x ../macros/PResolution.C", "... >>Mom. Resolution<<"); + bar2->AddButton("#sigma=f(#theta, P)", ".x ../macros/sigma.C", "... >>#sigma=f(#theta, P)<<"); + bar2->AddButton("#means=f(#theta, P)", ".x ../macros/mean.C", "... >>#means=f(#theta, P)<<"); + bar2->AddButton("Exit", ".q", "... >>Exit<<"); bar2->Show(); } diff --git a/tracking/macros/Pulls.C b/tracking/macros/Pulls.C index 66aad29..80a6517 100644 --- a/tracking/macros/Pulls.C +++ b/tracking/macros/Pulls.C @@ -1,32 +1,31 @@ #include "TSystem.h" #include -void Pulls(const char* ext = ".root") -{ +void Pulls(const char* ext = ".root") { const char* inDir = "../Results/Analysis"; - + char* dir = gSystem->ExpandPathName(inDir); void* dirp = gSystem->OpenDirectory(dir); - + const char* entry; const char* filename[100]; const char* filenametrunk[100]; Int_t n = 0; TString str; - - while((entry = (char*)gSystem->GetDirEntry(dirp))) { + + while ((entry = (char*)gSystem->GetDirEntry(dirp))) { str = entry; - if(str.EndsWith(ext)) + if (str.EndsWith(ext)) filename[n++] = gSystem->ConcatFileName(dir, entry); } - TCanvas *Pulls = new TCanvas("Pulls","Pulls",800,800); + TCanvas* Pulls = new TCanvas("Pulls", "Pulls", 800, 800); Pulls->Print("pulls.pdf["); - - for (Int_t i = 0; i < n; i++){ + + for (Int_t i = 0; i < n; i++) { Printf("file -> %s", filename[i]); - TFile *f1 = new TFile(filename[i], "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + TFile* f1 = new TFile(filename[i], "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); Pulls = (TCanvas*)f1->Get("pulls"); Pulls->SetTitle(filename[i]); @@ -34,13 +33,12 @@ void Pulls(const char* ext = ".root") // strs << "Title: " << filename[i] ; std::string dummy("Title: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); - std::sprintf( &dummy[0] , "Title: %52.52s" , filename[i] ) ; + std::sprintf(&dummy[0], "Title: %52.52s", filename[i]); - //Pulls->Draw(); - //Pulls->Print("pulls.pdf", strs.str().c_str() ); - Pulls->Print("pulls.pdf", &dummy[0]); + // Pulls->Draw(); + // Pulls->Print("pulls.pdf", strs.str().c_str() ); + Pulls->Print("pulls.pdf", &dummy[0]); } Pulls->Print("pulls.pdf]"); - } diff --git a/tracking/macros/Residuals.C b/tracking/macros/Residuals.C index 927880d..8ca1f2f 100644 --- a/tracking/macros/Residuals.C +++ b/tracking/macros/Residuals.C @@ -1,7 +1,6 @@ -void Residuals() -{ - TFile *f1 = new TFile("../scripts/ildperf.root", "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - TCanvas *Residuals = (TCanvas*)f1->Get("residuals"); +void Residuals() { + TFile* f1 = new TFile("../scripts/ildperf.root", "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + TCanvas* Residuals = (TCanvas*)f1->Get("residuals"); Residuals->Draw(); } diff --git a/tracking/macros/eff_comp.C b/tracking/macros/eff_comp.C index 9057b99..8c2ee3c 100644 --- a/tracking/macros/eff_comp.C +++ b/tracking/macros/eff_comp.C @@ -1,34 +1,33 @@ -void eff_comp(){ +void eff_comp() { gStyle->SetFillColor(0); - //option for graphs with statistical error - - TFile *f1 = new TFile("file1.root","read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - TGraphAsymmErrors *grb1 = (TGraphAsymmErrors*)f1->Get("gpt"); - TGraphAsymmErrors *grth1 = (TGraphAsymmErrors*)f1->Get("gth"); + // option for graphs with statistical error + + TFile* f1 = new TFile("file1.root", "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + TGraphAsymmErrors* grb1 = (TGraphAsymmErrors*)f1->Get("gpt"); + TGraphAsymmErrors* grth1 = (TGraphAsymmErrors*)f1->Get("gth"); grb1->SetFillColor(0); - TFile *f2 = new TFile("file2.root","read"); - //TDirectory *d2 = (TDirectory*) f2->Get("MyRecoMCTruthLinker"); - TGraphAsymmErrors *grb2 = (TGraphAsymmErrors*)f2->Get("gpt"); - TGraphAsymmErrors *grth2 = (TGraphAsymmErrors*)f2->Get("gth"); - - TFile *f3 = new TFile("file3.root","read"); - //TDirectory *d3 = (TDirectory*) f3->Get("MyRecoMCTruthLinker"); - TGraphAsymmErrors *grb3 = (TGraphAsymmErrors*)f3->Get("gpt"); - TGraphAsymmErrors *grth3 = (TGraphAsymmErrors*)f3->Get("gth"); - - - TFile *ofile = new TFile("effcomp.root","RECREATE"); + TFile* f2 = new TFile("file2.root", "read"); + // TDirectory *d2 = (TDirectory*) f2->Get("MyRecoMCTruthLinker"); + TGraphAsymmErrors* grb2 = (TGraphAsymmErrors*)f2->Get("gpt"); + TGraphAsymmErrors* grth2 = (TGraphAsymmErrors*)f2->Get("gth"); + + TFile* f3 = new TFile("file3.root", "read"); + // TDirectory *d3 = (TDirectory*) f3->Get("MyRecoMCTruthLinker"); + TGraphAsymmErrors* grb3 = (TGraphAsymmErrors*)f3->Get("gpt"); + TGraphAsymmErrors* grth3 = (TGraphAsymmErrors*)f3->Get("gth"); + + TFile* ofile = new TFile("effcomp.root", "RECREATE"); - TCanvas *c = new TCanvas("c","efficiency",800,800); - c->Divide(1,2); + TCanvas* c = new TCanvas("c", "efficiency", 800, 800); + c->Divide(1, 2); c->SetFillColor(0); - c->cd(1); - gPad->SetLogx() ; - + c->cd(1); + gPad->SetLogx(); + grb1->SetMarkerColor(4); grb1->SetMarkerStyle(22); grb1->Draw("AP"); @@ -38,7 +37,7 @@ void eff_comp(){ grb3->SetMarkerColor(6); grb3->SetMarkerStyle(22); grb3->Draw("P"); - + c->cd(2); grth1->SetMarkerColor(4); grth1->SetMarkerStyle(22); @@ -50,15 +49,14 @@ void eff_comp(){ grth3->SetMarkerStyle(22); grth3->Draw("P"); - TLegend* leg = new TLegend(0.2,0.36,0.55,0.68); - leg->AddEntry(grb1,"","p"); - leg->AddEntry(grb2,"","p"); - leg->AddEntry(grb3,"","p"); - //leg->AddEntry(grb4,"nominal VXD03","p"); + TLegend* leg = new TLegend(0.2, 0.36, 0.55, 0.68); + leg->AddEntry(grb1, "", "p"); + leg->AddEntry(grb2, "", "p"); + leg->AddEntry(grb3, "", "p"); + // leg->AddEntry(grb4,"nominal VXD03","p"); leg->Draw(); - - c->Write(); + c->Write(); ofile->Write(); } diff --git a/tracking/macros/mean.C b/tracking/macros/mean.C index 66a9156..095fd75 100644 --- a/tracking/macros/mean.C +++ b/tracking/macros/mean.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 7 @@ -29,400 +28,364 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void mean(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void mean() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - TFile *f1 = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - - TH1F* hOmega = (TH1F*) f1->Get("OmegaPull"); - TH1F* hPhi = (TH1F*) f1->Get("PhiPull"); - TH1F* hTanLambda = (TH1F*) f1->Get("TanLambdaPull"); - TH1F* hd0 = (TH1F*) f1->Get("d0pull"); - TH1F* hz0 = (TH1F*) f1->Get("z0pull"); - - if (hOmega->GetEntries()>50){ - - hOmega->Fit("gaus"); - TF1 *fit1 = (TF1*)hOmega->GetFunction("gaus"); - meanOmega[i][ii] = fit1->GetParameter(1); - error_meanOmega[i][ii] = fit1->GetParError(1); - - hTanLambda->Fit("gaus"); - TF1 *fit2 = (TF1*)hTanLambda->GetFunction("gaus"); - meanTanLambda[i][ii] = fit2->GetParameter(1); - error_meanTanLambda[i][ii] = fit2->GetParError(1); - - hPhi->Fit("gaus"); - TF1 *fit3 = (TF1*)hPhi->GetFunction("gaus"); - meanPhi[i][ii] = fit3->GetParameter(1); - error_meanPhi[i][ii] = fit3->GetParError(1); - - hd0->Fit("gaus"); - TF1 *fit4 = (TF1*)hd0->GetFunction("gaus"); - meand0[i][ii] = fit4->GetParameter(1); - error_meand0[i][ii] = fit4->GetParError(1); - - hz0->Fit("gaus"); - TF1 *fit5 = (TF1*)hz0->GetFunction("gaus"); - meanz0[i][ii] = fit5->GetParameter(1); - error_meanz0[i][ii] = fit5->GetParError(1); - - - }//loop for each .root files, here I have collected mean and its error - }//polar angle loop - - - + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + TFile* f1 = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + + TH1F* hOmega = (TH1F*)f1->Get("OmegaPull"); + TH1F* hPhi = (TH1F*)f1->Get("PhiPull"); + TH1F* hTanLambda = (TH1F*)f1->Get("TanLambdaPull"); + TH1F* hd0 = (TH1F*)f1->Get("d0pull"); + TH1F* hz0 = (TH1F*)f1->Get("z0pull"); + + if (hOmega->GetEntries() > 50) { + + hOmega->Fit("gaus"); + TF1* fit1 = (TF1*)hOmega->GetFunction("gaus"); + meanOmega[i][ii] = fit1->GetParameter(1); + error_meanOmega[i][ii] = fit1->GetParError(1); + + hTanLambda->Fit("gaus"); + TF1* fit2 = (TF1*)hTanLambda->GetFunction("gaus"); + meanTanLambda[i][ii] = fit2->GetParameter(1); + error_meanTanLambda[i][ii] = fit2->GetParError(1); + + hPhi->Fit("gaus"); + TF1* fit3 = (TF1*)hPhi->GetFunction("gaus"); + meanPhi[i][ii] = fit3->GetParameter(1); + error_meanPhi[i][ii] = fit3->GetParError(1); + + hd0->Fit("gaus"); + TF1* fit4 = (TF1*)hd0->GetFunction("gaus"); + meand0[i][ii] = fit4->GetParameter(1); + error_meand0[i][ii] = fit4->GetParError(1); + + hz0->Fit("gaus"); + TF1* fit5 = (TF1*)hz0->GetFunction("gaus"); + meanz0[i][ii] = fit5->GetParameter(1); + error_meanz0[i][ii] = fit5->GetParError(1); + + } // loop for each .root files, here I have collected mean and its error + } // polar angle loop + float meanOmega10[SIZE_M]; float errorOmega10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega10[kk] = meanOmega[kk][0]; errorOmega10[kk] = error_meanOmega[kk][0]; - } - - + } + float meanOmega20[SIZE_M]; float errorOmega20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega20[kk] = meanOmega[kk][1]; errorOmega20[kk] = error_meanOmega[kk][1]; - } - + } + float meanOmega40[SIZE_M]; float errorOmega40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega40[kk] = meanOmega[kk][2]; errorOmega40[kk] = error_meanOmega[kk][2]; } - + float meanOmega85[SIZE_M]; float errorOmega85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega85[kk] = meanOmega[kk][3]; errorOmega85[kk] = error_meanOmega[kk][3]; } - + float meanTanLambda10[SIZE_M]; float errorTanLambda10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda10[kk] = meanTanLambda[kk][0]; errorTanLambda10[kk] = error_meanTanLambda[kk][0]; - } - + } float meanTanLambda20[SIZE_M]; float errorTanLambda20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda20[kk] = meanTanLambda[kk][1]; errorTanLambda20[kk] = error_meanTanLambda[kk][1]; - } - + } + float meanTanLambda40[SIZE_M]; float errorTanLambda40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda40[kk] = meanTanLambda[kk][2]; errorTanLambda40[kk] = error_meanTanLambda[kk][2]; } - + float meanTanLambda85[SIZE_M]; float errorTanLambda85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda85[kk] = meanTanLambda[kk][3]; errorTanLambda85[kk] = error_meanTanLambda[kk][3]; } - - + float meanPhi10[SIZE_M]; float errorPhi10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi10[kk] = meanPhi[kk][0]; errorPhi10[kk] = error_meanPhi[kk][0]; - } - - + } + float meanPhi20[SIZE_M]; float errorPhi20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi20[kk] = meanPhi[kk][1]; errorPhi20[kk] = error_meanPhi[kk][1]; - } - + } + float meanPhi40[SIZE_M]; float errorPhi40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi40[kk] = meanPhi[kk][2]; errorPhi40[kk] = error_meanPhi[kk][2]; } - + float meanPhi85[SIZE_M]; float errorPhi85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi85[kk] = meanPhi[kk][3]; errorPhi85[kk] = error_meanPhi[kk][3]; } - - + float meand010[SIZE_M]; float errord010[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meand010[kk] = meand0[kk][0]; errord010[kk] = error_meand0[kk][0]; - } + } - float meand020[SIZE_M]; float errord020[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meand020[kk] = meand0[kk][1]; errord020[kk] = error_meand0[kk][1]; - } - + } + float meand040[SIZE_M]; float errord040[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meand040[kk] = meand0[kk][2]; errord040[kk] = error_meand0[kk][2]; } - + float meand085[SIZE_M]; float errord085[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meand085[kk] = meand0[kk][3]; errord085[kk] = error_meand0[kk][3]; } - float meanz010[SIZE_M]; float errorz010[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanz010[kk] = meanz0[kk][0]; errorz010[kk] = error_meanz0[kk][0]; - } - - + } + float meanz020[SIZE_M]; float errorz020[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanz020[kk] = meanz0[kk][1]; errorz020[kk] = error_meanz0[kk][1]; - } - + } + float meanz040[SIZE_M]; float errorz040[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanz040[kk] = meanz0[kk][2]; errorz040[kk] = error_meanz0[kk][2]; } - + float meanz085[SIZE_M]; float errorz085[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanz085[kk] = meanz0[kk][3]; errorz085[kk] = error_meanz0[kk][3]; } - - - TCanvas *c_two = new TCanvas("MomentumResolutionBar","Track Parameters #mean",200,10,700,500); - c_two->Divide(3,2); + TCanvas* c_two = new TCanvas("MomentumResolutionBar", "Track Parameters #mean", 200, 10, 700, 500); + c_two->Divide(3, 2); c_two->cd(1); - //TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, mean20); - - TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, meanOmega10, zeros, errorOmega10); - Muon_plot_omega10 -> SetTitle("#omega"); - Muon_plot_omega10 -> SetMarkerColor(2); - Muon_plot_omega10 -> SetMarkerStyle(24); - Muon_plot_omega10 -> SetMarkerSize(1); - Muon_plot_omega10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_omega10 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_omega10 -> SetMinimum( -0.5 ); - Muon_plot_omega10 -> SetMaximum( 0.5 ); - Muon_plot_omega10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, meanOmega20, zeros, errorOmega20); - Muon_plot_omega20 -> SetMarkerColor(4); - Muon_plot_omega20 -> SetMarkerStyle(22); - Muon_plot_omega20 -> SetMarkerSize(1); - Muon_plot_omega20 -> Draw("P"); - - TGraphErrors *Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, meanOmega40, zeros, errorOmega40); - Muon_plot_omega40 -> SetMarkerColor(2); - Muon_plot_omega40 -> SetMarkerStyle(21); - Muon_plot_omega40 -> SetMarkerSize(1); - Muon_plot_omega40 -> Draw("P"); - - TGraphErrors *Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, meanOmega85, zeros, errorOmega85); - Muon_plot_omega85 -> SetMarkerColor(1); - Muon_plot_omega85 -> SetMarkerStyle(20); - Muon_plot_omega85 -> SetMarkerSize(1); - Muon_plot_omega85 -> Draw("P"); + // TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, mean20); + + TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, meanOmega10, zeros, errorOmega10); + Muon_plot_omega10->SetTitle("#omega"); + Muon_plot_omega10->SetMarkerColor(2); + Muon_plot_omega10->SetMarkerStyle(24); + Muon_plot_omega10->SetMarkerSize(1); + Muon_plot_omega10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_omega10->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_omega10->SetMinimum(-0.5); + Muon_plot_omega10->SetMaximum(0.5); + Muon_plot_omega10->Draw("AP"); + + TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, meanOmega20, zeros, errorOmega20); + Muon_plot_omega20->SetMarkerColor(4); + Muon_plot_omega20->SetMarkerStyle(22); + Muon_plot_omega20->SetMarkerSize(1); + Muon_plot_omega20->Draw("P"); + + TGraphErrors* Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, meanOmega40, zeros, errorOmega40); + Muon_plot_omega40->SetMarkerColor(2); + Muon_plot_omega40->SetMarkerStyle(21); + Muon_plot_omega40->SetMarkerSize(1); + Muon_plot_omega40->Draw("P"); + + TGraphErrors* Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, meanOmega85, zeros, errorOmega85); + Muon_plot_omega85->SetMarkerColor(1); + Muon_plot_omega85->SetMarkerStyle(20); + Muon_plot_omega85->SetMarkerSize(1); + Muon_plot_omega85->Draw("P"); c_two->SetTickx(1); c_two->SetTicky(1); - - + c_two->cd(2); - TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda10, zeros, errorTanLambda10); - Muon_plot_tanlambda10 -> SetTitle("tan #lambda"); - Muon_plot_tanlambda10 -> SetMarkerColor(2); - Muon_plot_tanlambda10 -> SetMarkerStyle(24); - Muon_plot_tanlambda10 -> SetMarkerSize(1); - Muon_plot_tanlambda10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_tanlambda10 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_tanlambda10 -> SetMinimum( -0.5 ); - Muon_plot_tanlambda10 -> SetMaximum( 0.5 ); - Muon_plot_tanlambda10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda20, zeros, errorTanLambda20); - Muon_plot_tanlambda20 -> SetMarkerColor(4); - Muon_plot_tanlambda20 -> SetMarkerStyle(22); - Muon_plot_tanlambda20 -> SetMarkerSize(1); - Muon_plot_tanlambda20 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda40, zeros, errorTanLambda40); - Muon_plot_tanlambda40 -> SetMarkerColor(2); - Muon_plot_tanlambda40 -> SetMarkerStyle(21); - Muon_plot_tanlambda40 -> SetMarkerSize(1); - Muon_plot_tanlambda40 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda85, zeros, errorTanLambda85); - Muon_plot_tanlambda85 -> SetMarkerColor(1); - Muon_plot_tanlambda85 -> SetMarkerStyle(20); - Muon_plot_tanlambda85 -> SetMarkerSize(1); - Muon_plot_tanlambda85 -> Draw("P"); + TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda10, zeros, errorTanLambda10); + Muon_plot_tanlambda10->SetTitle("tan #lambda"); + Muon_plot_tanlambda10->SetMarkerColor(2); + Muon_plot_tanlambda10->SetMarkerStyle(24); + Muon_plot_tanlambda10->SetMarkerSize(1); + Muon_plot_tanlambda10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_tanlambda10->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_tanlambda10->SetMinimum(-0.5); + Muon_plot_tanlambda10->SetMaximum(0.5); + Muon_plot_tanlambda10->Draw("AP"); + + TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda20, zeros, errorTanLambda20); + Muon_plot_tanlambda20->SetMarkerColor(4); + Muon_plot_tanlambda20->SetMarkerStyle(22); + Muon_plot_tanlambda20->SetMarkerSize(1); + Muon_plot_tanlambda20->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda40, zeros, errorTanLambda40); + Muon_plot_tanlambda40->SetMarkerColor(2); + Muon_plot_tanlambda40->SetMarkerStyle(21); + Muon_plot_tanlambda40->SetMarkerSize(1); + Muon_plot_tanlambda40->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda85, zeros, errorTanLambda85); + Muon_plot_tanlambda85->SetMarkerColor(1); + Muon_plot_tanlambda85->SetMarkerStyle(20); + Muon_plot_tanlambda85->SetMarkerSize(1); + Muon_plot_tanlambda85->Draw("P"); c_two->SetTickx(1); c_two->SetTicky(1); - - + c_two->cd(3); - TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, meanPhi10, zeros, errorPhi10); - Muon_plot_phi10 -> SetTitle("#phi"); - Muon_plot_phi10 -> SetMarkerColor(2); - Muon_plot_phi10 -> SetMarkerStyle(24); - Muon_plot_phi10 -> SetMarkerSize(1); - Muon_plot_phi10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_phi10 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_phi10 -> SetMinimum( -0.5 ); - Muon_plot_phi10 -> SetMaximum( 0.5 ); - Muon_plot_phi10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, meanPhi20, zeros, errorPhi20); - Muon_plot_phi20 -> SetMarkerColor(4); - Muon_plot_phi20 -> SetMarkerStyle(22); - Muon_plot_phi20 -> SetMarkerSize(1); - Muon_plot_phi20 -> Draw("P"); - - TGraphErrors *Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, meanPhi40, zeros, errorPhi40); - Muon_plot_phi40 -> SetMarkerColor(2); - Muon_plot_phi40 -> SetMarkerStyle(21); - Muon_plot_phi40 -> SetMarkerSize(1); - Muon_plot_phi40 -> Draw("P"); - - TGraphErrors *Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, meanPhi85, zeros, errorPhi85); - Muon_plot_phi85 -> SetMarkerColor(1); - Muon_plot_phi85 -> SetMarkerStyle(20); - Muon_plot_phi85 -> SetMarkerSize(1); - Muon_plot_phi85 -> Draw("P"); + TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, meanPhi10, zeros, errorPhi10); + Muon_plot_phi10->SetTitle("#phi"); + Muon_plot_phi10->SetMarkerColor(2); + Muon_plot_phi10->SetMarkerStyle(24); + Muon_plot_phi10->SetMarkerSize(1); + Muon_plot_phi10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_phi10->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_phi10->SetMinimum(-0.5); + Muon_plot_phi10->SetMaximum(0.5); + Muon_plot_phi10->Draw("AP"); + + TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, meanPhi20, zeros, errorPhi20); + Muon_plot_phi20->SetMarkerColor(4); + Muon_plot_phi20->SetMarkerStyle(22); + Muon_plot_phi20->SetMarkerSize(1); + Muon_plot_phi20->Draw("P"); + + TGraphErrors* Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, meanPhi40, zeros, errorPhi40); + Muon_plot_phi40->SetMarkerColor(2); + Muon_plot_phi40->SetMarkerStyle(21); + Muon_plot_phi40->SetMarkerSize(1); + Muon_plot_phi40->Draw("P"); + + TGraphErrors* Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, meanPhi85, zeros, errorPhi85); + Muon_plot_phi85->SetMarkerColor(1); + Muon_plot_phi85->SetMarkerStyle(20); + Muon_plot_phi85->SetMarkerSize(1); + Muon_plot_phi85->Draw("P"); c_two->SetTickx(1); c_two->SetTicky(1); - - - - + c_two->cd(4); - TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, meand010, zeros, errord010); - Muon_plot_d010 -> SetTitle("d0"); - Muon_plot_d010 -> SetMarkerColor(2); - Muon_plot_d010 -> SetMarkerStyle(24); - Muon_plot_d010 -> SetMarkerSize(1); - Muon_plot_d010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_d010 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_d010 -> SetMinimum( -0.5 ); - Muon_plot_d010 -> SetMaximum( 0.5 ); - Muon_plot_d010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, meand020, zeros, errord020); - Muon_plot_d020 -> SetMarkerColor(4); - Muon_plot_d020 -> SetMarkerStyle(22); - Muon_plot_d020 -> SetMarkerSize(1); - - Muon_plot_d020 -> Draw("P"); - - TGraphErrors *Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, meand040, zeros, errord040); - Muon_plot_d040 -> SetMarkerColor(2); - Muon_plot_d040 -> SetMarkerStyle(21); - Muon_plot_d040 -> SetMarkerSize(1); - Muon_plot_d040 -> Draw("P"); - - TGraphErrors *Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, meand085, zeros, errord085); - Muon_plot_d085 -> SetMarkerColor(1); - Muon_plot_d085 -> SetMarkerStyle(20); - Muon_plot_d085 -> SetMarkerSize(1); - Muon_plot_d085 -> Draw("P"); - c_two->SetTickx(1); - c_two->SetTicky(1); + TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, meand010, zeros, errord010); + Muon_plot_d010->SetTitle("d0"); + Muon_plot_d010->SetMarkerColor(2); + Muon_plot_d010->SetMarkerStyle(24); + Muon_plot_d010->SetMarkerSize(1); + Muon_plot_d010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_d010->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_d010->SetMinimum(-0.5); + Muon_plot_d010->SetMaximum(0.5); + Muon_plot_d010->Draw("AP"); - - - c_two->cd(5); - TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, meanz010, zeros, errorz010); - Muon_plot_z010 -> SetTitle("z0"); - Muon_plot_z010 -> SetMarkerColor(2); - Muon_plot_z010 -> SetMarkerStyle(24); - Muon_plot_z010 -> SetMarkerSize(1); - Muon_plot_z010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_z010 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_z010 -> SetMinimum( -0.5 ); - Muon_plot_z010 -> SetMaximum( 0.5 ); - Muon_plot_z010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, meanz020, zeros, errorz020); - Muon_plot_z020 -> SetMarkerColor(4); - Muon_plot_z020 -> SetMarkerStyle(22); - Muon_plot_z020 -> SetMarkerSize(1); - Muon_plot_z020 -> Draw("P"); - - TGraphErrors *Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, meanz040, zeros, errorz040); - Muon_plot_z040 -> SetMarkerColor(2); - Muon_plot_z040 -> SetMarkerStyle(21); - Muon_plot_z040 -> SetMarkerSize(1); - Muon_plot_z040 -> Draw("P"); - - TGraphErrors *Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, meanz085, zeros, errorz085); - Muon_plot_z085 -> SetMarkerColor(1); - Muon_plot_z085 -> SetMarkerStyle(20); - Muon_plot_z085 -> SetMarkerSize(1); - Muon_plot_z085 -> Draw("P"); - c_two->SetTickx(1); - c_two->SetTicky(1); - - - + TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, meand020, zeros, errord020); + Muon_plot_d020->SetMarkerColor(4); + Muon_plot_d020->SetMarkerStyle(22); + Muon_plot_d020->SetMarkerSize(1); + Muon_plot_d020->Draw("P"); + TGraphErrors* Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, meand040, zeros, errord040); + Muon_plot_d040->SetMarkerColor(2); + Muon_plot_d040->SetMarkerStyle(21); + Muon_plot_d040->SetMarkerSize(1); + Muon_plot_d040->Draw("P"); + TGraphErrors* Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, meand085, zeros, errord085); + Muon_plot_d085->SetMarkerColor(1); + Muon_plot_d085->SetMarkerStyle(20); + Muon_plot_d085->SetMarkerSize(1); + Muon_plot_d085->Draw("P"); + c_two->SetTickx(1); + c_two->SetTicky(1); + c_two->cd(5); + TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, meanz010, zeros, errorz010); + Muon_plot_z010->SetTitle("z0"); + Muon_plot_z010->SetMarkerColor(2); + Muon_plot_z010->SetMarkerStyle(24); + Muon_plot_z010->SetMarkerSize(1); + Muon_plot_z010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_z010->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_z010->SetMinimum(-0.5); + Muon_plot_z010->SetMaximum(0.5); + Muon_plot_z010->Draw("AP"); + + TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, meanz020, zeros, errorz020); + Muon_plot_z020->SetMarkerColor(4); + Muon_plot_z020->SetMarkerStyle(22); + Muon_plot_z020->SetMarkerSize(1); + Muon_plot_z020->Draw("P"); + TGraphErrors* Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, meanz040, zeros, errorz040); + Muon_plot_z040->SetMarkerColor(2); + Muon_plot_z040->SetMarkerStyle(21); + Muon_plot_z040->SetMarkerSize(1); + Muon_plot_z040->Draw("P"); + TGraphErrors* Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, meanz085, zeros, errorz085); + Muon_plot_z085->SetMarkerColor(1); + Muon_plot_z085->SetMarkerStyle(20); + Muon_plot_z085->SetMarkerSize(1); + Muon_plot_z085->Draw("P"); + c_two->SetTickx(1); + c_two->SetTicky(1); c_two->cd(6); - TLegend *leg = new TLegend(0.6,0.7,0.75,0.95); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot_omega10,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot_omega20,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot_omega40,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot_omega85,"#theta = 85^{o}","p"); + TLegend* leg = new TLegend(0.6, 0.7, 0.75, 0.95); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot_omega10, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot_omega20, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot_omega40, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot_omega85, "#theta = 85^{o}", "p"); leg->Draw(); - } - } diff --git a/tracking/macros/meanL5.C b/tracking/macros/meanL5.C index 21ad928..d712c19 100644 --- a/tracking/macros/meanL5.C +++ b/tracking/macros/meanL5.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 7 @@ -29,8 +28,8 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void meanL5(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void meanL5() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } @@ -75,355 +74,330 @@ void meanL5(){ float meanz085[SIZE_M]; float errorz085[SIZE_M]; + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + TFile* f1 = + new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + + TH1F* hOmega = (TH1F*)f1->Get("OmegaPull"); + TH1F* hPhi = (TH1F*)f1->Get("PhiPull"); + TH1F* hTanLambda = (TH1F*)f1->Get("TanLambdaPull"); + TH1F* hd0 = (TH1F*)f1->Get("d0pull"); + TH1F* hz0 = (TH1F*)f1->Get("z0pull"); + + if (hOmega->GetEntries() > 50) { + + hOmega->Fit("gaus"); + TF1* fit1 = (TF1*)hOmega->GetFunction("gaus"); + meanOmega[i][ii] = fit1->GetParameter(1); + error_meanOmega[i][ii] = fit1->GetParError(1); + + hTanLambda->Fit("gaus"); + TF1* fit2 = (TF1*)hTanLambda->GetFunction("gaus"); + meanTanLambda[i][ii] = fit2->GetParameter(1); + error_meanTanLambda[i][ii] = fit2->GetParError(1); + + hPhi->Fit("gaus"); + TF1* fit3 = (TF1*)hPhi->GetFunction("gaus"); + meanPhi[i][ii] = fit3->GetParameter(1); + error_meanPhi[i][ii] = fit3->GetParError(1); + + hd0->Fit("gaus"); + TF1* fit4 = (TF1*)hd0->GetFunction("gaus"); + meand0[i][ii] = fit4->GetParameter(1); + error_meand0[i][ii] = fit4->GetParError(1); - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - TFile *f1 = new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - - TH1F* hOmega = (TH1F*) f1->Get("OmegaPull"); - TH1F* hPhi = (TH1F*) f1->Get("PhiPull"); - TH1F* hTanLambda = (TH1F*) f1->Get("TanLambdaPull"); - TH1F* hd0 = (TH1F*) f1->Get("d0pull"); - TH1F* hz0 = (TH1F*) f1->Get("z0pull"); - - if (hOmega->GetEntries()>50){ - - hOmega->Fit("gaus"); - TF1 *fit1 = (TF1*)hOmega->GetFunction("gaus"); - meanOmega[i][ii] = fit1->GetParameter(1); - error_meanOmega[i][ii] = fit1->GetParError(1); - - hTanLambda->Fit("gaus"); - TF1 *fit2 = (TF1*)hTanLambda->GetFunction("gaus"); - meanTanLambda[i][ii] = fit2->GetParameter(1); - error_meanTanLambda[i][ii] = fit2->GetParError(1); - - hPhi->Fit("gaus"); - TF1 *fit3 = (TF1*)hPhi->GetFunction("gaus"); - meanPhi[i][ii] = fit3->GetParameter(1); - error_meanPhi[i][ii] = fit3->GetParError(1); - - hd0->Fit("gaus"); - TF1 *fit4 = (TF1*)hd0->GetFunction("gaus"); - meand0[i][ii] = fit4->GetParameter(1); - error_meand0[i][ii] = fit4->GetParError(1); - - hz0->Fit("gaus"); - TF1 *fit5 = (TF1*)hz0->GetFunction("gaus"); - meanz0[i][ii] = fit5->GetParameter(1); - error_meanz0[i][ii] = fit5->GetParError(1); - - - }//loop for each .root files, here I have collected mean and its error - }//polar angle loop - - - - for(int kk=0; kk < SIZE_M; kk++){ + hz0->Fit("gaus"); + TF1* fit5 = (TF1*)hz0->GetFunction("gaus"); + meanz0[i][ii] = fit5->GetParameter(1); + error_meanz0[i][ii] = fit5->GetParError(1); + + } // loop for each .root files, here I have collected mean and its error + } // polar angle loop + + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega10[kk] = meanOmega[kk][0]; errorOmega10[kk] = error_meanOmega[kk][0]; - } - - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega20[kk] = meanOmega[kk][1]; errorOmega20[kk] = error_meanOmega[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega40[kk] = meanOmega[kk][2]; errorOmega40[kk] = error_meanOmega[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meanOmega85[kk] = meanOmega[kk][3]; errorOmega85[kk] = error_meanOmega[kk][3]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda10[kk] = meanTanLambda[kk][0]; errorTanLambda10[kk] = error_meanTanLambda[kk][0]; - } - + } - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda20[kk] = meanTanLambda[kk][1]; errorTanLambda20[kk] = error_meanTanLambda[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda40[kk] = meanTanLambda[kk][2]; errorTanLambda40[kk] = error_meanTanLambda[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meanTanLambda85[kk] = meanTanLambda[kk][3]; errorTanLambda85[kk] = error_meanTanLambda[kk][3]; } - - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi10[kk] = meanPhi[kk][0]; errorPhi10[kk] = error_meanPhi[kk][0]; - } - - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi20[kk] = meanPhi[kk][1]; errorPhi20[kk] = error_meanPhi[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi40[kk] = meanPhi[kk][2]; errorPhi40[kk] = error_meanPhi[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meanPhi85[kk] = meanPhi[kk][3]; errorPhi85[kk] = error_meanPhi[kk][3]; } - - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meand010[kk] = meand0[kk][0]; errord010[kk] = error_meand0[kk][0]; - } + } - - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meand020[kk] = meand0[kk][1]; errord020[kk] = error_meand0[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meand040[kk] = meand0[kk][2]; errord040[kk] = error_meand0[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meand085[kk] = meand0[kk][3]; errord085[kk] = error_meand0[kk][3]; } - - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { meanz010[kk] = meanz0[kk][0]; errorz010[kk] = error_meanz0[kk][0]; - } - - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meanz020[kk] = meanz0[kk][1]; errorz020[kk] = error_meanz0[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { meanz040[kk] = meanz0[kk][2]; errorz040[kk] = error_meanz0[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { meanz085[kk] = meanz0[kk][3]; errorz085[kk] = error_meanz0[kk][3]; } - - } - TCanvas *c_two = new TCanvas("MomentumResolutionBar","Track Parameters #mean",200,10,700,500); - c_two->Divide(3,2); - - c_two->cd(1); - c_two->cd(1)->SetLogx(); - c_two->cd(1)->SetTickx(1); - c_two->cd(1)->SetTicky(1); - - TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, meanOmega10, zeros, errorOmega10); - Muon_plot_omega10 -> SetTitle("#Omega"); - Muon_plot_omega10 -> SetMarkerColor(6); - Muon_plot_omega10 -> SetMarkerStyle(24); - Muon_plot_omega10 -> SetMarkerSize(1); - Muon_plot_omega10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_omega10 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_omega10 -> SetMinimum( -0.50 ); - Muon_plot_omega10 -> SetMaximum( 0.50 ); - Muon_plot_omega10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, meanOmega20, zeros, errorOmega20); - Muon_plot_omega20 -> SetMarkerColor(4); - Muon_plot_omega20 -> SetMarkerStyle(22); - Muon_plot_omega20 -> SetMarkerSize(1); - Muon_plot_omega20 -> Draw("P"); - - TGraphErrors *Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, meanOmega40, zeros, errorOmega40); - Muon_plot_omega40 -> SetMarkerColor(2); - Muon_plot_omega40 -> SetMarkerStyle(21); - Muon_plot_omega40 -> SetMarkerSize(1); - Muon_plot_omega40 -> Draw("P"); - - TGraphErrors *Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, meanOmega85, zeros, errorOmega85); - Muon_plot_omega85 -> SetMarkerColor(1); - Muon_plot_omega85 -> SetMarkerStyle(20); - Muon_plot_omega85 -> SetMarkerSize(1); - Muon_plot_omega85 -> Draw("P"); - - - c_two->cd(2); - c_two->cd(2)->SetLogx(); - c_two->cd(2)->SetTickx(1); - c_two->cd(2)->SetTicky(1); - - TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda10, zeros, errorTanLambda10); - Muon_plot_tanlambda10 -> SetTitle("tan #lambda"); - Muon_plot_tanlambda10 -> SetMarkerColor(6); - Muon_plot_tanlambda10 -> SetMarkerStyle(24); - Muon_plot_tanlambda10 -> SetMarkerSize(1); - Muon_plot_tanlambda10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_tanlambda10 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_tanlambda10 -> SetMinimum( -0.50 ); - Muon_plot_tanlambda10 -> SetMaximum( 0.50 ); - Muon_plot_tanlambda10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda20, zeros, errorTanLambda20); - Muon_plot_tanlambda20 -> SetMarkerColor(4); - Muon_plot_tanlambda20 -> SetMarkerStyle(22); - Muon_plot_tanlambda20 -> SetMarkerSize(1); - Muon_plot_tanlambda20 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda40, zeros, errorTanLambda40); - Muon_plot_tanlambda40 -> SetMarkerColor(2); - Muon_plot_tanlambda40 -> SetMarkerStyle(21); - Muon_plot_tanlambda40 -> SetMarkerSize(1); - Muon_plot_tanlambda40 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda85, zeros, errorTanLambda85); - Muon_plot_tanlambda85 -> SetMarkerColor(1); - Muon_plot_tanlambda85 -> SetMarkerStyle(20); - Muon_plot_tanlambda85 -> SetMarkerSize(1); - Muon_plot_tanlambda85 -> Draw("P"); - - - c_two->cd(3); - c_two->cd(3)->SetLogx(); - c_two->cd(3)->SetTickx(1); - c_two->cd(3)->SetTicky(1); - - TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, meanPhi10, zeros, errorPhi10); - Muon_plot_phi10 -> SetTitle("#phi"); - Muon_plot_phi10 -> SetMarkerColor(6); - Muon_plot_phi10 -> SetMarkerStyle(24); - Muon_plot_phi10 -> SetMarkerSize(1); - Muon_plot_phi10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_phi10 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_phi10 -> SetMinimum( -0.50 ); - Muon_plot_phi10 -> SetMaximum( 0.50 ); - Muon_plot_phi10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, meanPhi20, zeros, errorPhi20); - Muon_plot_phi20 -> SetMarkerColor(4); - Muon_plot_phi20 -> SetMarkerStyle(22); - Muon_plot_phi20 -> SetMarkerSize(1); - Muon_plot_phi20 -> Draw("P"); - - TGraphErrors *Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, meanPhi40, zeros, errorPhi40); - Muon_plot_phi40 -> SetMarkerColor(2); - Muon_plot_phi40 -> SetMarkerStyle(21); - Muon_plot_phi40 -> SetMarkerSize(1); - Muon_plot_phi40 -> Draw("P"); - - TGraphErrors *Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, meanPhi85, zeros, errorPhi85); - Muon_plot_phi85 -> SetMarkerColor(1); - Muon_plot_phi85 -> SetMarkerStyle(20); - Muon_plot_phi85 -> SetMarkerSize(1); - Muon_plot_phi85 -> Draw("P"); - - - c_two->cd(4); - c_two->cd(4)->SetLogx(); - c_two->cd(4)->SetTickx(1); - c_two->cd(4)->SetTicky(1); - - TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, meand010, zeros, errord010); - Muon_plot_d010 -> SetTitle("d0"); - Muon_plot_d010 -> SetMarkerColor(6); - Muon_plot_d010 -> SetMarkerStyle(24); - Muon_plot_d010 -> SetMarkerSize(1); - Muon_plot_d010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_d010 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_d010 -> SetMinimum( -0.50 ); - Muon_plot_d010 -> SetMaximum( 0.50 ); - Muon_plot_d010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, meand020, zeros, errord020); - Muon_plot_d020 -> SetMarkerColor(4); - Muon_plot_d020 -> SetMarkerStyle(22); - Muon_plot_d020 -> SetMarkerSize(1); - Muon_plot_d020 -> Draw("P"); - - TGraphErrors *Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, meand040, zeros, errord040); - Muon_plot_d040 -> SetMarkerColor(2); - Muon_plot_d040 -> SetMarkerStyle(21); - Muon_plot_d040 -> SetMarkerSize(1); - Muon_plot_d040 -> Draw("P"); - - TGraphErrors *Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, meand085, zeros, errord085); - Muon_plot_d085 -> SetMarkerColor(1); - Muon_plot_d085 -> SetMarkerStyle(20); - Muon_plot_d085 -> SetMarkerSize(1); - Muon_plot_d085 -> Draw("P"); - - - c_two->cd(5); - c_two->cd(5)->SetLogx(); - c_two->cd(5)->SetTickx(1); - c_two->cd(5)->SetTicky(1); - - TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, meanz010, zeros, errorz010); - Muon_plot_z010 -> SetTitle("z0"); - Muon_plot_z010 -> SetMarkerColor(6); - Muon_plot_z010 -> SetMarkerStyle(24); - Muon_plot_z010 -> SetMarkerSize(1); - Muon_plot_z010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_z010 -> GetYaxis() -> SetTitle("#mean = f(P,#theta)"); - Muon_plot_z010 -> SetMinimum( -0.50 ); - Muon_plot_z010 -> SetMaximum( 0.50 ); - Muon_plot_z010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, meanz020, zeros, errorz020); - Muon_plot_z020 -> SetMarkerColor(4); - Muon_plot_z020 -> SetMarkerStyle(22); - Muon_plot_z020 -> SetMarkerSize(1); - Muon_plot_z020 -> Draw("P"); - - TGraphErrors *Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, meanz040, zeros, errorz040); - Muon_plot_z040 -> SetMarkerColor(2); - Muon_plot_z040 -> SetMarkerStyle(21); - Muon_plot_z040 -> SetMarkerSize(1); - Muon_plot_z040 -> Draw("P"); - - TGraphErrors *Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, meanz085, zeros, errorz085); - Muon_plot_z085 -> SetMarkerColor(1); - Muon_plot_z085 -> SetMarkerStyle(20); - Muon_plot_z085 -> SetMarkerSize(1); - Muon_plot_z085 -> Draw("P"); - - - - c_two->cd(6); - TLegend *leg = new TLegend(0.5,0.5,0.75,0.89); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot_omega10,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot_omega20,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot_omega40,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot_omega85,"#theta = 85^{o}","p"); - leg->Draw(); - - c_two->SaveAs("pull_mean_ILD_l5_v02.png"); - + TCanvas* c_two = new TCanvas("MomentumResolutionBar", "Track Parameters #mean", 200, 10, 700, 500); + c_two->Divide(3, 2); + + c_two->cd(1); + c_two->cd(1)->SetLogx(); + c_two->cd(1)->SetTickx(1); + c_two->cd(1)->SetTicky(1); + + TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, meanOmega10, zeros, errorOmega10); + Muon_plot_omega10->SetTitle("#Omega"); + Muon_plot_omega10->SetMarkerColor(6); + Muon_plot_omega10->SetMarkerStyle(24); + Muon_plot_omega10->SetMarkerSize(1); + Muon_plot_omega10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_omega10->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_omega10->SetMinimum(-0.50); + Muon_plot_omega10->SetMaximum(0.50); + Muon_plot_omega10->Draw("AP"); + + TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, meanOmega20, zeros, errorOmega20); + Muon_plot_omega20->SetMarkerColor(4); + Muon_plot_omega20->SetMarkerStyle(22); + Muon_plot_omega20->SetMarkerSize(1); + Muon_plot_omega20->Draw("P"); + + TGraphErrors* Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, meanOmega40, zeros, errorOmega40); + Muon_plot_omega40->SetMarkerColor(2); + Muon_plot_omega40->SetMarkerStyle(21); + Muon_plot_omega40->SetMarkerSize(1); + Muon_plot_omega40->Draw("P"); + + TGraphErrors* Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, meanOmega85, zeros, errorOmega85); + Muon_plot_omega85->SetMarkerColor(1); + Muon_plot_omega85->SetMarkerStyle(20); + Muon_plot_omega85->SetMarkerSize(1); + Muon_plot_omega85->Draw("P"); + + c_two->cd(2); + c_two->cd(2)->SetLogx(); + c_two->cd(2)->SetTickx(1); + c_two->cd(2)->SetTicky(1); + + TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda10, zeros, errorTanLambda10); + Muon_plot_tanlambda10->SetTitle("tan #lambda"); + Muon_plot_tanlambda10->SetMarkerColor(6); + Muon_plot_tanlambda10->SetMarkerStyle(24); + Muon_plot_tanlambda10->SetMarkerSize(1); + Muon_plot_tanlambda10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_tanlambda10->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_tanlambda10->SetMinimum(-0.50); + Muon_plot_tanlambda10->SetMaximum(0.50); + Muon_plot_tanlambda10->Draw("AP"); + + TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda20, zeros, errorTanLambda20); + Muon_plot_tanlambda20->SetMarkerColor(4); + Muon_plot_tanlambda20->SetMarkerStyle(22); + Muon_plot_tanlambda20->SetMarkerSize(1); + Muon_plot_tanlambda20->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda40, zeros, errorTanLambda40); + Muon_plot_tanlambda40->SetMarkerColor(2); + Muon_plot_tanlambda40->SetMarkerStyle(21); + Muon_plot_tanlambda40->SetMarkerSize(1); + Muon_plot_tanlambda40->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, meanTanLambda85, zeros, errorTanLambda85); + Muon_plot_tanlambda85->SetMarkerColor(1); + Muon_plot_tanlambda85->SetMarkerStyle(20); + Muon_plot_tanlambda85->SetMarkerSize(1); + Muon_plot_tanlambda85->Draw("P"); + + c_two->cd(3); + c_two->cd(3)->SetLogx(); + c_two->cd(3)->SetTickx(1); + c_two->cd(3)->SetTicky(1); + + TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, meanPhi10, zeros, errorPhi10); + Muon_plot_phi10->SetTitle("#phi"); + Muon_plot_phi10->SetMarkerColor(6); + Muon_plot_phi10->SetMarkerStyle(24); + Muon_plot_phi10->SetMarkerSize(1); + Muon_plot_phi10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_phi10->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_phi10->SetMinimum(-0.50); + Muon_plot_phi10->SetMaximum(0.50); + Muon_plot_phi10->Draw("AP"); + + TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, meanPhi20, zeros, errorPhi20); + Muon_plot_phi20->SetMarkerColor(4); + Muon_plot_phi20->SetMarkerStyle(22); + Muon_plot_phi20->SetMarkerSize(1); + Muon_plot_phi20->Draw("P"); + + TGraphErrors* Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, meanPhi40, zeros, errorPhi40); + Muon_plot_phi40->SetMarkerColor(2); + Muon_plot_phi40->SetMarkerStyle(21); + Muon_plot_phi40->SetMarkerSize(1); + Muon_plot_phi40->Draw("P"); + + TGraphErrors* Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, meanPhi85, zeros, errorPhi85); + Muon_plot_phi85->SetMarkerColor(1); + Muon_plot_phi85->SetMarkerStyle(20); + Muon_plot_phi85->SetMarkerSize(1); + Muon_plot_phi85->Draw("P"); + + c_two->cd(4); + c_two->cd(4)->SetLogx(); + c_two->cd(4)->SetTickx(1); + c_two->cd(4)->SetTicky(1); + + TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, meand010, zeros, errord010); + Muon_plot_d010->SetTitle("d0"); + Muon_plot_d010->SetMarkerColor(6); + Muon_plot_d010->SetMarkerStyle(24); + Muon_plot_d010->SetMarkerSize(1); + Muon_plot_d010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_d010->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_d010->SetMinimum(-0.50); + Muon_plot_d010->SetMaximum(0.50); + Muon_plot_d010->Draw("AP"); + + TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, meand020, zeros, errord020); + Muon_plot_d020->SetMarkerColor(4); + Muon_plot_d020->SetMarkerStyle(22); + Muon_plot_d020->SetMarkerSize(1); + Muon_plot_d020->Draw("P"); + + TGraphErrors* Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, meand040, zeros, errord040); + Muon_plot_d040->SetMarkerColor(2); + Muon_plot_d040->SetMarkerStyle(21); + Muon_plot_d040->SetMarkerSize(1); + Muon_plot_d040->Draw("P"); + + TGraphErrors* Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, meand085, zeros, errord085); + Muon_plot_d085->SetMarkerColor(1); + Muon_plot_d085->SetMarkerStyle(20); + Muon_plot_d085->SetMarkerSize(1); + Muon_plot_d085->Draw("P"); + + c_two->cd(5); + c_two->cd(5)->SetLogx(); + c_two->cd(5)->SetTickx(1); + c_two->cd(5)->SetTicky(1); + + TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, meanz010, zeros, errorz010); + Muon_plot_z010->SetTitle("z0"); + Muon_plot_z010->SetMarkerColor(6); + Muon_plot_z010->SetMarkerStyle(24); + Muon_plot_z010->SetMarkerSize(1); + Muon_plot_z010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_z010->GetYaxis()->SetTitle("#mean = f(P,#theta)"); + Muon_plot_z010->SetMinimum(-0.50); + Muon_plot_z010->SetMaximum(0.50); + Muon_plot_z010->Draw("AP"); + + TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, meanz020, zeros, errorz020); + Muon_plot_z020->SetMarkerColor(4); + Muon_plot_z020->SetMarkerStyle(22); + Muon_plot_z020->SetMarkerSize(1); + Muon_plot_z020->Draw("P"); + + TGraphErrors* Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, meanz040, zeros, errorz040); + Muon_plot_z040->SetMarkerColor(2); + Muon_plot_z040->SetMarkerStyle(21); + Muon_plot_z040->SetMarkerSize(1); + Muon_plot_z040->Draw("P"); + + TGraphErrors* Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, meanz085, zeros, errorz085); + Muon_plot_z085->SetMarkerColor(1); + Muon_plot_z085->SetMarkerStyle(20); + Muon_plot_z085->SetMarkerSize(1); + Muon_plot_z085->Draw("P"); + + c_two->cd(6); + TLegend* leg = new TLegend(0.5, 0.5, 0.75, 0.89); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot_omega10, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot_omega20, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot_omega40, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot_omega85, "#theta = 85^{o}", "p"); + leg->Draw(); + + c_two->SaveAs("pull_mean_ILD_l5_v02.png"); } diff --git a/tracking/macros/rootlogon.C b/tracking/macros/rootlogon.C index 5891074..c0987f8 100644 --- a/tracking/macros/rootlogon.C +++ b/tracking/macros/rootlogon.C @@ -1,86 +1,84 @@ { -//ild TStyle -TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); - -//set the background color to white -ildStyle->SetFillColor(10); -ildStyle->SetFrameFillColor(10); -ildStyle->SetCanvasColor(10); -ildStyle->SetPadColor(10); -ildStyle->SetTitleFillColor(0); -ildStyle->SetStatColor(10); - -//dont put a colored frame around the plots -ildStyle->SetFrameBorderMode(0); -ildStyle->SetCanvasBorderMode(0); -ildStyle->SetPadBorderMode(0); -ildStyle->SetLegendBorderSize(0); - -//use the primary color palette -ildStyle->SetPalette(1,0); - -//set the default line color for a histogram to be black -ildStyle->SetHistLineColor(kBlack); - -//set the default line color for a fit function to be red -ildStyle->SetFuncColor(kRed); - -//make the axis labels black -ildStyle->SetLabelColor(kBlack,"xyz"); - -//set the default title color to be black -ildStyle->SetTitleColor(kBlack); - -//set the margins -ildStyle->SetPadBottomMargin(0.18); -ildStyle->SetPadTopMargin(0.08); -ildStyle->SetPadRightMargin(0.08); -ildStyle->SetPadLeftMargin(0.17); - -//set axis label and title text sizes -ildStyle->SetLabelFont(42,"xyz"); -ildStyle->SetLabelSize(0.06,"xyz"); -ildStyle->SetLabelOffset(0.015,"xyz"); -ildStyle->SetTitleFont(42,"xyz"); -ildStyle->SetTitleSize(0.07,"xyz"); -ildStyle->SetTitleOffset(1.1,"yz"); -ildStyle->SetTitleOffset(1.0,"x"); -ildStyle->SetStatFont(42); -ildStyle->SetStatFontSize(0.07); -ildStyle->SetTitleBorderSize(0); -ildStyle->SetStatBorderSize(0); -ildStyle->SetTextFont(42); - -//set line widths -ildStyle->SetFrameLineWidth(2); -ildStyle->SetFuncWidth(2); -ildStyle->SetHistLineWidth(2); - -//set the number of divisions to show -ildStyle->SetNdivisions(506, "xy"); - -//turn off xy grids -ildStyle->SetPadGridX(0); -ildStyle->SetPadGridY(0); - -//set the tick mark style -ildStyle->SetPadTickX(1); -ildStyle->SetPadTickY(1); - -//turn off stats -ildStyle->SetOptStat(0); -ildStyle->SetOptFit(0); - -//marker settings -ildStyle->SetMarkerStyle(20); -ildStyle->SetMarkerSize(0.7); -ildStyle->SetLineWidth(2); - -//done -ildStyle->cd(); -gROOT->ForceStyle(); -gStyle->ls(); - + // ild TStyle + TStyle* ildStyle = new TStyle("ildStyle", "ILD Style"); + + // set the background color to white + ildStyle->SetFillColor(10); + ildStyle->SetFrameFillColor(10); + ildStyle->SetCanvasColor(10); + ildStyle->SetPadColor(10); + ildStyle->SetTitleFillColor(0); + ildStyle->SetStatColor(10); + + // dont put a colored frame around the plots + ildStyle->SetFrameBorderMode(0); + ildStyle->SetCanvasBorderMode(0); + ildStyle->SetPadBorderMode(0); + ildStyle->SetLegendBorderSize(0); + + // use the primary color palette + ildStyle->SetPalette(1, 0); + + // set the default line color for a histogram to be black + ildStyle->SetHistLineColor(kBlack); + + // set the default line color for a fit function to be red + ildStyle->SetFuncColor(kRed); + + // make the axis labels black + ildStyle->SetLabelColor(kBlack, "xyz"); + + // set the default title color to be black + ildStyle->SetTitleColor(kBlack); + + // set the margins + ildStyle->SetPadBottomMargin(0.18); + ildStyle->SetPadTopMargin(0.08); + ildStyle->SetPadRightMargin(0.08); + ildStyle->SetPadLeftMargin(0.17); + + // set axis label and title text sizes + ildStyle->SetLabelFont(42, "xyz"); + ildStyle->SetLabelSize(0.06, "xyz"); + ildStyle->SetLabelOffset(0.015, "xyz"); + ildStyle->SetTitleFont(42, "xyz"); + ildStyle->SetTitleSize(0.07, "xyz"); + ildStyle->SetTitleOffset(1.1, "yz"); + ildStyle->SetTitleOffset(1.0, "x"); + ildStyle->SetStatFont(42); + ildStyle->SetStatFontSize(0.07); + ildStyle->SetTitleBorderSize(0); + ildStyle->SetStatBorderSize(0); + ildStyle->SetTextFont(42); + + // set line widths + ildStyle->SetFrameLineWidth(2); + ildStyle->SetFuncWidth(2); + ildStyle->SetHistLineWidth(2); + + // set the number of divisions to show + ildStyle->SetNdivisions(506, "xy"); + + // turn off xy grids + ildStyle->SetPadGridX(0); + ildStyle->SetPadGridY(0); + + // set the tick mark style + ildStyle->SetPadTickX(1); + ildStyle->SetPadTickY(1); + + // turn off stats + ildStyle->SetOptStat(0); + ildStyle->SetOptFit(0); + + // marker settings + ildStyle->SetMarkerStyle(20); + ildStyle->SetMarkerSize(0.7); + ildStyle->SetLineWidth(2); + + // done + ildStyle->cd(); + gROOT->ForceStyle(); + gStyle->ls(); } - diff --git a/tracking/macros/sigma.C b/tracking/macros/sigma.C index 086d566..5868195 100644 --- a/tracking/macros/sigma.C +++ b/tracking/macros/sigma.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 7 @@ -29,400 +28,364 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void sigma(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void sigma() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - TFile *f1 = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - - TH1F* hOmega = (TH1F*) f1->Get("OmegaPull"); - TH1F* hPhi = (TH1F*) f1->Get("PhiPull"); - TH1F* hTanLambda = (TH1F*) f1->Get("TanLambdaPull"); - TH1F* hd0 = (TH1F*) f1->Get("d0pull"); - TH1F* hz0 = (TH1F*) f1->Get("z0pull"); - - if (hOmega->GetEntries()>50){ - - hOmega->Fit("gaus"); - TF1 *fit1 = (TF1*)hOmega->GetFunction("gaus"); - sigmaOmega[i][ii] = fit1->GetParameter(2); - error_sigmaOmega[i][ii] = fit1->GetParError(2); - - hTanLambda->Fit("gaus"); - TF1 *fit2 = (TF1*)hTanLambda->GetFunction("gaus"); - sigmaTanLambda[i][ii] = fit2->GetParameter(2); - error_sigmaTanLambda[i][ii] = fit2->GetParError(2); - - hPhi->Fit("gaus"); - TF1 *fit3 = (TF1*)hPhi->GetFunction("gaus"); - sigmaPhi[i][ii] = fit3->GetParameter(2); - error_sigmaPhi[i][ii] = fit3->GetParError(2); - - hd0->Fit("gaus"); - TF1 *fit4 = (TF1*)hd0->GetFunction("gaus"); - sigmad0[i][ii] = fit4->GetParameter(2); - error_sigmad0[i][ii] = fit4->GetParError(2); - - hz0->Fit("gaus"); - TF1 *fit5 = (TF1*)hz0->GetFunction("gaus"); - sigmaz0[i][ii] = fit5->GetParameter(2); - error_sigmaz0[i][ii] = fit5->GetParError(2); - - - }//loop for each .root files, here I have collected sigma and its error - }//polar angle loop - - - + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + TFile* f1 = new TFile(Form("../Results/Analysis/analysis_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + + TH1F* hOmega = (TH1F*)f1->Get("OmegaPull"); + TH1F* hPhi = (TH1F*)f1->Get("PhiPull"); + TH1F* hTanLambda = (TH1F*)f1->Get("TanLambdaPull"); + TH1F* hd0 = (TH1F*)f1->Get("d0pull"); + TH1F* hz0 = (TH1F*)f1->Get("z0pull"); + + if (hOmega->GetEntries() > 50) { + + hOmega->Fit("gaus"); + TF1* fit1 = (TF1*)hOmega->GetFunction("gaus"); + sigmaOmega[i][ii] = fit1->GetParameter(2); + error_sigmaOmega[i][ii] = fit1->GetParError(2); + + hTanLambda->Fit("gaus"); + TF1* fit2 = (TF1*)hTanLambda->GetFunction("gaus"); + sigmaTanLambda[i][ii] = fit2->GetParameter(2); + error_sigmaTanLambda[i][ii] = fit2->GetParError(2); + + hPhi->Fit("gaus"); + TF1* fit3 = (TF1*)hPhi->GetFunction("gaus"); + sigmaPhi[i][ii] = fit3->GetParameter(2); + error_sigmaPhi[i][ii] = fit3->GetParError(2); + + hd0->Fit("gaus"); + TF1* fit4 = (TF1*)hd0->GetFunction("gaus"); + sigmad0[i][ii] = fit4->GetParameter(2); + error_sigmad0[i][ii] = fit4->GetParError(2); + + hz0->Fit("gaus"); + TF1* fit5 = (TF1*)hz0->GetFunction("gaus"); + sigmaz0[i][ii] = fit5->GetParameter(2); + error_sigmaz0[i][ii] = fit5->GetParError(2); + + } // loop for each .root files, here I have collected sigma and its error + } // polar angle loop + float sigmaOmega10[SIZE_M]; float errorOmega10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega10[kk] = sigmaOmega[kk][0]; errorOmega10[kk] = error_sigmaOmega[kk][0]; - } - - + } + float sigmaOmega20[SIZE_M]; float errorOmega20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega20[kk] = sigmaOmega[kk][1]; errorOmega20[kk] = error_sigmaOmega[kk][1]; - } - + } + float sigmaOmega40[SIZE_M]; float errorOmega40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega40[kk] = sigmaOmega[kk][2]; errorOmega40[kk] = error_sigmaOmega[kk][2]; } - + float sigmaOmega85[SIZE_M]; float errorOmega85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega85[kk] = sigmaOmega[kk][3]; errorOmega85[kk] = error_sigmaOmega[kk][3]; } - + float sigmaTanLambda10[SIZE_M]; float errorTanLambda10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda10[kk] = sigmaTanLambda[kk][0]; errorTanLambda10[kk] = error_sigmaTanLambda[kk][0]; - } - + } float sigmaTanLambda20[SIZE_M]; float errorTanLambda20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda20[kk] = sigmaTanLambda[kk][1]; errorTanLambda20[kk] = error_sigmaTanLambda[kk][1]; - } - + } + float sigmaTanLambda40[SIZE_M]; float errorTanLambda40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda40[kk] = sigmaTanLambda[kk][2]; errorTanLambda40[kk] = error_sigmaTanLambda[kk][2]; } - + float sigmaTanLambda85[SIZE_M]; float errorTanLambda85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda85[kk] = sigmaTanLambda[kk][3]; errorTanLambda85[kk] = error_sigmaTanLambda[kk][3]; } - - + float sigmaPhi10[SIZE_M]; float errorPhi10[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi10[kk] = sigmaPhi[kk][0]; errorPhi10[kk] = error_sigmaPhi[kk][0]; - } - - + } + float sigmaPhi20[SIZE_M]; float errorPhi20[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi20[kk] = sigmaPhi[kk][1]; errorPhi20[kk] = error_sigmaPhi[kk][1]; - } - + } + float sigmaPhi40[SIZE_M]; float errorPhi40[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi40[kk] = sigmaPhi[kk][2]; errorPhi40[kk] = error_sigmaPhi[kk][2]; } - + float sigmaPhi85[SIZE_M]; float errorPhi85[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi85[kk] = sigmaPhi[kk][3]; errorPhi85[kk] = error_sigmaPhi[kk][3]; } - - + float sigmad010[SIZE_M]; float errord010[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmad010[kk] = sigmad0[kk][0]; errord010[kk] = error_sigmad0[kk][0]; - } + } - float sigmad020[SIZE_M]; float errord020[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmad020[kk] = sigmad0[kk][1]; errord020[kk] = error_sigmad0[kk][1]; - } - + } + float sigmad040[SIZE_M]; float errord040[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmad040[kk] = sigmad0[kk][2]; errord040[kk] = error_sigmad0[kk][2]; } - + float sigmad085[SIZE_M]; float errord085[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmad085[kk] = sigmad0[kk][3]; errord085[kk] = error_sigmad0[kk][3]; } - float sigmaz010[SIZE_M]; float errorz010[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz010[kk] = sigmaz0[kk][0]; errorz010[kk] = error_sigmaz0[kk][0]; - } - - + } + float sigmaz020[SIZE_M]; float errorz020[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz020[kk] = sigmaz0[kk][1]; errorz020[kk] = error_sigmaz0[kk][1]; - } - + } + float sigmaz040[SIZE_M]; float errorz040[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz040[kk] = sigmaz0[kk][2]; errorz040[kk] = error_sigmaz0[kk][2]; } - + float sigmaz085[SIZE_M]; float errorz085[SIZE_M]; - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz085[kk] = sigmaz0[kk][3]; errorz085[kk] = error_sigmaz0[kk][3]; } - - - TCanvas *c_two = new TCanvas("MomentumResolutionBar","Track Parameters #sigma",200,10,700,500); - c_two->Divide(3,2); + TCanvas* c_two = new TCanvas("MomentumResolutionBar", "Track Parameters #sigma", 200, 10, 700, 500); + c_two->Divide(3, 2); c_two->cd(1); - //TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); - - TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega10, zeros, errorOmega10); - Muon_plot_omega10 -> SetTitle("#omega"); - Muon_plot_omega10 -> SetMarkerColor(2); - Muon_plot_omega10 -> SetMarkerStyle(24); - Muon_plot_omega10 -> SetMarkerSize(1); - Muon_plot_omega10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_omega10 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_omega10 -> SetMinimum( 0.75 ); - Muon_plot_omega10 -> SetMaximum( 1.65 ); - Muon_plot_omega10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega20, zeros, errorOmega20); - Muon_plot_omega20 -> SetMarkerColor(4); - Muon_plot_omega20 -> SetMarkerStyle(22); - Muon_plot_omega20 -> SetMarkerSize(1); - Muon_plot_omega20 -> Draw("P"); - - TGraphErrors *Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega40, zeros, errorOmega40); - Muon_plot_omega40 -> SetMarkerColor(2); - Muon_plot_omega40 -> SetMarkerStyle(21); - Muon_plot_omega40 -> SetMarkerSize(1); - Muon_plot_omega40 -> Draw("P"); - - TGraphErrors *Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega85, zeros, errorOmega85); - Muon_plot_omega85 -> SetMarkerColor(1); - Muon_plot_omega85 -> SetMarkerStyle(20); - Muon_plot_omega85 -> SetMarkerSize(1); - Muon_plot_omega85 -> Draw("P"); + // TGraph *Muon_plot20 = new TGraph(SIZE_M, Momentum, sigma20); + + TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega10, zeros, errorOmega10); + Muon_plot_omega10->SetTitle("#omega"); + Muon_plot_omega10->SetMarkerColor(2); + Muon_plot_omega10->SetMarkerStyle(24); + Muon_plot_omega10->SetMarkerSize(1); + Muon_plot_omega10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_omega10->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_omega10->SetMinimum(0.75); + Muon_plot_omega10->SetMaximum(1.65); + Muon_plot_omega10->Draw("AP"); + + TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega20, zeros, errorOmega20); + Muon_plot_omega20->SetMarkerColor(4); + Muon_plot_omega20->SetMarkerStyle(22); + Muon_plot_omega20->SetMarkerSize(1); + Muon_plot_omega20->Draw("P"); + + TGraphErrors* Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega40, zeros, errorOmega40); + Muon_plot_omega40->SetMarkerColor(2); + Muon_plot_omega40->SetMarkerStyle(21); + Muon_plot_omega40->SetMarkerSize(1); + Muon_plot_omega40->Draw("P"); + + TGraphErrors* Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega85, zeros, errorOmega85); + Muon_plot_omega85->SetMarkerColor(1); + Muon_plot_omega85->SetMarkerStyle(20); + Muon_plot_omega85->SetMarkerSize(1); + Muon_plot_omega85->Draw("P"); c_two->SetTickx(1); c_two->SetTicky(1); - - + c_two->cd(2); - TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda10, zeros, errorTanLambda10); - Muon_plot_tanlambda10 -> SetTitle("tan #lambda"); - Muon_plot_tanlambda10 -> SetMarkerColor(2); - Muon_plot_tanlambda10 -> SetMarkerStyle(24); - Muon_plot_tanlambda10 -> SetMarkerSize(1); - Muon_plot_tanlambda10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_tanlambda10 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_tanlambda10 -> SetMinimum( 0.80 ); - Muon_plot_tanlambda10 -> SetMaximum( 1.40 ); - Muon_plot_tanlambda10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda20, zeros, errorTanLambda20); - Muon_plot_tanlambda20 -> SetMarkerColor(4); - Muon_plot_tanlambda20 -> SetMarkerStyle(22); - Muon_plot_tanlambda20 -> SetMarkerSize(1); - Muon_plot_tanlambda20 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda40, zeros, errorTanLambda40); - Muon_plot_tanlambda40 -> SetMarkerColor(2); - Muon_plot_tanlambda40 -> SetMarkerStyle(21); - Muon_plot_tanlambda40 -> SetMarkerSize(1); - Muon_plot_tanlambda40 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda85, zeros, errorTanLambda85); - Muon_plot_tanlambda85 -> SetMarkerColor(1); - Muon_plot_tanlambda85 -> SetMarkerStyle(20); - Muon_plot_tanlambda85 -> SetMarkerSize(1); - Muon_plot_tanlambda85 -> Draw("P"); + TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda10, zeros, errorTanLambda10); + Muon_plot_tanlambda10->SetTitle("tan #lambda"); + Muon_plot_tanlambda10->SetMarkerColor(2); + Muon_plot_tanlambda10->SetMarkerStyle(24); + Muon_plot_tanlambda10->SetMarkerSize(1); + Muon_plot_tanlambda10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_tanlambda10->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_tanlambda10->SetMinimum(0.80); + Muon_plot_tanlambda10->SetMaximum(1.40); + Muon_plot_tanlambda10->Draw("AP"); + + TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda20, zeros, errorTanLambda20); + Muon_plot_tanlambda20->SetMarkerColor(4); + Muon_plot_tanlambda20->SetMarkerStyle(22); + Muon_plot_tanlambda20->SetMarkerSize(1); + Muon_plot_tanlambda20->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda40, zeros, errorTanLambda40); + Muon_plot_tanlambda40->SetMarkerColor(2); + Muon_plot_tanlambda40->SetMarkerStyle(21); + Muon_plot_tanlambda40->SetMarkerSize(1); + Muon_plot_tanlambda40->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda85, zeros, errorTanLambda85); + Muon_plot_tanlambda85->SetMarkerColor(1); + Muon_plot_tanlambda85->SetMarkerStyle(20); + Muon_plot_tanlambda85->SetMarkerSize(1); + Muon_plot_tanlambda85->Draw("P"); c_two->SetTickx(1); c_two->SetTicky(1); - - + c_two->cd(3); - TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi10, zeros, errorPhi10); - Muon_plot_phi10 -> SetTitle("#phi"); - Muon_plot_phi10 -> SetMarkerColor(2); - Muon_plot_phi10 -> SetMarkerStyle(24); - Muon_plot_phi10 -> SetMarkerSize(1); - Muon_plot_phi10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_phi10 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_phi10 -> SetMinimum( 0.80 ); - Muon_plot_phi10 -> SetMaximum( 1.40 ); - Muon_plot_phi10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi20, zeros, errorPhi20); - Muon_plot_phi20 -> SetMarkerColor(4); - Muon_plot_phi20 -> SetMarkerStyle(22); - Muon_plot_phi20 -> SetMarkerSize(1); - Muon_plot_phi20 -> Draw("P"); - - TGraphErrors *Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi40, zeros, errorPhi40); - Muon_plot_phi40 -> SetMarkerColor(2); - Muon_plot_phi40 -> SetMarkerStyle(21); - Muon_plot_phi40 -> SetMarkerSize(1); - Muon_plot_phi40 -> Draw("P"); - - TGraphErrors *Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi85, zeros, errorPhi85); - Muon_plot_phi85 -> SetMarkerColor(1); - Muon_plot_phi85 -> SetMarkerStyle(20); - Muon_plot_phi85 -> SetMarkerSize(1); - Muon_plot_phi85 -> Draw("P"); + TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi10, zeros, errorPhi10); + Muon_plot_phi10->SetTitle("#phi"); + Muon_plot_phi10->SetMarkerColor(2); + Muon_plot_phi10->SetMarkerStyle(24); + Muon_plot_phi10->SetMarkerSize(1); + Muon_plot_phi10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_phi10->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_phi10->SetMinimum(0.80); + Muon_plot_phi10->SetMaximum(1.40); + Muon_plot_phi10->Draw("AP"); + + TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi20, zeros, errorPhi20); + Muon_plot_phi20->SetMarkerColor(4); + Muon_plot_phi20->SetMarkerStyle(22); + Muon_plot_phi20->SetMarkerSize(1); + Muon_plot_phi20->Draw("P"); + + TGraphErrors* Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi40, zeros, errorPhi40); + Muon_plot_phi40->SetMarkerColor(2); + Muon_plot_phi40->SetMarkerStyle(21); + Muon_plot_phi40->SetMarkerSize(1); + Muon_plot_phi40->Draw("P"); + + TGraphErrors* Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi85, zeros, errorPhi85); + Muon_plot_phi85->SetMarkerColor(1); + Muon_plot_phi85->SetMarkerStyle(20); + Muon_plot_phi85->SetMarkerSize(1); + Muon_plot_phi85->Draw("P"); c_two->SetTickx(1); c_two->SetTicky(1); - - - - + c_two->cd(4); - TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, sigmad010, zeros, errord010); - Muon_plot_d010 -> SetTitle("d0"); - Muon_plot_d010 -> SetMarkerColor(2); - Muon_plot_d010 -> SetMarkerStyle(24); - Muon_plot_d010 -> SetMarkerSize(1); - Muon_plot_d010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_d010 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_d010 -> SetMinimum( 0.80 ); - Muon_plot_d010 -> SetMaximum( 1.40 ); - Muon_plot_d010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, sigmad020, zeros, errord020); - Muon_plot_d020 -> SetMarkerColor(4); - Muon_plot_d020 -> SetMarkerStyle(22); - Muon_plot_d020 -> SetMarkerSize(1); - - Muon_plot_d020 -> Draw("P"); - - TGraphErrors *Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, sigmad040, zeros, errord040); - Muon_plot_d040 -> SetMarkerColor(2); - Muon_plot_d040 -> SetMarkerStyle(21); - Muon_plot_d040 -> SetMarkerSize(1); - Muon_plot_d040 -> Draw("P"); - - TGraphErrors *Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, sigmad085, zeros, errord085); - Muon_plot_d085 -> SetMarkerColor(1); - Muon_plot_d085 -> SetMarkerStyle(20); - Muon_plot_d085 -> SetMarkerSize(1); - Muon_plot_d085 -> Draw("P"); - c_two->SetTickx(1); - c_two->SetTicky(1); + TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, sigmad010, zeros, errord010); + Muon_plot_d010->SetTitle("d0"); + Muon_plot_d010->SetMarkerColor(2); + Muon_plot_d010->SetMarkerStyle(24); + Muon_plot_d010->SetMarkerSize(1); + Muon_plot_d010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_d010->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_d010->SetMinimum(0.80); + Muon_plot_d010->SetMaximum(1.40); + Muon_plot_d010->Draw("AP"); - - - c_two->cd(5); - TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, sigmaz010, zeros, errorz010); - Muon_plot_z010 -> SetTitle("z0"); - Muon_plot_z010 -> SetMarkerColor(2); - Muon_plot_z010 -> SetMarkerStyle(24); - Muon_plot_z010 -> SetMarkerSize(1); - Muon_plot_z010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_z010 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_z010 -> SetMinimum( 0.80 ); - Muon_plot_z010 -> SetMaximum( 1.40 ); - Muon_plot_z010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, sigmaz020, zeros, errorz020); - Muon_plot_z020 -> SetMarkerColor(4); - Muon_plot_z020 -> SetMarkerStyle(22); - Muon_plot_z020 -> SetMarkerSize(1); - Muon_plot_z020 -> Draw("P"); - - TGraphErrors *Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, sigmaz040, zeros, errorz040); - Muon_plot_z040 -> SetMarkerColor(2); - Muon_plot_z040 -> SetMarkerStyle(21); - Muon_plot_z040 -> SetMarkerSize(1); - Muon_plot_z040 -> Draw("P"); - - TGraphErrors *Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, sigmaz085, zeros, errorz085); - Muon_plot_z085 -> SetMarkerColor(1); - Muon_plot_z085 -> SetMarkerStyle(20); - Muon_plot_z085 -> SetMarkerSize(1); - Muon_plot_z085 -> Draw("P"); - c_two->SetTickx(1); - c_two->SetTicky(1); - - - + TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, sigmad020, zeros, errord020); + Muon_plot_d020->SetMarkerColor(4); + Muon_plot_d020->SetMarkerStyle(22); + Muon_plot_d020->SetMarkerSize(1); + Muon_plot_d020->Draw("P"); + TGraphErrors* Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, sigmad040, zeros, errord040); + Muon_plot_d040->SetMarkerColor(2); + Muon_plot_d040->SetMarkerStyle(21); + Muon_plot_d040->SetMarkerSize(1); + Muon_plot_d040->Draw("P"); + TGraphErrors* Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, sigmad085, zeros, errord085); + Muon_plot_d085->SetMarkerColor(1); + Muon_plot_d085->SetMarkerStyle(20); + Muon_plot_d085->SetMarkerSize(1); + Muon_plot_d085->Draw("P"); + c_two->SetTickx(1); + c_two->SetTicky(1); + c_two->cd(5); + TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, sigmaz010, zeros, errorz010); + Muon_plot_z010->SetTitle("z0"); + Muon_plot_z010->SetMarkerColor(2); + Muon_plot_z010->SetMarkerStyle(24); + Muon_plot_z010->SetMarkerSize(1); + Muon_plot_z010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_z010->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_z010->SetMinimum(0.80); + Muon_plot_z010->SetMaximum(1.40); + Muon_plot_z010->Draw("AP"); + + TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, sigmaz020, zeros, errorz020); + Muon_plot_z020->SetMarkerColor(4); + Muon_plot_z020->SetMarkerStyle(22); + Muon_plot_z020->SetMarkerSize(1); + Muon_plot_z020->Draw("P"); + TGraphErrors* Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, sigmaz040, zeros, errorz040); + Muon_plot_z040->SetMarkerColor(2); + Muon_plot_z040->SetMarkerStyle(21); + Muon_plot_z040->SetMarkerSize(1); + Muon_plot_z040->Draw("P"); + TGraphErrors* Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, sigmaz085, zeros, errorz085); + Muon_plot_z085->SetMarkerColor(1); + Muon_plot_z085->SetMarkerStyle(20); + Muon_plot_z085->SetMarkerSize(1); + Muon_plot_z085->Draw("P"); + c_two->SetTickx(1); + c_two->SetTicky(1); c_two->cd(6); - TLegend *leg = new TLegend(0.6,0.7,0.75,0.95); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot_z010,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot_z020,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot_z040,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot_z085,"#theta = 85^{o}","p"); + TLegend* leg = new TLegend(0.6, 0.7, 0.75, 0.95); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot_z010, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot_z020, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot_z040, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot_z085, "#theta = 85^{o}", "p"); leg->Draw(); - } - } diff --git a/tracking/macros/sigmaL5.C b/tracking/macros/sigmaL5.C index 62ad722..1d105b1 100644 --- a/tracking/macros/sigmaL5.C +++ b/tracking/macros/sigmaL5.C @@ -1,16 +1,15 @@ -#include "TH1F.h" -#include "TF1.h" -#include "TH1D.h" #include "TCanvas.h" +#include "TF1.h" +#include "TFile.h" #include "TGraph.h" +#include "TGraphErrors.h" +#include "TH1D.h" +#include "TH1F.h" +#include "TLegend.h" #include "TTree.h" -#include "TFile.h" #include "iostream" #include "vector" -#include "TLegend.h" -#include "TGraphErrors.h" -#include -#include "TLegend.h" +#include using namespace std; #define SIZE_M 7 @@ -29,8 +28,8 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void sigmaL5(){ - for (int ll = 0; ll < SIZE_M; ll++){ +void sigmaL5() { + for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } @@ -75,357 +74,331 @@ void sigmaL5(){ float sigmaz085[SIZE_M]; float errorz085[SIZE_M]; - for(int ii = 0; ii < SIZE_PA; ii++){ - for (int i = 0; i < SIZE_M; i++){ - TFile *f1 = new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root",PA[ii],Mom[i]), "read"); - //TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); - - TH1F* hOmega = (TH1F*) f1->Get("OmegaPull"); - TH1F* hPhi = (TH1F*) f1->Get("PhiPull"); - TH1F* hTanLambda = (TH1F*) f1->Get("TanLambdaPull"); - TH1F* hd0 = (TH1F*) f1->Get("d0pull"); - TH1F* hz0 = (TH1F*) f1->Get("z0pull"); - - if (hOmega->GetEntries()>50){ - - hOmega->Fit("gaus"); - TF1 *fit1 = (TF1*)hOmega->GetFunction("gaus"); - sigmaOmega[i][ii] = fit1->GetParameter(2); - error_sigmaOmega[i][ii] = fit1->GetParError(2); - - hTanLambda->Fit("gaus"); - TF1 *fit2 = (TF1*)hTanLambda->GetFunction("gaus"); - sigmaTanLambda[i][ii] = fit2->GetParameter(2); - error_sigmaTanLambda[i][ii] = fit2->GetParError(2); - - hPhi->Fit("gaus"); - TF1 *fit3 = (TF1*)hPhi->GetFunction("gaus"); - sigmaPhi[i][ii] = fit3->GetParameter(2); - error_sigmaPhi[i][ii] = fit3->GetParError(2); - - hd0->Fit("gaus"); - TF1 *fit4 = (TF1*)hd0->GetFunction("gaus"); - sigmad0[i][ii] = fit4->GetParameter(2); - error_sigmad0[i][ii] = fit4->GetParError(2); - - hz0->Fit("gaus"); - TF1 *fit5 = (TF1*)hz0->GetFunction("gaus"); - sigmaz0[i][ii] = fit5->GetParameter(2); - error_sigmaz0[i][ii] = fit5->GetParError(2); - - - }//loop for each .root files, here I have collected sigma and its error - }//polar angle loop - - - - for(int kk=0; kk < SIZE_M; kk++){ + for (int ii = 0; ii < SIZE_PA; ii++) { + for (int i = 0; i < SIZE_M; i++) { + TFile* f1 = + new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); + + TH1F* hOmega = (TH1F*)f1->Get("OmegaPull"); + TH1F* hPhi = (TH1F*)f1->Get("PhiPull"); + TH1F* hTanLambda = (TH1F*)f1->Get("TanLambdaPull"); + TH1F* hd0 = (TH1F*)f1->Get("d0pull"); + TH1F* hz0 = (TH1F*)f1->Get("z0pull"); + + if (hOmega->GetEntries() > 50) { + + hOmega->Fit("gaus"); + TF1* fit1 = (TF1*)hOmega->GetFunction("gaus"); + sigmaOmega[i][ii] = fit1->GetParameter(2); + error_sigmaOmega[i][ii] = fit1->GetParError(2); + + hTanLambda->Fit("gaus"); + TF1* fit2 = (TF1*)hTanLambda->GetFunction("gaus"); + sigmaTanLambda[i][ii] = fit2->GetParameter(2); + error_sigmaTanLambda[i][ii] = fit2->GetParError(2); + + hPhi->Fit("gaus"); + TF1* fit3 = (TF1*)hPhi->GetFunction("gaus"); + sigmaPhi[i][ii] = fit3->GetParameter(2); + error_sigmaPhi[i][ii] = fit3->GetParError(2); + + hd0->Fit("gaus"); + TF1* fit4 = (TF1*)hd0->GetFunction("gaus"); + sigmad0[i][ii] = fit4->GetParameter(2); + error_sigmad0[i][ii] = fit4->GetParError(2); + + hz0->Fit("gaus"); + TF1* fit5 = (TF1*)hz0->GetFunction("gaus"); + sigmaz0[i][ii] = fit5->GetParameter(2); + error_sigmaz0[i][ii] = fit5->GetParError(2); + + } // loop for each .root files, here I have collected sigma and its error + } // polar angle loop + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega10[kk] = sigmaOmega[kk][0]; errorOmega10[kk] = error_sigmaOmega[kk][0]; - } - - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega20[kk] = sigmaOmega[kk][1]; errorOmega20[kk] = error_sigmaOmega[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega40[kk] = sigmaOmega[kk][2]; errorOmega40[kk] = error_sigmaOmega[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaOmega85[kk] = sigmaOmega[kk][3]; errorOmega85[kk] = error_sigmaOmega[kk][3]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda10[kk] = sigmaTanLambda[kk][0]; errorTanLambda10[kk] = error_sigmaTanLambda[kk][0]; - } - + } - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda20[kk] = sigmaTanLambda[kk][1]; errorTanLambda20[kk] = error_sigmaTanLambda[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda40[kk] = sigmaTanLambda[kk][2]; errorTanLambda40[kk] = error_sigmaTanLambda[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaTanLambda85[kk] = sigmaTanLambda[kk][3]; errorTanLambda85[kk] = error_sigmaTanLambda[kk][3]; } - - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi10[kk] = sigmaPhi[kk][0]; errorPhi10[kk] = error_sigmaPhi[kk][0]; - } - - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi20[kk] = sigmaPhi[kk][1]; errorPhi20[kk] = error_sigmaPhi[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi40[kk] = sigmaPhi[kk][2]; errorPhi40[kk] = error_sigmaPhi[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaPhi85[kk] = sigmaPhi[kk][3]; errorPhi85[kk] = error_sigmaPhi[kk][3]; } - - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmad010[kk] = sigmad0[kk][0]; errord010[kk] = error_sigmad0[kk][0]; - } + } - - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmad020[kk] = sigmad0[kk][1]; errord020[kk] = error_sigmad0[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmad040[kk] = sigmad0[kk][2]; errord040[kk] = error_sigmad0[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmad085[kk] = sigmad0[kk][3]; errord085[kk] = error_sigmad0[kk][3]; } - - for(int kk=0; kk < SIZE_M; kk++){ + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz010[kk] = sigmaz0[kk][0]; errorz010[kk] = error_sigmaz0[kk][0]; - } - - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz020[kk] = sigmaz0[kk][1]; errorz020[kk] = error_sigmaz0[kk][1]; - } - - for(int kk=0; kk < SIZE_M; kk++){ + } + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz040[kk] = sigmaz0[kk][2]; errorz040[kk] = error_sigmaz0[kk][2]; } - - for(int kk=0; kk < SIZE_M; kk++){ + + for (int kk = 0; kk < SIZE_M; kk++) { sigmaz085[kk] = sigmaz0[kk][3]; errorz085[kk] = error_sigmaz0[kk][3]; } - - } - - TCanvas *c_two = new TCanvas("MomentumResolutionBar","Track Parameters #sigma",200,10,700,500); - c_two->Divide(3,2); - - c_two->cd(1); - c_two->cd(1)->SetLogx(); - c_two->cd(1)->SetTickx(1); - c_two->cd(1)->SetTicky(1); - - TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega10, zeros, errorOmega10); - Muon_plot_omega10 -> SetTitle("#Omega"); - Muon_plot_omega10 -> SetMarkerColor(6); - Muon_plot_omega10 -> SetMarkerStyle(24); - Muon_plot_omega10 -> SetMarkerSize(1); - Muon_plot_omega10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_omega10 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_omega10 -> SetMinimum( 0.70 ); - Muon_plot_omega10 -> SetMaximum( 1.50 ); - Muon_plot_omega10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega20, zeros, errorOmega20); - Muon_plot_omega20 -> SetMarkerColor(4); - Muon_plot_omega20 -> SetMarkerStyle(22); - Muon_plot_omega20 -> SetMarkerSize(1); - Muon_plot_omega20 -> Draw("P"); - - TGraphErrors *Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega40, zeros, errorOmega40); - Muon_plot_omega40 -> SetMarkerColor(2); - Muon_plot_omega40 -> SetMarkerStyle(21); - Muon_plot_omega40 -> SetMarkerSize(1); - Muon_plot_omega40 -> Draw("P"); - - TGraphErrors *Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega85, zeros, errorOmega85); - Muon_plot_omega85 -> SetMarkerColor(1); - Muon_plot_omega85 -> SetMarkerStyle(20); - Muon_plot_omega85 -> SetMarkerSize(1); - Muon_plot_omega85 -> Draw("P"); - - - - c_two->cd(2); - c_two->cd(2)->SetLogx(); - c_two->cd(2)->SetTickx(1); - c_two->cd(2)->SetTicky(1); - - TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda10, zeros, errorTanLambda10); - Muon_plot_tanlambda10 -> SetTitle("tan #lambda"); - Muon_plot_tanlambda10 -> SetMarkerColor(6); - Muon_plot_tanlambda10 -> SetMarkerStyle(24); - Muon_plot_tanlambda10 -> SetMarkerSize(1); - Muon_plot_tanlambda10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_tanlambda10 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_tanlambda10 -> SetMinimum( 0.70 ); - Muon_plot_tanlambda10 -> SetMaximum( 1.50 ); - Muon_plot_tanlambda10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda20, zeros, errorTanLambda20); - Muon_plot_tanlambda20 -> SetMarkerColor(4); - Muon_plot_tanlambda20 -> SetMarkerStyle(22); - Muon_plot_tanlambda20 -> SetMarkerSize(1); - Muon_plot_tanlambda20 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda40, zeros, errorTanLambda40); - Muon_plot_tanlambda40 -> SetMarkerColor(2); - Muon_plot_tanlambda40 -> SetMarkerStyle(21); - Muon_plot_tanlambda40 -> SetMarkerSize(1); - Muon_plot_tanlambda40 -> Draw("P"); - - TGraphErrors *Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda85, zeros, errorTanLambda85); - Muon_plot_tanlambda85 -> SetMarkerColor(1); - Muon_plot_tanlambda85 -> SetMarkerStyle(20); - Muon_plot_tanlambda85 -> SetMarkerSize(1); - Muon_plot_tanlambda85 -> Draw("P"); - - - c_two->cd(3); - c_two->cd(3)->SetLogx(); - c_two->cd(3)->SetTickx(1); - c_two->cd(3)->SetTicky(1); - - TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi10, zeros, errorPhi10); - Muon_plot_phi10 -> SetTitle("#phi"); - Muon_plot_phi10 -> SetMarkerColor(6); - Muon_plot_phi10 -> SetMarkerStyle(24); - Muon_plot_phi10 -> SetMarkerSize(1); - Muon_plot_phi10 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_phi10 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_phi10 -> SetMinimum( 0.70 ); - Muon_plot_phi10 -> SetMaximum( 1.50 ); - Muon_plot_phi10 -> Draw("AP"); - - - TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi20, zeros, errorPhi20); - Muon_plot_phi20 -> SetMarkerColor(4); - Muon_plot_phi20 -> SetMarkerStyle(22); - Muon_plot_phi20 -> SetMarkerSize(1); - Muon_plot_phi20 -> Draw("P"); - - TGraphErrors *Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi40, zeros, errorPhi40); - Muon_plot_phi40 -> SetMarkerColor(2); - Muon_plot_phi40 -> SetMarkerStyle(21); - Muon_plot_phi40 -> SetMarkerSize(1); - Muon_plot_phi40 -> Draw("P"); - - TGraphErrors *Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi85, zeros, errorPhi85); - Muon_plot_phi85 -> SetMarkerColor(1); - Muon_plot_phi85 -> SetMarkerStyle(20); - Muon_plot_phi85 -> SetMarkerSize(1); - Muon_plot_phi85 -> Draw("P"); - - - - c_two->cd(4); - c_two->cd(4)->SetLogx(); - c_two->cd(4)->SetTickx(1); - c_two->cd(4)->SetTicky(1); - - TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, sigmad010, zeros, errord010); - Muon_plot_d010 -> SetTitle("d0"); - Muon_plot_d010 -> SetMarkerColor(6); - Muon_plot_d010 -> SetMarkerStyle(24); - Muon_plot_d010 -> SetMarkerSize(1); - Muon_plot_d010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_d010 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_d010 -> SetMinimum( 0.70 ); - Muon_plot_d010 -> SetMaximum( 1.50 ); - Muon_plot_d010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, sigmad020, zeros, errord020); - Muon_plot_d020 -> SetMarkerColor(4); - Muon_plot_d020 -> SetMarkerStyle(22); - Muon_plot_d020 -> SetMarkerSize(1); - - Muon_plot_d020 -> Draw("P"); - - TGraphErrors *Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, sigmad040, zeros, errord040); - Muon_plot_d040 -> SetMarkerColor(2); - Muon_plot_d040 -> SetMarkerStyle(21); - Muon_plot_d040 -> SetMarkerSize(1); - Muon_plot_d040 -> Draw("P"); - - TGraphErrors *Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, sigmad085, zeros, errord085); - Muon_plot_d085 -> SetMarkerColor(1); - Muon_plot_d085 -> SetMarkerStyle(20); - Muon_plot_d085 -> SetMarkerSize(1); - Muon_plot_d085 -> Draw("P"); - - - c_two->cd(5); - c_two->cd(5)->SetLogx(); - c_two->cd(5)->SetTickx(1); - c_two->cd(5)->SetTicky(1); - - TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, sigmaz010, zeros, errorz010); - Muon_plot_z010 -> SetTitle("z0"); - Muon_plot_z010 -> SetMarkerColor(6); - Muon_plot_z010 -> SetMarkerStyle(24); - Muon_plot_z010 -> SetMarkerSize(1); - Muon_plot_z010 -> GetXaxis() -> SetTitle("P (GeV)"); - Muon_plot_z010 -> GetYaxis() -> SetTitle("#sigma = f(P,#theta)"); - Muon_plot_z010 -> SetMinimum( 0.70 ); - Muon_plot_z010 -> SetMaximum( 1.50 ); - Muon_plot_z010 -> Draw("AP"); - - - TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, sigmaz020, zeros, errorz020); - Muon_plot_z020 -> SetMarkerColor(4); - Muon_plot_z020 -> SetMarkerStyle(22); - Muon_plot_z020 -> SetMarkerSize(1); - Muon_plot_z020 -> Draw("P"); - - TGraphErrors *Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, sigmaz040, zeros, errorz040); - Muon_plot_z040 -> SetMarkerColor(2); - Muon_plot_z040 -> SetMarkerStyle(21); - Muon_plot_z040 -> SetMarkerSize(1); - Muon_plot_z040 -> Draw("P"); - - TGraphErrors *Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, sigmaz085, zeros, errorz085); - Muon_plot_z085 -> SetMarkerColor(1); - Muon_plot_z085 -> SetMarkerStyle(20); - Muon_plot_z085 -> SetMarkerSize(1); - Muon_plot_z085 -> Draw("P"); - - - - c_two->cd(6); - TLegend *leg = new TLegend(0.5,0.5,0.75,0.89); - //leg->SetHeader("Polar Angles"); //name of the legend - leg->AddEntry(Muon_plot_z010,"#theta = 10^{o}","p"); - leg->AddEntry(Muon_plot_z020,"#theta = 20^{o}","p"); - leg->AddEntry(Muon_plot_z040,"#theta = 40^{o}","p"); - leg->AddEntry(Muon_plot_z085,"#theta = 85^{o}","p"); - leg->Draw(); - - c_two->SaveAs("pull_sigma_ILD_l5_v02.png"); + TCanvas* c_two = new TCanvas("MomentumResolutionBar", "Track Parameters #sigma", 200, 10, 700, 500); + c_two->Divide(3, 2); + + c_two->cd(1); + c_two->cd(1)->SetLogx(); + c_two->cd(1)->SetTickx(1); + c_two->cd(1)->SetTicky(1); + + TGraphErrors* Muon_plot_omega10 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega10, zeros, errorOmega10); + Muon_plot_omega10->SetTitle("#Omega"); + Muon_plot_omega10->SetMarkerColor(6); + Muon_plot_omega10->SetMarkerStyle(24); + Muon_plot_omega10->SetMarkerSize(1); + Muon_plot_omega10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_omega10->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_omega10->SetMinimum(0.70); + Muon_plot_omega10->SetMaximum(1.50); + Muon_plot_omega10->Draw("AP"); + + TGraphErrors* Muon_plot_omega20 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega20, zeros, errorOmega20); + Muon_plot_omega20->SetMarkerColor(4); + Muon_plot_omega20->SetMarkerStyle(22); + Muon_plot_omega20->SetMarkerSize(1); + Muon_plot_omega20->Draw("P"); + + TGraphErrors* Muon_plot_omega40 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega40, zeros, errorOmega40); + Muon_plot_omega40->SetMarkerColor(2); + Muon_plot_omega40->SetMarkerStyle(21); + Muon_plot_omega40->SetMarkerSize(1); + Muon_plot_omega40->Draw("P"); + + TGraphErrors* Muon_plot_omega85 = new TGraphErrors(SIZE_M, Momentum, sigmaOmega85, zeros, errorOmega85); + Muon_plot_omega85->SetMarkerColor(1); + Muon_plot_omega85->SetMarkerStyle(20); + Muon_plot_omega85->SetMarkerSize(1); + Muon_plot_omega85->Draw("P"); + + c_two->cd(2); + c_two->cd(2)->SetLogx(); + c_two->cd(2)->SetTickx(1); + c_two->cd(2)->SetTicky(1); + + TGraphErrors* Muon_plot_tanlambda10 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda10, zeros, errorTanLambda10); + Muon_plot_tanlambda10->SetTitle("tan #lambda"); + Muon_plot_tanlambda10->SetMarkerColor(6); + Muon_plot_tanlambda10->SetMarkerStyle(24); + Muon_plot_tanlambda10->SetMarkerSize(1); + Muon_plot_tanlambda10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_tanlambda10->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_tanlambda10->SetMinimum(0.70); + Muon_plot_tanlambda10->SetMaximum(1.50); + Muon_plot_tanlambda10->Draw("AP"); + + TGraphErrors* Muon_plot_tanlambda20 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda20, zeros, errorTanLambda20); + Muon_plot_tanlambda20->SetMarkerColor(4); + Muon_plot_tanlambda20->SetMarkerStyle(22); + Muon_plot_tanlambda20->SetMarkerSize(1); + Muon_plot_tanlambda20->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda40 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda40, zeros, errorTanLambda40); + Muon_plot_tanlambda40->SetMarkerColor(2); + Muon_plot_tanlambda40->SetMarkerStyle(21); + Muon_plot_tanlambda40->SetMarkerSize(1); + Muon_plot_tanlambda40->Draw("P"); + + TGraphErrors* Muon_plot_tanlambda85 = new TGraphErrors(SIZE_M, Momentum, sigmaTanLambda85, zeros, errorTanLambda85); + Muon_plot_tanlambda85->SetMarkerColor(1); + Muon_plot_tanlambda85->SetMarkerStyle(20); + Muon_plot_tanlambda85->SetMarkerSize(1); + Muon_plot_tanlambda85->Draw("P"); + + c_two->cd(3); + c_two->cd(3)->SetLogx(); + c_two->cd(3)->SetTickx(1); + c_two->cd(3)->SetTicky(1); + + TGraphErrors* Muon_plot_phi10 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi10, zeros, errorPhi10); + Muon_plot_phi10->SetTitle("#phi"); + Muon_plot_phi10->SetMarkerColor(6); + Muon_plot_phi10->SetMarkerStyle(24); + Muon_plot_phi10->SetMarkerSize(1); + Muon_plot_phi10->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_phi10->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_phi10->SetMinimum(0.70); + Muon_plot_phi10->SetMaximum(1.50); + Muon_plot_phi10->Draw("AP"); + + TGraphErrors* Muon_plot_phi20 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi20, zeros, errorPhi20); + Muon_plot_phi20->SetMarkerColor(4); + Muon_plot_phi20->SetMarkerStyle(22); + Muon_plot_phi20->SetMarkerSize(1); + Muon_plot_phi20->Draw("P"); + + TGraphErrors* Muon_plot_phi40 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi40, zeros, errorPhi40); + Muon_plot_phi40->SetMarkerColor(2); + Muon_plot_phi40->SetMarkerStyle(21); + Muon_plot_phi40->SetMarkerSize(1); + Muon_plot_phi40->Draw("P"); + + TGraphErrors* Muon_plot_phi85 = new TGraphErrors(SIZE_M, Momentum, sigmaPhi85, zeros, errorPhi85); + Muon_plot_phi85->SetMarkerColor(1); + Muon_plot_phi85->SetMarkerStyle(20); + Muon_plot_phi85->SetMarkerSize(1); + Muon_plot_phi85->Draw("P"); + + c_two->cd(4); + c_two->cd(4)->SetLogx(); + c_two->cd(4)->SetTickx(1); + c_two->cd(4)->SetTicky(1); + + TGraphErrors* Muon_plot_d010 = new TGraphErrors(SIZE_M, Momentum, sigmad010, zeros, errord010); + Muon_plot_d010->SetTitle("d0"); + Muon_plot_d010->SetMarkerColor(6); + Muon_plot_d010->SetMarkerStyle(24); + Muon_plot_d010->SetMarkerSize(1); + Muon_plot_d010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_d010->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_d010->SetMinimum(0.70); + Muon_plot_d010->SetMaximum(1.50); + Muon_plot_d010->Draw("AP"); + + TGraphErrors* Muon_plot_d020 = new TGraphErrors(SIZE_M, Momentum, sigmad020, zeros, errord020); + Muon_plot_d020->SetMarkerColor(4); + Muon_plot_d020->SetMarkerStyle(22); + Muon_plot_d020->SetMarkerSize(1); + + Muon_plot_d020->Draw("P"); + + TGraphErrors* Muon_plot_d040 = new TGraphErrors(SIZE_M, Momentum, sigmad040, zeros, errord040); + Muon_plot_d040->SetMarkerColor(2); + Muon_plot_d040->SetMarkerStyle(21); + Muon_plot_d040->SetMarkerSize(1); + Muon_plot_d040->Draw("P"); + + TGraphErrors* Muon_plot_d085 = new TGraphErrors(SIZE_M, Momentum, sigmad085, zeros, errord085); + Muon_plot_d085->SetMarkerColor(1); + Muon_plot_d085->SetMarkerStyle(20); + Muon_plot_d085->SetMarkerSize(1); + Muon_plot_d085->Draw("P"); + + c_two->cd(5); + c_two->cd(5)->SetLogx(); + c_two->cd(5)->SetTickx(1); + c_two->cd(5)->SetTicky(1); + + TGraphErrors* Muon_plot_z010 = new TGraphErrors(SIZE_M, Momentum, sigmaz010, zeros, errorz010); + Muon_plot_z010->SetTitle("z0"); + Muon_plot_z010->SetMarkerColor(6); + Muon_plot_z010->SetMarkerStyle(24); + Muon_plot_z010->SetMarkerSize(1); + Muon_plot_z010->GetXaxis()->SetTitle("P (GeV)"); + Muon_plot_z010->GetYaxis()->SetTitle("#sigma = f(P,#theta)"); + Muon_plot_z010->SetMinimum(0.70); + Muon_plot_z010->SetMaximum(1.50); + Muon_plot_z010->Draw("AP"); + + TGraphErrors* Muon_plot_z020 = new TGraphErrors(SIZE_M, Momentum, sigmaz020, zeros, errorz020); + Muon_plot_z020->SetMarkerColor(4); + Muon_plot_z020->SetMarkerStyle(22); + Muon_plot_z020->SetMarkerSize(1); + Muon_plot_z020->Draw("P"); + + TGraphErrors* Muon_plot_z040 = new TGraphErrors(SIZE_M, Momentum, sigmaz040, zeros, errorz040); + Muon_plot_z040->SetMarkerColor(2); + Muon_plot_z040->SetMarkerStyle(21); + Muon_plot_z040->SetMarkerSize(1); + Muon_plot_z040->Draw("P"); + + TGraphErrors* Muon_plot_z085 = new TGraphErrors(SIZE_M, Momentum, sigmaz085, zeros, errorz085); + Muon_plot_z085->SetMarkerColor(1); + Muon_plot_z085->SetMarkerStyle(20); + Muon_plot_z085->SetMarkerSize(1); + Muon_plot_z085->Draw("P"); + + c_two->cd(6); + TLegend* leg = new TLegend(0.5, 0.5, 0.75, 0.89); + // leg->SetHeader("Polar Angles"); //name of the legend + leg->AddEntry(Muon_plot_z010, "#theta = 10^{o}", "p"); + leg->AddEntry(Muon_plot_z020, "#theta = 20^{o}", "p"); + leg->AddEntry(Muon_plot_z040, "#theta = 40^{o}", "p"); + leg->AddEntry(Muon_plot_z085, "#theta = 85^{o}", "p"); + leg->Draw(); + + c_two->SaveAs("pull_sigma_ILD_l5_v02.png"); } diff --git a/validateSim/include/valStruct.h b/validateSim/include/valStruct.h index 5ace2c9..ee17b2e 100644 --- a/validateSim/include/valStruct.h +++ b/validateSim/include/valStruct.h @@ -2,15 +2,15 @@ #define _validatePilotProcessor_maxMin_ 1 struct validatePilotProcessor_maxMin { - std::vector < std::string > indx_name{}; - std::vector < std::pair < int, int > > indx_minmax{}; - std::pair < float, float > eminmax{}; - std::pair < float, float > tminmax{}; - std::pair < float, float > xminmax{}; - std::pair < float, float > yminmax{}; - std::pair < float, float > zminmax{}; - std::pair < float, float > rminmax{}; - std::pair < float, float > abszminmax{}; + std::vector indx_name{}; + std::vector> indx_minmax{}; + std::pair eminmax{}; + std::pair tminmax{}; + std::pair xminmax{}; + std::pair yminmax{}; + std::pair zminmax{}; + std::pair rminmax{}; + std::pair abszminmax{}; }; #endif diff --git a/validateSim/include/validateAuto.h b/validateSim/include/validateAuto.h index 53329ba..1ae0d08 100644 --- a/validateSim/include/validateAuto.h +++ b/validateSim/include/validateAuto.h @@ -1,52 +1,49 @@ #ifndef validateAutoProcessor_h #define validateAutoProcessor_h 1 -#include "marlin/Processor.h" -#include "valStruct.h" -#include "UTIL/CellIDDecoder.h" +#include "EVENT/CalorimeterHit.h" #include "EVENT/SimCalorimeterHit.h" #include "EVENT/SimTrackerHit.h" -#include "EVENT/CalorimeterHit.h" #include "EVENT/TrackerHit.h" +#include "UTIL/CellIDDecoder.h" +#include "marlin/Processor.h" +#include "valStruct.h" #include "TFile.h" #include "TH1F.h" #include "TH2F.h" -using namespace marlin ; - +using namespace marlin; class validateAutoProcessor : public Processor { - - public: - - virtual Processor* newProcessor() { return new validateAutoProcessor ; } - - validateAutoProcessor(const validateAutoProcessor&) = delete ; - validateAutoProcessor& operator=(const validateAutoProcessor& ) = delete ; - - validateAutoProcessor() ; - + +public: + virtual Processor* newProcessor() { return new validateAutoProcessor; } + + validateAutoProcessor(const validateAutoProcessor&) = delete; + validateAutoProcessor& operator=(const validateAutoProcessor&) = delete; + + validateAutoProcessor(); + /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ - virtual void init() ; - + virtual void init(); + /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; - + virtual void processRunHeader(LCRunHeader* run); + /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; + virtual void processEvent(LCEvent* evt); + + virtual void check(LCEvent* evt); - virtual void check( LCEvent * evt ) ; - /** Called after data processing for clean up. */ - virtual void end() ; - - protected: + virtual void end(); +protected: StringVec _infiles{}; std::string _outfile{}; @@ -54,41 +51,34 @@ class validateAutoProcessor : public Processor { float _maxZ{}; float _minZ{}; float _maxE{}; - bool _isEndcap{}; + bool _isEndcap{}; - std::vector < std::string > cellindices{}; + std::vector cellindices{}; - CellIDDecoder * _SimCalorimeterHitDecoder{}; - CellIDDecoder * _SimTrackerHitDecoder{}; - CellIDDecoder * _CalorimeterHitDecoder{}; - CellIDDecoder * _TrackerHitDecoder{}; - - std::map < std::string , validatePilotProcessor_maxMin > _allranges{}; + CellIDDecoder* _SimCalorimeterHitDecoder{}; + CellIDDecoder* _SimTrackerHitDecoder{}; + CellIDDecoder* _CalorimeterHitDecoder{}; + CellIDDecoder* _TrackerHitDecoder{}; + std::map _allranges{}; TFile* _fout{}; TH2F* _hAll_overallposZR{}; TH2F* _hAll_Log_overallposZR{}; - std::map < std::string, TH2F* > _h_overallposZR{}; - std::map < std::string, TH2F* > _h_Log_overallposZR{}; - - std::map < std::string, TH1F* > _h_HitEn{}; - std::map < std::string, TH1F* > _h_HitTime{}; - std::map < std::string, std::pair < TH2F* , TH2F* > > _h_posXY{}; - std::map < std::string, std::pair < TH2F* , TH2F* > > _h_posZR{}; - - std::map < std::string, std::vector < std::pair < TH2F* , TH2F* > > > _h_index_posX{}; - std::map < std::string, std::vector < std::pair < TH2F* , TH2F* > > > _h_index_posY{}; - std::map < std::string, std::vector < std::pair < TH2F* , TH2F* > > > _h_index_posZ{}; - std::map < std::string, std::vector < std::pair < TH2F* , TH2F* > > > _h_index_posR{}; - std::map < std::string, std::vector < std::pair < TH2F* , TH2F* > > > _h_index_posPhi{}; - - + std::map _h_overallposZR{}; + std::map _h_Log_overallposZR{}; + + std::map _h_HitEn{}; + std::map _h_HitTime{}; + std::map> _h_posXY{}; + std::map> _h_posZR{}; + + std::map>> _h_index_posX{}; + std::map>> _h_index_posY{}; + std::map>> _h_index_posZ{}; + std::map>> _h_index_posR{}; + std::map>> _h_index_posPhi{}; }; - #endif - - - diff --git a/validateSim/include/validatePilot.h b/validateSim/include/validatePilot.h index d51728b..9cc0884 100644 --- a/validateSim/include/validatePilot.h +++ b/validateSim/include/validatePilot.h @@ -2,71 +2,62 @@ #define validatePilotProcessor_h 1 #include "marlin/Processor.h" -#include "UTIL/CellIDDecoder.h" +#include "EVENT/CalorimeterHit.h" #include "EVENT/SimCalorimeterHit.h" #include "EVENT/SimTrackerHit.h" -#include "EVENT/CalorimeterHit.h" #include "EVENT/TrackerHit.h" -#include "valStruct.h" #include "TFile.h" #include "TH1F.h" #include "TH2F.h" +#include "UTIL/CellIDDecoder.h" +#include "valStruct.h" -using namespace marlin ; +using namespace marlin; +class validatePilotProcessor : public Processor { +public: + virtual Processor* newProcessor() { return new validatePilotProcessor; } -class validatePilotProcessor : public Processor { - - public: - - virtual Processor* newProcessor() { return new validatePilotProcessor ; } + validatePilotProcessor(const validatePilotProcessor&) = delete; + validatePilotProcessor& operator=(const validatePilotProcessor&) = delete; - validatePilotProcessor(const validatePilotProcessor&) = delete ; - validatePilotProcessor& operator=(const validatePilotProcessor& ) = delete ; + validatePilotProcessor(); - validatePilotProcessor() ; - /** Called at the begin of the job before anything is read. * Use to initialize the processor, e.g. book histograms. */ - virtual void init() ; - + virtual void init(); + /** Called for every run. */ - virtual void processRunHeader( LCRunHeader* run ) ; - + virtual void processRunHeader(LCRunHeader* run); + /** Called for every event - the working horse. */ - virtual void processEvent( LCEvent * evt ) ; + virtual void processEvent(LCEvent* evt); + + virtual void check(LCEvent* evt); - virtual void check( LCEvent * evt ) ; - /** Called after data processing for clean up. */ - virtual void end() ; - - protected: + virtual void end(); +protected: std::string _outfile{}; - std::map < std::string , std::vector < std::pair < std::string, std::pair > > > _indxCode{}; - - CellIDDecoder * _SimCalorimeterHitDecoder{}; - CellIDDecoder * _SimTrackerHitDecoder{}; - CellIDDecoder * _CalorimeterHitDecoder{}; - CellIDDecoder * _TrackerHitDecoder{}; + std::map>>> _indxCode{}; - std::map < std::string , validatePilotProcessor_maxMin > _allranges{}; + CellIDDecoder* _SimCalorimeterHitDecoder{}; + CellIDDecoder* _SimTrackerHitDecoder{}; + CellIDDecoder* _CalorimeterHitDecoder{}; + CellIDDecoder* _TrackerHitDecoder{}; - std::map < std::string , int > _colTypes{}; + std::map _allranges{}; - enum {SIMCALO=0, SIMTRK, CALO, TRK}; + std::map _colTypes{}; + enum { SIMCALO = 0, SIMTRK, CALO, TRK }; }; - #endif - - - diff --git a/validateSim/test/plotauto.C b/validateSim/test/plotauto.C index 0709bbb..8343c95 100644 --- a/validateSim/test/plotauto.C +++ b/validateSim/test/plotauto.C @@ -1,14 +1,14 @@ -#include "TFile.h" #include "TCanvas.h" -#include "TKey.h" -#include "TROOT.h" +#include "TFile.h" #include "TH1F.h" #include "TH2F.h" +#include "TKey.h" +#include "TLegend.h" +#include "TROOT.h" #include "TStyle.h" #include "TText.h" -#include "TLegend.h" -#include #include +#include using std::cout; using std::endl; @@ -23,19 +23,19 @@ using std::endl; void plotauto(TString infilename) { - TString plname = infilename+".ps"; - TCanvas* cc = new TCanvas("validate","validate",500,370); - cc->Print(plname+"["); + TString plname = infilename + ".ps"; + TCanvas* cc = new TCanvas("validate", "validate", 500, 370); + cc->Print(plname + "["); TText tt; tt.SetTextColor(2); tt.SetTextSize(0.02); gStyle->SetMarkerSize(0.1); - gStyle->SetTitleSize(0.15,"ff"); + gStyle->SetTitleSize(0.15, "ff"); gStyle->SetTitleTextColor(4); - std::vector < TString > vnames; + std::vector vnames; vnames.push_back("Sim_HitEn"); vnames.push_back("Sim_HitTime"); vnames.push_back("Sim_posXY"); @@ -43,46 +43,52 @@ void plotauto(TString infilename) { vnames.push_back("Sim_posYZ"); vnames.push_back("Sim_posRZ"); - std::vector exts; + std::vector exts; exts.push_back(""); exts.push_back("_posZ"); exts.push_back("_negZ"); TH1F* h; TH2F* hh; - TKey *key; + TKey* key; TIter next; - TKey *key2; + TKey* key2; TIter next2; TFile* infile = new TFile(infilename, "read"); // overall geometry - TDirectory* td = (TDirectory*) infile->Get("ALLCollections"); + TDirectory* td = (TDirectory*)infile->Get("ALLCollections"); cc->Clear(); - cc->Divide(3,3); + cc->Divide(3, 3); cc->cd(1); - hh = (TH2F*) td->Get("ALLCollections_overallhitZR"); + hh = (TH2F*)td->Get("ALLCollections_overallhitZR"); hh->Draw("box"); cc->cd(2); - int icol=1; - bool first=true; + int icol = 1; + bool first = true; TLegend* tl = new TLegend(0., 0., 1, 1); next = td->GetListOfKeys(); while ((key = (TKey*)next())) { - TClass *cll = gROOT->GetClass(key->GetClassName()); + TClass* cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); - if ( hn.Contains("ALL") ) continue; - if ( hn.Contains("_Log") ) continue; + if (hn.Contains("ALL")) + continue; + if (hn.Contains("_Log")) + continue; hh->SetLineColor(icol); - if ( first ) {hh->Draw("box"); first=false;} - else hh->Draw("same;box"); + if (first) { + hh->Draw("box"); + first = false; + } else + hh->Draw("same;box"); icol++; - if (icol==10) icol=1; - TString ss = hn.ReplaceAll( "_overallhitZR", ""); - tl->AddEntry(hh, ss , "l"); + if (icol == 10) + icol = 1; + TString ss = hn.ReplaceAll("_overallhitZR", ""); + tl->AddEntry(hh, ss, "l"); } } // the legend @@ -90,162 +96,180 @@ void plotauto(TString infilename) { tl->Draw(); cc->cd(4); - hh = (TH2F*) td->Get("ALLCollections_Log_overallhitZR"); + hh = (TH2F*)td->Get("ALLCollections_Log_overallhitZR"); hh->Draw("box"); cc->cd(5); - icol=1; - first=true; + icol = 1; + first = true; next = td->GetListOfKeys(); while ((key = (TKey*)next())) { - TClass *cll = gROOT->GetClass(key->GetClassName()); + TClass* cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); - if ( hn.Contains("ALL" ) ) continue; - if ( ! hn.Contains("_Log_") ) continue; + if (hn.Contains("ALL")) + continue; + if (!hn.Contains("_Log_")) + continue; hh->SetLineColor(icol); - if ( first ) {hh->Draw("box"); first=false;} - else hh->Draw("same;box"); + if (first) { + hh->Draw("box"); + first = false; + } else + hh->Draw("same;box"); icol++; - if (icol==10) icol=1; + if (icol == 10) + icol = 1; } } cc->cd(7); - hh = (TH2F*) td->Get("ALLCollections_LogLog_overallhitZR"); + hh = (TH2F*)td->Get("ALLCollections_LogLog_overallhitZR"); hh->Draw("box"); cc->cd(8); - icol=1; - first=true; + icol = 1; + first = true; next = td->GetListOfKeys(); while ((key = (TKey*)next())) { - TClass *cll = gROOT->GetClass(key->GetClassName()); + TClass* cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); - if ( hn.Contains("ALL" ) ) continue; - if ( ! hn.Contains("_LogLog_") ) continue; + if (hn.Contains("ALL")) + continue; + if (!hn.Contains("_LogLog_")) + continue; hh->SetLineColor(icol); - if ( first ) {hh->Draw("box"); first=false;} - else hh->Draw("same;box"); + if (first) { + hh->Draw("box"); + first = false; + } else + hh->Draw("same;box"); icol++; - if (icol==10) icol=1; + if (icol == 10) + icol = 1; } } - cc->Print(plname); // now collection-by-collection next = infile->GetListOfKeys(); while ((key = (TKey*)next())) { - TClass *cll = gROOT->GetClass(key->GetClassName()); + TClass* cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TDirectory")) { td = (TDirectory*)key->ReadObj(); TString dirname = td->GetName(); - if ( dirname=="ALLCollections" ) continue; + if (dirname == "ALLCollections") + continue; // is it an endcap collection? - bool isEndcap = td->Get(dirname+"_hitXY_posZ"); + bool isEndcap = td->Get(dirname + "_hitXY_posZ"); // first overall geometry cc->Clear(); - cc->Divide(3,2); - - cc->cd(1); - ( (TH2F*) td->Get(dirname+"_hitEn"))->Draw("box"); - cc->cd(4)->SetLogy(); - ( (TH2F*) td->Get(dirname+"_hitTime"))->Draw("box"); - - if ( isEndcap ) { - cc->cd(2); - ( (TH2F*) td->Get(dirname+"_hitXY_posZ"))->Draw("box"); - cc->cd(3); - ( (TH2F*) td->Get(dirname+"_hitXY_negZ"))->Draw("box"); - cc->cd(5); - ((TH2F*) td->Get(dirname+"_hitZR_posZ"))->Draw("box"); - cc->cd(6); - ((TH2F*) td->Get(dirname+"_hitZR_negZ"))->Draw("box"); + cc->Divide(3, 2); + + cc->cd(1); + ((TH2F*)td->Get(dirname + "_hitEn"))->Draw("box"); + cc->cd(4)->SetLogy(); + ((TH2F*)td->Get(dirname + "_hitTime"))->Draw("box"); + + if (isEndcap) { + cc->cd(2); + ((TH2F*)td->Get(dirname + "_hitXY_posZ"))->Draw("box"); + cc->cd(3); + ((TH2F*)td->Get(dirname + "_hitXY_negZ"))->Draw("box"); + cc->cd(5); + ((TH2F*)td->Get(dirname + "_hitZR_posZ"))->Draw("box"); + cc->cd(6); + ((TH2F*)td->Get(dirname + "_hitZR_negZ"))->Draw("box"); } else { - cc->cd(2); - ( (TH2F*) td->Get(dirname+"_hitXY"))->Draw("box"); - cc->cd(3); - ( (TH2F*) td->Get(dirname+"_hitZR"))->Draw("box"); + cc->cd(2); + ((TH2F*)td->Get(dirname + "_hitXY"))->Draw("box"); + cc->cd(3); + ((TH2F*)td->Get(dirname + "_hitZR"))->Draw("box"); } cc->Print(plname); - // then the cell indices // work out how many indices/variables we're dealing with - std::vector < TString > indices; - std::vector < TString > variables; + std::vector indices; + std::vector variables; next2 = td->GetListOfKeys(); while ((key2 = (TKey*)next2())) { - cll = gROOT->GetClass(key2->GetClassName()); - if (cll->InheritsFrom("TH2F")) { - hh = (TH2F*) key2->ReadObj(); - TString hn = hh->GetName(); - if ( hn.Contains("Indx") ) { - TString ss = hn.ReplaceAll(dirname+"_", ""); - TString asas = ((TObjString*) (ss.Tokenize("_") -> At(0)))->GetString(); - if ( find( indices.begin(), indices.end(), asas )==indices.end() ) indices.push_back(asas); - asas = ((TObjString*) (ss.Tokenize("_") -> At(1)))->GetString(); - if ( find( variables.begin(), variables.end(), asas )==variables.end() ) variables.push_back(asas); - } - } + cll = gROOT->GetClass(key2->GetClassName()); + if (cll->InheritsFrom("TH2F")) { + hh = (TH2F*)key2->ReadObj(); + TString hn = hh->GetName(); + if (hn.Contains("Indx")) { + TString ss = hn.ReplaceAll(dirname + "_", ""); + TString asas = ((TObjString*)(ss.Tokenize("_")->At(0)))->GetString(); + if (find(indices.begin(), indices.end(), asas) == indices.end()) + indices.push_back(asas); + asas = ((TObjString*)(ss.Tokenize("_")->At(1)))->GetString(); + if (find(variables.begin(), variables.end(), asas) == variables.end()) + variables.push_back(asas); + } + } } - if ( indices.size()==0 || variables.size()==0 ) continue; - - - for (int inp=0; inp<2; inp++) { - if ( !isEndcap && inp==1 ) continue; - cc->Clear(); - cc->Divide(indices.size(), variables.size()); - int ic=1; - next2 = td->GetListOfKeys(); - while ((key2 = (TKey*)next2())) { - cll = gROOT->GetClass(key2->GetClassName()); - if (cll->InheritsFrom("TH2F")) { - hh = (TH2F*) key2->ReadObj(); - TString hn = hh->GetName(); - if ( isEndcap ) { - if ( inp==0 && ! hn.Contains("posZ") ) continue; - else if ( inp==1 && ! hn.Contains("negZ") ) continue; - } - if ( hn.Contains("Indx") ) { - TString asas = ((TObjString*) (hn.Tokenize("_") -> At(1)))->GetString(); - asas = asas(4,asas.Length()); - cc->cd(ic++); - hh->Draw("box"); - } - } - } - - cc->cd(); - for ( size_t k=0; kPrint(plname); + if (indices.size() == 0 || variables.size() == 0) + continue; + + for (int inp = 0; inp < 2; inp++) { + if (!isEndcap && inp == 1) + continue; + cc->Clear(); + cc->Divide(indices.size(), variables.size()); + int ic = 1; + next2 = td->GetListOfKeys(); + while ((key2 = (TKey*)next2())) { + cll = gROOT->GetClass(key2->GetClassName()); + if (cll->InheritsFrom("TH2F")) { + hh = (TH2F*)key2->ReadObj(); + TString hn = hh->GetName(); + if (isEndcap) { + if (inp == 0 && !hn.Contains("posZ")) + continue; + else if (inp == 1 && !hn.Contains("negZ")) + continue; + } + if (hn.Contains("Indx")) { + TString asas = ((TObjString*)(hn.Tokenize("_")->At(1)))->GetString(); + asas = asas(4, asas.Length()); + cc->cd(ic++); + hh->Draw("box"); + } + } + } + + cc->cd(); + for (size_t k = 0; k < variables.size(); k++) { + tt.DrawTextNDC(0.0, 0.9 - (1.0 * k) / (variables.size()), variables[k]); + } + + for (size_t k = 0; k < indices.size(); k++) { + tt.DrawTextNDC(0.05 + (1.0 * k) / (indices.size()), 0.02, indices[k].ReplaceAll("Indx", "Indx_")); + } + + tt.DrawTextNDC(0.1, 0.99, dirname); + if (isEndcap) { + if (inp == 0) + tt.DrawTextNDC(0.35, 0.99, "posZ"); + else + tt.DrawTextNDC(0.35, 0.99, "negZ"); + } + + cc->Print(plname); } } } infile->Close(); - cc->Print(plname+"]"); + cc->Print(plname + "]"); } From 3ba941bdc6f1ae9c8e2d2805e9e402ea9e995dfd Mon Sep 17 00:00:00 2001 From: Victor Schwan Date: Fri, 29 May 2026 13:24:20 +0200 Subject: [PATCH 3/5] Add formatting commit to ignored commits for git blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 65f7b68..d3e8998 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,3 +1,4 @@ 2db7e8caefb409a8fa62f094a829041d6cd8e7ef 59e15ce2182927fc057b2ad5ae9897e0d1df2d0f e2d838570a634f446b83b8a94ce84d567a4ef510 +81b289e17e7d3776b68c4b8656e9ce522f58b9ab From f255aa7b41914d2339e6b8684e22d1e2aa493926 Mon Sep 17 00:00:00 2001 From: Victor Schwan Date: Thu, 28 May 2026 22:54:12 +0200 Subject: [PATCH 4/5] D0ResolutionL5: promote DetModName to proc param --- tracking/macros/D0ResolutionL5.C | 21 ++++++++++++--------- tracking/test/run_ILD_l5_v02_singleMuon.sh | 3 ++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tracking/macros/D0ResolutionL5.C b/tracking/macros/D0ResolutionL5.C index dde09ec..883eaf0 100644 --- a/tracking/macros/D0ResolutionL5.C +++ b/tracking/macros/D0ResolutionL5.C @@ -30,10 +30,10 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void D0ResolutionL5() { +void D0ResolutionL5(const char* modelName = "ILD_l5_v02") { TCanvas* D0_fit = new TCanvas("D0 fit", "D0 fit", 800, 800); - D0_fit->Print("D0_fit_ILD_l5_v02.pdf["); + D0_fit->Print(Form("D0_fit_%s.pdf[", modelName)); for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; @@ -41,13 +41,15 @@ void D0ResolutionL5() { for (int ii = 0; ii < SIZE_PA; ii++) { for (int i = 0; i < SIZE_M; i++) { - TFile* f = - new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + TFile* f = new TFile(Form("../Results/Analysis/" + "analysis_%s_MuonsAngle_%d_Mom_%d.root", + modelName, PA[ii], Mom[i]), + "read"); // TTree *EvalTree = (TTree*)f->Get("EvalTree"); TTree* EvalTree; f->GetObject("EvalTree", EvalTree); - printf(" I am studying file analysis_MuonsAngle_%d_Mom_%d.root ", PA[ii], Mom[i]); + printf(" I am studying file analysis_%s_MuonsAngle_%d_Mom_%d.root ", modelName, PA[ii], Mom[i]); vector* recoD0 = 0; vector* trueD0 = 0; @@ -112,14 +114,15 @@ void D0ResolutionL5() { sigma[i][ii] = (fit1->GetParameter(2)); error_sigma[i][ii] = (fit1->GetParError(2)); - // std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " << sigma[i][ii] << std::endl ; + // std::cout << " angle " << PA[ii] << " momentum " << Mom[i] << " sigma " + // << sigma[i][ii] << std::endl ; - D0_fit->Print("D0_fit_ILD_l5_v02.pdf", &dummy[0]); + D0_fit->Print(Form("D0_fit_%s.pdf", modelName), &dummy[0]); } // loop for each .root files, here I have collected sigma and its error } // polar angle loop - D0_fit->Print("D0_fit_ILD_l5_v02.pdf]"); + D0_fit->Print(Form("D0_fit_%s.pdf]", modelName)); float sigma20[SIZE_M]; float error20[SIZE_M]; @@ -230,5 +233,5 @@ void D0ResolutionL5() { fpr85->SetLineColor(1); // fpr85->Draw("same"); - c_two->SaveAs("IPResolution_ILD_l5_v02.png"); + c_two->SaveAs(Form("IPResolution_%s.png", modelName)); } diff --git a/tracking/test/run_ILD_l5_v02_singleMuon.sh b/tracking/test/run_ILD_l5_v02_singleMuon.sh index 84c4934..86e6bff 100755 --- a/tracking/test/run_ILD_l5_v02_singleMuon.sh +++ b/tracking/test/run_ILD_l5_v02_singleMuon.sh @@ -125,7 +125,8 @@ mv analysis_${ILDMODELRECO}_${ILCSOFTVER}_MuonsAngle_*_Mom_*.root ../Results/Ana cd ../macros -root -b -q D0ResolutionL5.C +root -b -q "D0ResolutionL5.C(\"${ILDMODELRECO}\")" +# root -b -q D0ResolutionL5.C root -b -q PResolutionL5.C root -b -q meanL5.C root -b -q sigmaL5.C From a05a909d6148553fee8d8a18a2d4366692c28e06 Mon Sep 17 00:00:00 2001 From: Victor Schwan Date: Fri, 29 May 2026 16:17:45 +0200 Subject: [PATCH 5/5] Other macros: Also promote DetModName to proc param --- tracking/macros/PResolutionL5.C | 12 ++++++------ tracking/macros/meanL5.C | 6 +++--- tracking/macros/sigmaL5.C | 6 +++--- tracking/test/run_ILD_l5_v02_singleMuon.sh | 7 +++---- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tracking/macros/PResolutionL5.C b/tracking/macros/PResolutionL5.C index 684c63d..1ca7bd5 100644 --- a/tracking/macros/PResolutionL5.C +++ b/tracking/macros/PResolutionL5.C @@ -25,10 +25,10 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void PResolutionL5() { +void PResolutionL5(const char* modelName = "ILD_l5_v02") { TCanvas* PR_fit = new TCanvas("PR fit", "PR fit", 800, 800); - PR_fit->Print("PR_fit_ILD_l5_v02.pdf["); + PR_fit->Print(Form("PR_fit_%s.pdf[", modelName)); for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; @@ -36,7 +36,7 @@ void PResolutionL5() { for (int ii = 0; ii < SIZE_PA; ii++) { for (int i = 0; i < SIZE_M; i++) { TFile* f = - new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + new TFile(Form("../Results/Analysis/analysis_%s_MuonsAngle_%d_Mom_%d.root", modelName, PA[ii], Mom[i]), "read"); // TTree *EvalTree = (TTree*)f->Get("EvalTree"); TTree* EvalTree; f->GetObject("EvalTree", EvalTree); @@ -99,12 +99,12 @@ void PResolutionL5() { // std::cout << " sigma " << sigma[i][ii] <Print("PR_fit_ILD_l5_v02.pdf", &dummy[0]); + PR_fit->Print(Form("PR_fit_%s.pdf", modelName), &dummy[0]); } // loop for each .root files, here I have collected sigma and its error } // polar angle loop - PR_fit->Print("PR_fit_ILD_l5_v02.pdf]"); + PR_fit->Print(Form("PR_fit_%s.pdf]", modelName)); float sigma20[SIZE_M]; float error20[SIZE_M]; @@ -216,5 +216,5 @@ void PResolutionL5() { fpr85->SetLineColor(1); // fpr85->Draw("same"); - c_two->SaveAs("PResolution_ILD_l5_v02.png"); + c_two->SaveAs(Form("PResolution_%s.png", modelName)); } diff --git a/tracking/macros/meanL5.C b/tracking/macros/meanL5.C index d712c19..554211c 100644 --- a/tracking/macros/meanL5.C +++ b/tracking/macros/meanL5.C @@ -28,7 +28,7 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void meanL5() { +void meanL5(const char* modelName = "ILD_l5_v02") { for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } @@ -77,7 +77,7 @@ void meanL5() { for (int ii = 0; ii < SIZE_PA; ii++) { for (int i = 0; i < SIZE_M; i++) { TFile* f1 = - new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + new TFile(Form("../Results/Analysis/analysis_%s_MuonsAngle_%d_Mom_%d.root", modelName, PA[ii], Mom[i]), "read"); // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); TH1F* hOmega = (TH1F*)f1->Get("OmegaPull"); @@ -399,5 +399,5 @@ void meanL5() { leg->AddEntry(Muon_plot_omega85, "#theta = 85^{o}", "p"); leg->Draw(); - c_two->SaveAs("pull_mean_ILD_l5_v02.png"); + c_two->SaveAs(Form("pull_mean_%s.png", modelName)); } diff --git a/tracking/macros/sigmaL5.C b/tracking/macros/sigmaL5.C index 1d105b1..266534f 100644 --- a/tracking/macros/sigmaL5.C +++ b/tracking/macros/sigmaL5.C @@ -28,7 +28,7 @@ int PA[SIZE_PA] = {10, 20, 40, 85}; float LimAxis; int color, marker; -void sigmaL5() { +void sigmaL5(const char* modelName = "ILD_l5_v02") { for (int ll = 0; ll < SIZE_M; ll++) { zeros[ll] = 0; } @@ -77,7 +77,7 @@ void sigmaL5() { for (int ii = 0; ii < SIZE_PA; ii++) { for (int i = 0; i < SIZE_M; i++) { TFile* f1 = - new TFile(Form("../Results/Analysis/analysis_ILD_l5_v02_MuonsAngle_%d_Mom_%d.root", PA[ii], Mom[i]), "read"); + new TFile(Form("../Results/Analysis/analysis_%s_MuonsAngle_%d_Mom_%d.root", modelName, PA[ii], Mom[i]), "read"); // TDirectory *d1 = (TDirectory*) f1->Get("MyRecoMCTruthLinker"); TH1F* hOmega = (TH1F*)f1->Get("OmegaPull"); @@ -400,5 +400,5 @@ void sigmaL5() { leg->AddEntry(Muon_plot_z085, "#theta = 85^{o}", "p"); leg->Draw(); - c_two->SaveAs("pull_sigma_ILD_l5_v02.png"); + c_two->SaveAs(Form("pull_sigma_%s.png", modelName)); } diff --git a/tracking/test/run_ILD_l5_v02_singleMuon.sh b/tracking/test/run_ILD_l5_v02_singleMuon.sh index 86e6bff..dc65061 100755 --- a/tracking/test/run_ILD_l5_v02_singleMuon.sh +++ b/tracking/test/run_ILD_l5_v02_singleMuon.sh @@ -126,10 +126,9 @@ mv analysis_${ILDMODELRECO}_${ILCSOFTVER}_MuonsAngle_*_Mom_*.root ../Results/Ana cd ../macros root -b -q "D0ResolutionL5.C(\"${ILDMODELRECO}\")" -# root -b -q D0ResolutionL5.C -root -b -q PResolutionL5.C -root -b -q meanL5.C -root -b -q sigmaL5.C +root -b -q "PResolutionL5.C(\"${ILDMODELRECO}\")" +root -b -q "meanL5.C(\"${ILDMODELRECO}\")" +root -b -q "sigmaL5.C(\"${ILDMODELRECO}\")" OUTPUTPATH=../Results/MonitorPlots