// With source tests, we get about 5ns timing resolution within each 25ns clock period by only accepting photomultiplier triggers that occur within a 5ns acceptance window. By scanning this acceptance window, we can find the full pulse shape. To see this properly, we need to combine the results from 5 NTuple files. // The N-Tuples will already have been sorted with an appropriate script, which will make things simpler // While running, we need to keep track of the 4 trees separately // THIS SCRIPT SHOULD BE COMPILED BEFORE USE #include #include "TTree.h" #include "TFile.h" #include "TChain.h" void combine() { int num_files=5; TString fileName[num_files]; TString sensorName=""; // Specify the names of the files here (in order) fileName[0] = "Sort_NTuple_CNM3D_testpulse_newcable_phase00_10V_amp23_withFIR.root"; fileName[1] = "Sort_NTuple_CNM3D_testpulse_newcable_phase20_10V_amp23_withFIR.root"; fileName[2] = "Sort_NTuple_CNM3D_testpulse_newcable_phase40_10V_amp23_withFIR.root"; fileName[3] = "Sort_NTuple_CNM3D_testpulse_newcable_phase60_10V_amp23_withFIR.root"; fileName[4] = "Sort_NTuple_CNM3D_testpulse_newcable_phase80_10V_amp23_withFIR.root"; TString pathLCMSEvent; TString pathLCMSHit; TString pathClusterEvent; TString pathClusterHit; pathLCMSEvent = "LCMSEvent" + sensorName; // Put together the path pathLCMSHit = "LCMSHit" + sensorName; pathClusterEvent = "ClusterEvent" + sensorName; // Put together the path pathClusterHit = "ClusterHit" + sensorName; TString outFile = "_combinedData_CNM3D_testpulse_test.root"; TString LCMSEventFile = "LCMSEvent" + outFile; TString LCMSHitFile = "LCMSHit" + outFile; TString ClusterEventFile = "ClusterEvent" + outFile; TString ClusterHitFile = "ClusterHit" + outFile; // Need to add a chain for each tree TChain chainLCMSEvent(pathLCMSEvent); // name of the tree is the argument chainLCMSEvent.Add(fileName[0]); chainLCMSEvent.Add(fileName[1]); chainLCMSEvent.Add(fileName[2]); chainLCMSEvent.Add(fileName[3]); chainLCMSEvent.Add(fileName[4]); TChain chainLCMSHit(pathLCMSHit); // Name of the tree is the argument chainLCMSHit.Add(fileName[0]); chainLCMSHit.Add(fileName[1]); chainLCMSHit.Add(fileName[2]); chainLCMSHit.Add(fileName[3]); chainLCMSHit.Add(fileName[4]); TChain chainClusterEvent(pathClusterEvent); // Name of the tree is the argument chainClusterEvent.Add(fileName[0]); chainClusterEvent.Add(fileName[1]); chainClusterEvent.Add(fileName[2]); chainClusterEvent.Add(fileName[3]); chainClusterEvent.Add(fileName[4]); TChain chainClusterHit(pathClusterHit); // Name of the tree is the argument chainClusterHit.Add(fileName[0]); chainClusterHit.Add(fileName[1]); chainClusterHit.Add(fileName[2]); chainClusterHit.Add(fileName[3]); chainClusterHit.Add(fileName[4]); gDirectory->ls(); // Merge the chains in a new file. This is a pain!!! CanĀ“t get them into a single file!!! chainClusterEvent.Merge(ClusterEventFile); chainClusterHit.Merge(ClusterHitFile); chainLCMSEvent.Merge(LCMSEventFile); chainLCMSHit.Merge(LCMSHitFile); /* TFile a("ClusterEvent.root"); TFile c("LCMSEvent.root"); TFile d("LCMSHit.root"); TFile b("ClusterHit.root"); TFile output(outFile,"RECREATE"); TTree *treeClusterHit; TTree *treeLCMSEvent; TTree *treeLCMSHit; TTree *treeClusterEvent; treeClusterEvent = (TTree*)a.Get(pathClusterEvent); treeClusterHit = (TTree*)b.Get(pathClusterHit); treeLCMSEvent = (TTree*)c.Get(pathLCMSEvent); treeLCMSHit = (TTree*)d.Get(pathLCMSHit); treeLCMSHit->Write(); treeClusterEvent->Write(); treeClusterHit->Write(); treeLCMSEvent->Write(); */ }