diff --git a/.clang-format b/.clang-format index 0cbccb84d2af16059203b8e1f849b37a0c88e4d0..2ed2489b03a98620d6ce2506fee1f9d9cf87f940 100644 --- a/.clang-format +++ b/.clang-format @@ -1,15 +1,11 @@ --- -Language: Cpp +Standard: Cpp11 BasedOnStyle: Chromium AccessModifierOffset: -2 -AlignAfterOpenBracket: Align AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: true -AlignEscapedNewlines: Right -AlignOperands: true +AlignEscapedNewlines: true AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: false @@ -20,97 +16,17 @@ AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - 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: Attach -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false +BreakConstructorInitializersBeforeComma: true BreakStringLiterals: true -ColumnLimit: 100 +ColumnLimit: 100 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 +ConstructorInitializerAllOnOneLineOrOnePerLine: true Cpp11BracedListStyle: 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 -RawStringFormats: - - Delimiter: pb - Language: TextProto - BasedOnStyle: google -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 +PointerBindsToType: true +SpaceAfterControlStatementKeyword: true TabWidth: 8 UseTab: Never ... - diff --git a/SCRIPTS/SHMS/replay_production_shms.cxx b/SCRIPTS/SHMS/replay_production_shms.cxx index 17547eaa493feeb774b8cd0519bf59eb7a015532..a17c1b04e7b91f4b0cc7a3f96ce9abbd0d43e7e3 100644 --- a/SCRIPTS/SHMS/replay_production_shms.cxx +++ b/SCRIPTS/SHMS/replay_production_shms.cxx @@ -12,67 +12,58 @@ using namespace std; R__LOAD_LIBRARY(libHallC.so) #include "hcana/HallC_Data.h" -#include "THcAnalyzer.h" #include "THaCut.h" -#include "THcGlobals.h" -#include "THcHallCSpectrometer.h" -#include "THcDetectorMap.h" +#include "THaGoldenTrack.h" +#include "THaReactionPoint.h" +#include "THcAerogel.h" +#include "THcAnalyzer.h" #include "THcCherenkov.h" +#include "THcCoinTime.h" +#include "THcConfigEvtHandler.h" #include "THcDC.h" +#include "THcDetectorMap.h" +#include "THcExtTarCor.h" +#include "THcGlobals.h" +#include "THcHallCSpectrometer.h" +#include "THcHodoEff.h" #include "THcHodoscope.h" #include "THcParmList.h" -#include "THaGoldenTrack.h" -#include "THcHodoEff.h" -#include "THcScalerEvtHandler.h" -#include "THcShower.h" -#include "THaReactionPoint.h" -#include "THcExtTarCor.h" +#include "THcPrimaryKine.h" #include "THcRasteredBeam.h" #include "THcRun.h" -#include "THcCoinTime.h" -#include "THcConfigEvtHandler.h" -#include "THcTrigDet.h" -#include "THcTrigApp.h" +#include "THcScalerEvtHandler.h" #include "THcSecondaryKine.h" -#include "THcAerogel.h" -#include "THcPrimaryKine.h" +#include "THcShower.h" +#include "THcTrigApp.h" +#include "THcTrigDet.h" void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { - - //hallc::helper::script_requires_hcana(); - //{ - // std::string process_name = ""; - // if (const char* env_p = std::getenv("_")) { - // process_name = env_p ; - // } - // std::cout << "running program : " << process_name << "\n"; - // auto last_part = process_name.substr(process_name.size()-4,4); - // std::cout << last_part << "\n"; - // if( last_part == "root" ) { - // std::cout << " You are running this script with root!\n"; - // std::cout << " Use hcana instead. \n"; - // std::quick_exit(1); - // } - //} + // =========================================================================== + // Setup logging spdlog::set_level(spdlog::level::warn); spdlog::flush_every(std::chrono::seconds(5)); - + // =========================================================================== // Get RunNumber and MaxEvent if not provided. - if(RunNumber == 0) { + if (RunNumber == 0) { cout << "Enter a Run Number (-1 to exit): "; - if( RunNumber<=0 ) return; + if (RunNumber <= 0) + return; } - if(MaxEvent == 0) { + // note: MaxEvent equal to -1 means all events + if (MaxEvent == 0) { cout << "\nNumber of Events to analyze: "; cin >> MaxEvent; - if(MaxEvent == 0) { + if (MaxEvent == 0) { cerr << "...Invalid entry\n"; exit; } } + // =========================================================================== // Create file name patterns. - const char* RunFileNamePattern = "shms_all_%05d.dat"; + // + // 1. Input files + const char* RunFileNamePattern = "shms_all_%05d.dat"; vector<TString> pathList; pathList.push_back("."); pathList.push_back("./DATA/raw"); @@ -81,8 +72,7 @@ void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { pathList.push_back("./raw.copiedtotape"); pathList.push_back("./raw/../raw.copiedtotape"); pathList.push_back("./cache"); - - //const char* RunFileNamePattern = "raw/coin_all_%05d.dat"; + // 2. Output files const char* ROOTFileNamePattern = "ROOTfiles/shms_replay_production_%d_%d.root"; // Load global parameters @@ -99,11 +89,13 @@ void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { // Load the Hall C detector map gHcDetectorMap = new THcDetectorMap(); gHcDetectorMap->Load("MAPS/SHMS/DETEC/STACK/shms_stack.map"); - - // ======== - // SHMS - // ======== + // =========================================================================== + // Experimental apparatus + // + // --------------------------------------------------------------------------- + // A. SHMS setup + // // Set up the equipment to be analyzed. THcHallCSpectrometer* SHMS = new THcHallCSpectrometer("P", "SHMS"); SHMS->SetEvtType(1); @@ -112,45 +104,64 @@ void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { SHMS->AddEvtType(6); SHMS->AddEvtType(7); gHaApps->Add(SHMS); - // Add Noble Gas Cherenkov to SHMS apparatus + // 1. Add Noble Gas Cherenkov to SHMS apparatus THcCherenkov* pngcer = new THcCherenkov("ngcer", "Noble Gas Cherenkov"); SHMS->AddDetector(pngcer); - // Add drift chambers to SHMS apparatus + // 2. Add drift chambers to SHMS apparatus THcDC* pdc = new THcDC("dc", "Drift Chambers"); SHMS->AddDetector(pdc); - // Add hodoscope to SHMS apparatus + // 3. Add hodoscope to SHMS apparatus THcHodoscope* phod = new THcHodoscope("hod", "Hodoscope"); SHMS->AddDetector(phod); - // Add Heavy Gas Cherenkov to SHMS apparatus + // 4. Add Heavy Gas Cherenkov to SHMS apparatus THcCherenkov* phgcer = new THcCherenkov("hgcer", "Heavy Gas Cherenkov"); SHMS->AddDetector(phgcer); - // Add Aerogel Cherenkov to SHMS apparatus + // 5. Add Aerogel Cherenkov to SHMS apparatus THcAerogel* paero = new THcAerogel("aero", "Aerogel"); SHMS->AddDetector(paero); - // Add calorimeter to SHMS apparatus + // 6. Add calorimeter to SHMS apparatus THcShower* pcal = new THcShower("cal", "Calorimeter"); SHMS->AddDetector(pcal); - + // --------------------------------------------------------------------------- + // B. Beamline + // // Add rastered beam apparatus THaApparatus* pbeam = new THcRasteredBeam("P.rb", "Rastered Beamline"); gHaApps->Add(pbeam); - auto trkEff = new hcana::TrackingEfficiency("P.trackEfficiency", "SHMS tracking Efficiency", "P.hod"); - gHaPhysics->Add(trkEff); - // Add physics modules - // Calculate reaction point + // --------------------------------------------------------------------------- + // C. Trigger + // + // Add trigger detector to trigger apparatus + THaApparatus* TRG = new THcTrigApp("T", "TRG"); + gHaApps->Add(TRG); + // TODO Add helicity detector to trigger apparatus + // THcHelicity* helicity = new THcHelicity("helicity","Helicity Detector"); + // TRG->AddDetector(helicity); + + // =========================================================================== + // Phyics and derived quantities + // + // 1. Calculate reaction point THaReactionPoint* prp = new THaReactionPoint("P.react", "SHMS reaction point", "P", "P.rb"); gHaPhysics->Add(prp); - // Calculate extended target corrections - THcExtTarCor* pext = new THcExtTarCor("P.extcor", "HMS extended target corrections", "P", "P.react"); + // 2. Calculate extended target corrections + THcExtTarCor* pext = + new THcExtTarCor("P.extcor", "HMS extended target corrections", "P", "P.react"); gHaPhysics->Add(pext); - // Calculate golden track quantites + // 3. Calculate golden track quantites THaGoldenTrack* pgtr = new THaGoldenTrack("P.gtr", "SHMS Golden Track", "P"); gHaPhysics->Add(pgtr); - // Calculate the hodoscope efficiencies + // 4. Calculate the hodoscope efficiencies THcHodoEff* peff = new THcHodoEff("phodeff", "SHMS hodo efficiency", "P.hod"); - gHaPhysics->Add(peff); + gHaPhysics->Add(peff); + // 5. Single arm kinematics + THcPrimaryKine* kin = new THcPrimaryKine("P.kin", "SHMS Single Arm Kinematics", "P", "P.rb"); + gHaPhysics->Add(kin); + // =========================================================================== + // Global Objects & Event Handlers + // // Add event handler for scaler events THcScalerEvtHandler* pscaler = new THcScalerEvtHandler("P", "Hall C scaler event type 1"); pscaler->AddEvtType(1); @@ -163,38 +174,6 @@ void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { pscaler->SetUseFirstEvent(kTRUE); gHaEvtHandlers->Add(pscaler); - - // ================================= - // Kinematics Modules - // ================================= - - // Add Physics Module to calculate primary (scattered electrons) beam kinematics - //THcPrimaryKine* hkin_primary = new THcPrimaryKine("H.kin.primary", "HMS Single Arm Kinematics", "H", "H.rb"); - //gHaPhysics->Add(hkin_primary); - // Add Physics Module to calculate secondary (scattered hadrons) beam kinematics - //THcSecondaryKine* pkin_secondary = new THcSecondaryKine("P.kin.secondary", "SHMS Single Arm Kinematics", "P", "H.kin.primary"); - //gHaPhysics->Add(pkin_secondary); - THcPrimaryKine* kin = new THcPrimaryKine("P.kin", "SHMS Single Arm Kinematics", "P", "P.rb"); - gHaPhysics->Add(kin); - - // ================================= - // Global Objects & Event Handlers - // ================================= - - // Add trigger apparatus - THaApparatus* TRG = new THcTrigApp("T", "TRG"); - gHaApps->Add(TRG); - // Add trigger detector to trigger apparatus - //THcTrigDet* coin = new THcTrigDet("coin", "Coincidence Trigger Information"); - // Suppress missing reference time warnings for these event types - //coin->SetEvtType(1); - //coin->AddEvtType(2); - //TRG->AddDetector(coin); - - // Add helicity detector to grigger apparatus - THcHelicity* helicity = new THcHelicity("helicity","Helicity Detector"); - TRG->AddDetector(helicity); - // Add event handler for prestart event 125. THcConfigEvtHandler* ev125 = new THcConfigEvtHandler("HC", "Config Event type 125"); gHaEvtHandlers->Add(ev125); @@ -202,98 +181,13 @@ void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { THaEpicsEvtHandler* hcepics = new THaEpicsEvtHandler("epics", "HC EPICS event type 180"); gHaEvtHandlers->Add(hcepics); - // Add coin physics module - //THcCoinTime* coinTime = new THcCoinTime("CTime", "Coincidende Time Determination", "P", "H", "T.coin"); - //gHaPhysics->Add(coinTime); - // ----------------------------------------------------------- - // Scandalizer + // Analyzer // ----------------------------------------------------------- // - hcana::Scandalizer* analyzer = new hcana::Scandalizer; - //analyzer->_skip_events = 100; + THcAnalyzer* analyzer = new THcAnalyzer; analyzer->SetCodaVersion(2); - //analyzer->EnableBenchmarks(true); - - // The following analyzes the first 2000 events (for pedestals, is required) - // then repeatedly skips 3000 events and processes 1000. - //auto pp0 = new hallc::scandalizer::SkipPeriodicAfterPedestal(); - //auto pp0 = new hallc::scandalizer::SkipAfterPedestal(); - //pp0->_analyzer = analyzer; - - //SimplePostProcess([&]() { return 0; }, - // [&](const THaEvData* evt) { - // static int counter = 0; - // if (evt->GetEvNum() > 2000) { - // if (counter == 0) { - // analyzer->_skip_events = 3000; - // counter = 1000; - // } else { - // counter--; - // } - // } - // return 0; - // }); - - //hallc::scandalizer::SpectrometerMonitor * pp1a = new hallc::scandalizer::SpectrometerMonitor(hhod,hcer,hdc); - //pp1a->_analyzer = analyzer; - //pp1a->_spectrometer_name = "HMS"; - - //hallc::scandalizer::SpectrometerMonitor * pp1 = new hallc::scandalizer::SpectrometerMonitor(phod,phgcer,pdc); - //pp1->_analyzer = analyzer; - - //hallc::scandalizer::SimplePostProcess* pp1 = new hallc::scandalizer::SimplePostProcess( - // [&](){ - // return 0; - // }, - // [&](const THaEvData* evt){ - // static int counter = 0; - // static double eff_num = 0.0000001; - // static double eff_den = 0.0; - // static int n_num = 0; - // static int n_den = 0; - // int shmsDC1Planes_nhits = 0; - // int shmsDC2Planes_nhits = 0; - // for (int ip = 0; ip < 6; ip++) { - // shmsDC1Planes_nhits += pdc->GetPlane(ip)->GetNHits(); - // } - // for (int ip = 6; ip < 12; ip++) { - // shmsDC2Planes_nhits += pdc->GetPlane(ip)->GetNHits(); - // } - // bool shms_DC_too_many_hits = (shmsDC1Planes_nhits > 8) || (shmsDC2Planes_nhits > 8); - // double beta = phod->GetBetaNotrk(); - // bool good_beta = beta > 0.4; - // bool shms_good_hodoscope = phod->fGoodScinHits; - // bool good_ntracks = (pdc->GetNTracks() > 0); - // bool good_hgc = phgcer->GetCerNPE() > 1; - // if ((good_beta && shms_good_hodoscope) && (!shms_DC_too_many_hits) && good_hgc) { - // eff_den = eff_den + 1.0; - // n_den++; - // if (good_ntracks) { - // eff_num = eff_num + 1.0; - // n_num++; - // } - // } - // if ((evt->GetEvNum() > 1200) && (counter > 1000)) { - // std::cout << " efficiency : " << eff_num / eff_den << "\n"; - // //std::cout << " Event : " << evt->GetEvNum() << " ( " << evt->GetEvType() << ")\n"; - // pv_list.Put("hcSHMSTrackingEff", eff_num/eff_den); - // pv_list.Put("hcSHMSTrackingEff:Unc",std::sqrt(double(n_num))/(n_num+n_den+0.0000001)); - // pv_list.Put("hcSHMSTrackingEff.LOW",0.95); - // pv_list.Put("hcSHMSTrackingEff.LOLO",0.93); - - // eff_num = 0.000000001; - // eff_den = 0.0; - // //analyzer->_skip_events = 300; - // counter = 0; - // } - // counter++; - // return 0; - // }); - - //analyzer->AddPostProcess(pp0); - //analyzer->AddPostProcess(pp1); - //analyzer->AddPostProcess(pp1a); + // analyzer->EnableBenchmarks(true); // A simple event class to be output to the resulting tree. // Creating your own descendant of THaEvent is one way of @@ -302,16 +196,17 @@ void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { // Define the run(s) that we want to analyze. // We just set up one, but this could be many. - THcRun* run = new THcRun( pathList, Form(RunFileNamePattern, RunNumber) ); + THcRun* run = new THcRun(pathList, Form(RunFileNamePattern, RunNumber)); // Set to read in Hall C run database parameters run->SetRunParamClass("THcRunParameters"); - + // Eventually need to learn to skip over, or properly analyze the pedestal events - run->SetEventRange(1, MaxEvent); // Physics Event number, does not include scaler or control events. + run->SetEventRange(1, + MaxEvent); // Physics Event number, does not include scaler or control events. run->SetNscan(1); run->SetDataRequired(0x7); - //run->Print(); + // run->Print(); // Define the analysis parameters TString ROOTFileName = Form(ROOTFileNamePattern, RunNumber, MaxEvent); @@ -327,18 +222,20 @@ void replay_production_shms(Int_t RunNumber = 7160, Int_t MaxEvent = 50000) { // Define output ROOT file analyzer->SetOutFile(ROOTFileName.Data()); // Define DEF-file+ - //analyzer->SetOdefFile("DEF-files/SHMS/PRODUCTION/pstackana_production_all.def"); + // analyzer->SetOdefFile("DEF-files/SHMS/PRODUCTION/pstackana_production_all.def"); analyzer->SetOdefFile("DEF-files/SHMS/PRODUCTION/pstackana_production.def"); // Define cuts file analyzer->SetCutFile("DEF-files/SHMS/PRODUCTION/CUTS/pstackana_production_cuts.def"); // optional // File to record accounting information for cuts - analyzer->SetSummaryFile(Form("REPORT_OUTPUT/SHMS/PRODUCTION/summary_all_production_%d_%d.report", RunNumber, MaxEvent)); // optional + analyzer->SetSummaryFile(Form("REPORT_OUTPUT/SHMS/PRODUCTION/summary_all_production_%d_%d.report", + RunNumber, MaxEvent)); // optional // Start the actual analysis. analyzer->Process(run); // Create report file from template - analyzer->PrintReport("TEMPLATES/SHMS/PRODUCTION/pstackana_production.template", - Form("REPORT_OUTPUT/SHMS/PRODUCTION/replay_shms_all_production_%d_%d.report", RunNumber, MaxEvent)); // optional - + analyzer->PrintReport( + "TEMPLATES/SHMS/PRODUCTION/pstackana_production.template", + Form("REPORT_OUTPUT/SHMS/PRODUCTION/replay_shms_all_production_%d_%d.report", RunNumber, + MaxEvent)); // optional delete analyzer; } diff --git a/run_full_shms b/run_full_shms index e8d77a827afef18021ef6c5b9b1d1de7930dff8c..2a448aed1e0d38b65634e901a32d673da303d46a 100755 --- a/run_full_shms +++ b/run_full_shms @@ -5,7 +5,7 @@ function print_the_help { echo "USAGE: $0 -r <run_number> -n <num> " echo " OPTIONS: " echo " -r,--run Required run number" - echo " -n,--n-events Required number of eventsrun number" + echo " -n,--n-events Optional number of events (default: all)" #echo " -o,--online-only Log online only" #echo " -a,--all Log all plots (online, detectors, physics)" #echo " -n,--no-log Do not submit any log entries" @@ -89,8 +89,8 @@ fi # exit #fi -source /group/c-pol-he3/software/setup.sh +#source /group/c-pol-he3/software/setup.sh -hcana -b -q "SCRIPTS/SHMS/replay_production_shms.cxx(${run_number},${n_events})" +hcana -b -q "SCRIPTS/SHMS/replay_production_shms.cxx+(${run_number},${n_events})"