From 3a53f133dc104b753cac01b0a06db251bf54b5bf Mon Sep 17 00:00:00 2001
From: Whitney Armstrong <warmstrong@anl.gov>
Date: Wed, 21 Oct 2020 00:40:52 -0500
Subject: [PATCH] 	modified:   .clang-format 	modified:  
 ecal/scripts/emcal_electrons.cxx 	modified:   ecal/scripts/emcal_pi0.cxx

---
 .clang-format                    | 116 +++++++++++++++++++++++++++++--
 ecal/scripts/emcal_electrons.cxx |  19 +++--
 ecal/scripts/emcal_pi0.cxx       |  16 +++--
 3 files changed, 133 insertions(+), 18 deletions(-)

diff --git a/.clang-format b/.clang-format
index 11bdfea9..05b10dc8 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,10 +1,112 @@
 ---
-BasedOnStyle:  LLVM
-BreakConstructorInitializersBeforeComma: true
-ConstructorInitializerAllOnOneLineOrOnePerLine: true
+Language:        Cpp
+BasedOnStyle:  Chromium
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: true
+AlignConsecutiveDeclarations: true
+AlignEscapedNewlines: Right
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:   
+  AfterClass:      false
+  AfterControlStatement: false
+  AfterEnum:       false
+  AfterFunction:   true
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct:     false
+  AfterUnion:      false
+  AfterExternBlock: false
+  BeforeCatch:     false
+  BeforeElse:      false
+  IndentBraces:    false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit:     120
+CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
 Cpp11BracedListStyle: true
-Standard: Cpp11
-#SpaceBeforeParens: ControlStatements
-SpaceAfterControlStatementKeyword: true
-PointerBindsToType: true
+DerivePointerAlignment: false
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:   
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+IncludeBlocks:   Preserve
+IncludeCategories: 
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
+    Priority:        2
+  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
+    Priority:        3
+  - Regex:           '.*'
+    Priority:        1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+IndentPPDirectives: None
+IndentWidth:     2
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: All
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Left
+ReflowComments:  true
+SortIncludes:    true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+#SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        8
+UseTab:          Never
 ...
+
diff --git a/ecal/scripts/emcal_electrons.cxx b/ecal/scripts/emcal_electrons.cxx
index d17f6092..9ef64b87 100644
--- a/ecal/scripts/emcal_electrons.cxx
+++ b/ecal/scripts/emcal_electrons.cxx
@@ -19,8 +19,12 @@
 
 using namespace HepMC3;
 
-void emcal_electrons(int n_events = 1e3, double e_start = 1.0, double e_end = 1.0, const char* out_fname = "./data/emcal_electron_0GeVto30GeV_100kEvt.hepmc")
+void emcal_electrons(int n_events = 1e2, double e_start = 1.0, double e_end = 1.0,
+                     const char* out_fname = "./data/emcal_electron_0GeVto30GeV_100kEvt.hepmc")
 {
+  double cos_theta_min = std::cos(M_PI * (120.0 / 180.0));
+  double cos_theta_max = std::cos(M_PI);
+
   WriterAscii hepmc_output(out_fname);
   int events_parsed = 0;
   GenEvent evt(Units::GEV, Units::MM);
@@ -40,13 +44,16 @@ void emcal_electrons(int n_events = 1e3, double e_start = 1.0, double e_end = 1.
         FourVector(0.0, 0.0, 0.0, 0.938), 2212, 4);
 
     // Define momentum
-    Double_t p = r1->Uniform(e_start, e_end);
-    Double_t px;
-    Double_t py;
-    Double_t pz;
+    Double_t p     = r1->Uniform(0.0, 30.0);
+    Double_t phi   = r1->Uniform(0.0, 2.0 * M_PI);
+    Double_t costh = r1->Uniform(cos_theta_min, cos_theta_max);
+    Double_t th    = std::acos(costh);
+    Double_t px    = p * std::cos(phi) * std::sin(th);
+    Double_t py    = p * std::sin(phi) * std::sin(th);
+    Double_t pz    = p * std::cos(th);
     // Generates random vectors, uniformly distributed over the surface of a
     // sphere of given radius, in this case momentum.
-    r1->Sphere(px, py, pz, p);
+    // r1->Sphere(px, py, pz, p);
 
     //std::cout << std::sqrt(px*px + py*py + pz*pz) - p << " is zero? \n";
 
diff --git a/ecal/scripts/emcal_pi0.cxx b/ecal/scripts/emcal_pi0.cxx
index e07101d3..b9a70d1e 100644
--- a/ecal/scripts/emcal_pi0.cxx
+++ b/ecal/scripts/emcal_pi0.cxx
@@ -18,6 +18,9 @@ using namespace HepMC3;
 
 void emcal_pi0(int n_events = 1e6, const char* out_fname = "./data/emcal_pi0_0GeVto30GeV_100kEvt.hepmc")
 {
+  double cos_theta_min = std::cos(M_PI*(120.0/180.0));
+  double cos_theta_max = std::cos(M_PI);
+
   WriterAscii hepmc_output(out_fname);
   int events_parsed = 0;
   GenEvent evt(Units::GEV, Units::MM);
@@ -37,13 +40,16 @@ void emcal_pi0(int n_events = 1e6, const char* out_fname = "./data/emcal_pi0_0Ge
         FourVector(0.0, 0.0, 0.0, 0.938), 2212, 4);
 
     // Define momentum
-    Double_t p = r1->Uniform(0.0,30.0);
-    Double_t px;
-    Double_t py;
-    Double_t pz;
+    Double_t p = r1->Uniform(0.0, 30.0);
+    Double_t phi = r1->Uniform(0.0,2.0*M_PI);
+    Double_t costh = r1->Uniform(cos_theta_min,cos_theta_max);
+    Double_t th = std::acos(costh);
+    Double_t px = p * std::cos(phi)*std::sin(th) ;
+    Double_t py = p * std::sin(phi)*std::sin(th) ;
+    Double_t pz = p * std::cos(th) ;
     // Generates random vectors, uniformly distributed over the surface of a
     // sphere of given radius, in this case momentum.
-    r1->Sphere(px, py, pz, p);
+    //r1->Sphere(px, py, pz, p);
 
     // type 1 is final state
     // pdgid 111 - pi0 135 MeV/c^2
-- 
GitLab