All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
CRTMergePreProcessTrees.cxx File Reference
#include <TTree.h>
#include <TFile.h>
#include <map>
#include "./CRTPreProcessTree.h"
#include "./CRTTiming.h"

Go to the source code of this file.

Macros

#define CRTMergePreProcessTrees_CXX
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

#define CRTMergePreProcessTrees_CXX

Definition at line 2 of file CRTMergePreProcessTrees.cxx.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 22 of file CRTMergePreProcessTrees.cxx.

22  {
23 
24  cout << "Opening file for reading with name, '" << argv[1] << "'" << endl;
25 
26  cout << "Opening new file for writing with name, '" << argv[2] << "'" << endl;
27 
28  uint8_t fMac5;
29  bool fIsNoise;
30  uint8_t fMaxChan;
31  float fMaxPE;
32  float fTotPE;
33  float fPE[32];
34  uint8_t fNChanAbove;
35  bool fAbove[32];
36  bool fActive[32];
37  uint64_t fT0;
38  int fRegion;
39  int fLayer;
40  float fPollRate;
41  float fInstRate;
42 
43  TTree* fAnaTree = new TTree("anaTree","calibrated charge, trigger 'flag', and time ordered entries");
44 
45  fAnaTree->Branch("mac5", &fMac5, "mac5/b");
46  fAnaTree->Branch("pe", fPE, "pe[32]/F");
47  fAnaTree->Branch("active", fActive, "active[32]/O");
48  fAnaTree->Branch("maxChan", &fMaxChan, "maxChan/b");
49  fAnaTree->Branch("maxPE", &fMaxPE, "maxPE/F");
50  fAnaTree->Branch("totPE", &fTotPE, "totPE/F");
51  fAnaTree->Branch("nAbove", &fNChanAbove, "nAbove/b");
52  fAnaTree->Branch("above", fAbove, "above[32]/O");
53  fAnaTree->Branch("isNoise", &fIsNoise, "isNoise/O");
54  fAnaTree->Branch("region", &fRegion, "region/I");
55  fAnaTree->Branch("layer", &fLayer, "layer/I");
56  fAnaTree->Branch("t0", &fT0, "t0/l");
57  fAnaTree->Branch("pollRate", &fPollRate, "pollRate/F");
58  fAnaTree->Branch("instRate", &fInstRate, "instRate/F");
59 
60  TFile fin(argv[1],"READ");
61  TTree* intree = (TTree*)fin.FindObjectAny("anaTree");
63  icarus::crt::CRTTiming ct(cpt);
64 
65  const map<size_t,size_t>* sortedToRaw = ct.GetOrderedToRawMap();
66  std::cout << "done sorting " << sortedToRaw->size() << " entries" << std::endl;
67 
68 
69  TFile fout(argv[2],"RECREATE");
70 
71  std::cout << "filling new, sorted tree..." << std::endl;
72  const size_t nentries = cpt.GetNEntries();
73  for(size_t i=0; i<nentries; i++) {
74 
75  if(i%100000==0)
76  std::cout << 100.0*i/nentries << " % complete" << std::endl;
77 
78  cpt.Load(sortedToRaw->at(i));
79 
80  fMac5 = cpt.Mac5();
81  fIsNoise = cpt.IsNoise();
82  fMaxChan = cpt.MaxChan();
83  fMaxPE = cpt.MaxPE();
84  fTotPE = cpt.TotPE();
85  fNChanAbove = cpt.NChanAbove();
86  fT0 = cpt.T0();
87  fRegion = cpt.Region();
88  fLayer = cpt.Layer();
89  fPollRate = cpt.PollRate();
90  fInstRate = cpt.InstRate();
91 
92  for(size_t ch=0; ch<32; ch++){
93  fPE[ch] = cpt.PE(ch);
94  fAbove[ch] = cpt.Above(ch);
95  fActive[ch] = cpt.Active(ch);
96  }
97 
98  fAnaTree->Fill();
99  }
100  fin.Close();
101 
102  fAnaTree->Write();
103  fout.Close();
104 
105  return 0;
106 }
createEngine fT0
BEGIN_PROLOG could also be cout