Commit b3290ea3 authored by Qiunan Zhang's avatar Qiunan Zhang
Browse files

Merge branch 'master' of https://git.cbm.gsi.de/computing/cbmroot

parents a0c6163f bb82dd46
---
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
#AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: false
#AlignConsecutiveMacros: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
#AllowAllArgumentsOnNextLine: true
#AllowAllConstructorInitializersOnNextLine: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
#AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
#AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
# Discuss
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: AfterColon
ColumnLimit: 80
#Discuss
BreakStringLiterals: true
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeBlocks: Preserve
# Implement ordering of include statements
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^("|<)Cbm'
Priority: 1
- Regex: '^("|<).*slice'
Priority: 2
- Regex: '^("|<)Fair'
Priority: 3
- Regex: '^("|<)Logger.h'
Priority: 3
- Regex: '^("|<)T'
Priority: 4
- Regex: '^("|<)Rt'
Priority: 4
- Regex: '^("|<)boost'
Priority: 5
- Regex: '^<.*[^\.h]>'
Priority: 6
- Regex: '^<.*>'
Priority: 7
- Regex: '.*'
Priority: 8
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
#Discuss Penalties
PenaltyBreakAssignment: 2
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
#SpaceAfterLogicalNot: true
SpaceAfterTemplateKeyword: false
......@@ -62,13 +129,20 @@ SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
TabWidth: 8
UseCRLF: false
UseTab: Never
...
......@@ -88,7 +88,7 @@ CodeFormatCheck:
- echo "export FAIRROOTPATH=/cvmfs/fairroot.gsi.de/fairroot/\${FAIRROOT_VERSION}_fairsoft-\${FAIRSOFT_VERSION}" >> env.sh
- echo "export BUILDDIR=$PWD/build" >> env.sh
- echo "export SOURCEDIR=$PWD" >> env.sh
- echo "export PATH=/cvmfs/fairroot.gsi.de/clang-format-8.0.1:\$SIMPATH/bin:$PATH:/cvmfs/it.gsi.de/compiler/llvm/6.0.1/bin/" >> env.sh
- echo "export PATH=/cvmfs/fairroot.gsi.de/clang-format-11.0.0/bin:\$SIMPATH/bin:$PATH" >> env.sh
- echo "export LABEL=format-check_MR-\${CI_MERGE_REQUEST_IID}" >> env.sh
- echo "export FAIRROOT_FORMAT_BASE=upstream/\${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" >> env.sh
- . ./env.sh && ctest -S cmake/scripts/checkformat.cmake -VV
......
......@@ -57,6 +57,7 @@ report/CbmLatexReportElement.cxx
utils/CbmUtils.cxx
utils/CbmGeometryUtils.cxx
utils/CbmMediaList.cxx
utils/CbmFileUtils.cxx
)
Set(LINKDEF CbmBaseLinkDef.h)
......
......@@ -73,4 +73,6 @@
// can not read the file with the CbmMediaList object. For other platforms there is no
// problem without the line. So generate the correct streamer info in any way.
#pragma link C++ class std::pair < TString, TString>;
#pragma link C++ function Cbm::File::IsRootFile( string );
#endif
#include "CbmFileUtils.h"
#include "FairLogger.h" // for LOG, info and error
#include "TArchiveFile.h" // for TArchiveFile
#include "TFile.h" // for TFile
#include "TObjArray.h"
#include <string> // for string, find, substr
#include <sys/stat.h> // for stcuct stat
namespace Cbm
{
namespace File
{
bool IsRootFile(std::string filename)
{
// Currently plain root files and root files stored in a zip file are supported.
// The destiction between the two is a "#" in the filename string which separates the
// name of the zip file from the name of the root file which is inside the zip file.
// In case the filename contains a hash (e.g. multi.zip#file.root) the hash
// separates the name of a zipfile (multi.zip) which contains the real root file
// (file.root).
// This nameing convention (e.g. multi.zip#file.root) is sed by ROOT.
// If a filename string contains a hash "#"
// split the string at the # in the name of the zipfile and
// the name of the contained root file.
std::string checkFilename {""};
std::string membername {""};
std::size_t found = filename.find("#");
if (found != std::string::npos) {
checkFilename = filename.substr(0, found);
membername = filename.substr(found + 1);
}
else {
checkFilename = filename;
}
bool wasfound = kFALSE;
// Check if the file exist
// In case of a root file contained in a zip archive check if the zip file
// exist
struct stat buffer;
if (stat(checkFilename.c_str(), &buffer) == 0) { wasfound = kTRUE; }
else {
wasfound = kFALSE;
LOG(error) << "Input File " << checkFilename << " not found";
}
// In case of a zip archive check if the archive contains the root file
if (membername.compare("") != 0) {
TFile* fzip = TFile::Open(checkFilename.c_str());
if (fzip->IsOpen()) {
TArchiveFile* archive = fzip->GetArchive();
if (archive) {
TObjArray* members = archive->GetMembers();
if (members->FindObject(membername.c_str()) == 0) {
LOG(error) << "File " << membername << " not found in zipfile " << checkFilename;
wasfound = kFALSE;
}
else {
LOG(info) << "File " << membername << " found in zipfile " << checkFilename;
wasfound = kTRUE;
}
}
else {
LOG(error) << "Zipfile " << checkFilename << " does not contain an archive";
wasfound = kFALSE;
}
fzip->Close();
delete fzip;
}
else {
LOG(error) << "Could not open zipfile " << checkFilename;
wasfound = kFALSE;
}
}
else {
TFile* rootfile = TFile::Open(checkFilename.c_str());
if (rootfile->IsOpen()) {
LOG(info) << "File " << checkFilename << " is a ROOT file.";
wasfound = kTRUE;
}
else {
LOG(error) << "File " << checkFilename << " is no ROOT file.";
wasfound = kFALSE;
}
rootfile->Close();
delete rootfile;
}
return wasfound;
}
} // namespace File
} // namespace Cbm
#ifndef CBMFILEUTILS_H_
#define CBMFILEUTILS_H_
#include <string> // for string
namespace Cbm
{
namespace File
{
/**
* \brief Check if a the file exist and is a root file
* \param[in] filename The filename of the file to be checked
* \value true if file is an existing root file, 0 in any other case
**/
bool IsRootFile(std::string filename);
} //namespace File
} // namespace Cbm
#endif /* CBMFILEUTILS_H_ */
......@@ -26,7 +26,7 @@ CbmTofDetectorId_v21a::CbmTofDetectorId_v21a()
if (i == 4) continue; // ignore side bit
modulemask |= (maskarray[i] << shiftarray[i]);
}
char prev = std::cout.fill('x');
char prev = std::cout.fill();
std::cout << "<I> V21a module mask 0x" << std::setfill('0') << std::setw(8)
<< std::right << std::hex << modulemask << std::setfill(prev)
<< std::dec << std::endl;
......
......@@ -135,12 +135,19 @@ void CbmMuchGeoScheme::Init(TObjArray* stations, Int_t flag) {
// -------------------------------------------------------------------------
void CbmMuchGeoScheme::Init(TString digiFileName, Int_t flag) {
TFile* oldfile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* file = new TFile(digiFileName);
TObjArray* stations = (TObjArray*) file->Get("stations");
file->Close();
file->Delete();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
Init(stations, flag);
}
// -------------------------------------------------------------------------
......
......@@ -230,13 +230,18 @@ void CbmMuchSegmentAuto::FinishTask() {
printf("Station%i segmented\n", i + 1);
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// Save parameters
TFile* oldfile = gFile;
TFile* f = new TFile(fDigiFileName, "RECREATE");
fStations->Write("stations", 1);
f->Close();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
DrawSegmentation();
......
......@@ -261,13 +261,18 @@ void CbmMuchSegmentManual::SegmentMuch() {
printf("Station %i segmented\n", iStation + 1);
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// Save parameters
TFile* oldfile = gFile;
TFile* f = new TFile(fDigiFileName, "RECREATE");
fStations->Write("stations", 1);
f->Close();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
// Draw colored stations
DrawSegmentation();
......
......@@ -144,13 +144,18 @@ void CbmMuchSegmentSector::SegmentMuch() {
printf("Station %i segmented\n", iStation + 1);
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// Save parameters
TFile* oldfile = gFile;
TFile* f = new TFile(fDigiFileName, "RECREATE");
fStations->Write("stations", 1);
f->Close();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
DrawSegmentation();
}
......
......@@ -182,16 +182,25 @@ void CbmBsField::CalculateMapFromBs(Int_t pNx, Int_t pNy, Int_t pNz) {
void CbmBsField::writeBsRootfile(const char* name) // Write Field Splined
{
TFile* oldfile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* f = new TFile(name, "RECREATE");
this->Write();
f->Close();
if (oldfile) oldfile->cd();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
}
void CbmBsField::readBsRootfile(const char* name) // Read Field Splined
{
TFile* oldfile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* f = new TFile(name, "READ");
if (f->IsZombie()) {
cout << "-E- CbmBsField::readBsRootfile: can not read from file: " << endl;
......@@ -219,7 +228,10 @@ void CbmBsField::readBsRootfile(const char* name) // Read Field Splined
fZ = new TArrayF(*fnew->GetZ());
f->Close();
if (oldfile) oldfile->cd();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
UX1 = fX->GetArray();
UX2 = fY->GetArray();
......
......@@ -536,11 +536,18 @@ void CbmFieldMap::WriteAsciiFile(const char* fileName) {
void CbmFieldMap::WriteRootFile(const char* fileName, const char* mapName) {
CbmFieldMapData* data = new CbmFieldMapData(mapName, *this);
TFile* oldFile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* file = new TFile(fileName, "RECREATE");
data->Write();
file->Close();
if (oldFile) oldFile->cd();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
}
// ------------------------------------------------------------------------
......@@ -696,9 +703,9 @@ void CbmFieldMap::ReadAsciiFile(const char* fileName) {
// ------------- Read field map from ROOT file (private) ---------------
void CbmFieldMap::ReadRootFile(const char* fileName, const char* mapName) {
// Store gFile pointer
TFile* oldFile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// Open root file
LOG(info) << "CbmFieldMap: Reading field map from ROOT file " << fileName;
......@@ -723,7 +730,10 @@ void CbmFieldMap::ReadRootFile(const char* fileName, const char* mapName) {
// Close the root file and delete the data object
file->Close();
delete data;
if (oldFile) oldFile->cd();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
}
// ------------------------------------------------------------------------
......
......@@ -265,8 +265,10 @@ void CbmFieldMapDistorted::SetFromParent(FairField* field) {
// ----------- Read Distortion Formulas from Distortion File ------------------------------------------
void CbmFieldMapDistorted::ReadDistortionInformation(const char* filename) {
TFile* filesave = gFile;
gFile = 0;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
if (filename) {
if (strlen(filename)) { fDistortionFilename = filename; }
}
......@@ -299,13 +301,16 @@ void CbmFieldMapDistorted::ReadDistortionInformation(const char* filename) {
}
}
}
gFile = filesave;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
}
// ----------- Write Distortion Formulas to Distortion File ------------------------------------------
void CbmFieldMapDistorted::WriteDistortionInformation(const char* filename) {
TFile* filesave = gFile;
gFile = 0;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
if (filename) {
if (strlen(filename)) { fDistortionFilename = filename; }
......@@ -336,7 +341,9 @@ void CbmFieldMapDistorted::WriteDistortionInformation(const char* filename) {
}
}
}
gFile = filesave;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
}
// ---------------Getter and Setter for Distortion Formulas------------------------------
......
......@@ -29,7 +29,7 @@ ExternalProject_Add(ANALYSISTREEQA
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
-DCMAKE_CXX_STANDARD=11
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DROOTSYS=${SIMPATH}
-DBOOST_ROOT=${SIMPATH}
-DBoost_NO_BOOST_CMAKE=ON
......
set(PARAMETER_VERSION 884ac67bbc782e6862fccdeb413f8b11b83124ba)
set(PARAMETER_VERSION 68f0b16c6edace4faaa09f460682173772081976)
set(PARAMETER_SRC_URL "https://git.cbm.gsi.de/CbmSoft/cbmroot_parameter.git")
......
......@@ -130,6 +130,9 @@ Set(SRCS
tasks/CbmMcbmCheckTimingAlgo.cxx
tasks/CbmMcbmCheckTimingTask.cxx
tasks/CbmMcbmSpillFindAlgo.cxx
tasks/CbmMcbmSpillFindTask.cxx
)
If(_UINT8_T_EXIST)
......
......@@ -77,4 +77,7 @@
#pragma link C++ class CbmMcbmCheckTimingAlgo + ;
#pragma link C++ class CbmMcbmCheckTimingTask + ;
#pragma link C++ class CbmMcbmSpillFindAlgo + ;
#pragma link C++ class CbmMcbmSpillFindTask + ;
#endif
......@@ -117,6 +117,73 @@ Bool_t CbmMcbm2018Source::Init() {
fTimeSliceMetaDataArray,
fbWriteOutput);
/// Single spill or spills range unpacking
/// => Obtain the start and stop TS indices for the TS loop from user supplied vectors
/// => Three possibilities linked to output of CbmMcbmSpillFindAlgo,
/// choice controlled by fuFlagSpillStart
/// - Beginning of the spill break
/// - Middle of the spill break
/// - End of the spill break
if (0 <= fiUnpSpillIdxStart) {
switch (fuFlagSpillStart) {
case 0: {
/// 0 = Break begin
if (fvuSpillBreakBegTs.size() - 1 <= fiUnpSpillIdxStop) {
LOG(warning) << "Chosen last spill index larger than spills contained in chosen spill start vector: "
<< fiUnpSpillIdxStop << " VS " << fvuSpillBreakBegTs.size() - 1;
if (fiUnpSpillIdxStart < fvuSpillBreakBegTs.size() - 1) {
fiUnpSpillIdxStop = fvuSpillBreakBegTs.size() - 2;
LOG(warning) << "Using last possible spill instead as final one";
} // if( fiUnpSpillIdxStart < fvuSpillBreakBegTs.size() - 1 )
else
LOG(fatal) << "Start index also too large, exiting";
} // if( fvuSpillBreakBegTs.size() - 1 <= fiUnpSpillIdxStop )
fuSpillBegTs = fvuSpillBreakBegTs[fiUnpSpillIdxStart]; //!
fuSpillEndTs = fvuSpillBreakBegTs[fiUnpSpillIdxStop + 1]; //!
break;
}
case 1: {
/// 1 = Break middle
if (fvuSpillBreakMidTs.size() - 1 <= fiUnpSpillIdxStop) {
LOG(warning) << "Chosen last spill index larger than spills contained in chosen spill start vector: "
<< fiUnpSpillIdxStop << " VS " << fvuSpillBreakMidTs.size() - 1;
if (fiUnpSpillIdxStart < fvuSpillBreakMidTs.size() - 1) {
fiUnpSpillIdxStop = fvuSpillBreakMidTs.size() - 2;
LOG(warning) << "Using last possible spill instead as final one";
} // if( fiUnpSpillIdxStart < fvuSpillBreakMidTs.size() - 1 )
else
LOG(fatal) << "Start index also too large, exiting";
} // if( fvuSpillBreakMidTs.size() - 1 <= fiUnpSpillIdxStop )
fuSpillBegTs = fvuSpillBreakMidTs[fiUnpSpillIdxStart]; //!
fuSpillEndTs = fvuSpillBreakMidTs[fiUnpSpillIdxStop + 1]; //!
break;
}