LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
AssembleSingleFile.C File Reference

Go to the source code of this file.

Functions

TChain * CreateChainFromList_opt (std::string ListFileName, std::string ChainName, std::string BaseDirectory, bool DoCheck=false)
 
void MakeCombinedFile (std::string FileList, std::string BaseDirectory, std::string OutputName)
 
void AssembleSingleFile (std::string FileList, std::string BaseDirectory, std::string OutputName)
 

Function Documentation

void AssembleSingleFile ( std::string  FileList,
std::string  BaseDirectory,
std::string  OutputName 
)

Definition at line 7 of file AssembleSingleFile.C.

References CreateChainFromList_opt(), and f.

8 {
9 
10  TFile* f = TFile::Open(OutputName.c_str(), "RECREATE");
11  TChain* ch = CreateChainFromList_opt(
12  FileList.c_str(), BaseDirectory.c_str(), "pmtresponse/PhotonLibraryData", false);
13 
14  Int_t Voxel, OpChannel;
15  Float_t Visibility;
16  ch->SetBranchAddress("Voxel", &Voxel);
17  ch->SetBranchAddress("OpChannel", &OpChannel);
18  ch->SetBranchAddress("Visibility", &Visibility);
19 
20  TTree* tt = new TTree("PhotonLibraryData", "PhotonLibraryData");
21  tt->Branch("Voxel", &Voxel, "Voxel/I");
22  tt->Branch("OpChannel", &OpChannel, "OpChannel/I");
23  tt->Branch("Visibility", &Visibility, "Visibility/F");
24 
25  for (int i = 0; i != ch->GetEntries(); ++i) {
26  ch->GetEntry(i);
27  tt->Fill();
28  }
29 
30  f->Write();
31  f->Close();
32 }
TFile f
Definition: plotHisto.C:6
Definition: type_traits.h:61
TChain * CreateChainFromList_opt(std::string ListFileName, std::string ChainName, std::string BaseDirectory, bool DoCheck=false)
TChain * CreateChainFromList_opt ( std::string  ListFileName,
std::string  ChainName,
std::string  BaseDirectory,
bool  DoCheck = false 
)

Definition at line 34 of file AssembleSingleFile.C.

References f.

Referenced by AssembleSingleFile().

38 {
39  std::ifstream InputFile(ListFileName.c_str());
40  std::string FileName;
41 
42  TChain* TheChain = new TChain(ChainName.c_str());
43  if (!DoCheck) {
44  while (getline(InputFile, FileName)) {
45  FileName = BaseDirectory + FileName;
46  std::cout << FileName.c_str() << std::endl;
47  TheChain->Add(FileName.c_str());
48  }
49  }
50  else {
51  while (getline(InputFile, FileName)) {
52  FileName = BaseDirectory + FileName;
53  TFile* f = TFile::Open(FileName.c_str());
54  if (f->Get(ChainName.c_str())) {
55  std::cout << FileName.c_str() << std::endl;
56  TheChain->Add(FileName.c_str());
57  }
58  else
59  std::cout << "Chain " << ChainName << " not found in file " << FileName << std::endl;
60  }
61  }
62  return TheChain;
63 }
TFile f
Definition: plotHisto.C:6
void MakeCombinedFile ( std::string  FileList,
std::string  BaseDirectory,
std::string  OutputName 
)