Skip to content

Commit 81fea66

Browse files
committed
compiled version
1 parent b160a6a commit 81fea66

File tree

4 files changed

+268
-0
lines changed

4 files changed

+268
-0
lines changed

Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
CXX = $(shell root-config --cxx)
2+
LD = $(shell root-config --ld)
3+
4+
INC = $(shell pwd)
5+
6+
OS_NAME:=$(shell uname -s | tr A-Z a-z)
7+
ifeq ($(OS_NAME),darwin)
8+
STDINCDIR := -I/opt/local/include
9+
STDLIBDIR := -L/opt/local/lib
10+
else
11+
STDINCDIR :=-I/afs/cern.ch/work/c/cpena/scratch_DM/CMSSW_5_2_3/src/UserCode/CPena/src/DarkMatter/include
12+
STDLIBDIR :=
13+
endif
14+
15+
CPPFLAGS := -Wl,--no-as-needed $(shell root-config --cflags) -I$(INC)/include
16+
LDFLAGS := $(shell root-config --glibs) $(STDLIBDIR)
17+
18+
CPPFLAGS += -g
19+
20+
TARGET = Spec
21+
22+
SRC = test.cc outTree.C
23+
24+
#TARGET = bkg_pre_1mu
25+
#SRC = bkg_pre_1mu.cc src/DM_1DRatio.cc src/DM_2DRatio.cc src/DM_Base.cc
26+
27+
OBJ = $(SRC:.cc=.o)
28+
29+
all : $(TARGET)
30+
31+
$(TARGET) : $(OBJ)
32+
$(LD) $(CPPFLAGS) -o $(TARGET) $(OBJ) $(LDFLAGS)
33+
@echo $@
34+
@echo $<
35+
@echo $^
36+
37+
%.o : %.cc
38+
$(CXX) $(CPPFLAGS) -o $@ -c $<
39+
@echo $@
40+
@echo $<
41+
clean :
42+
rm -f *.o src/*.o $(TARGET) *~
43+

outTree.C

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#define outTree_cxx
2+
#include "outTree.h"
3+
#include <TH2.h>
4+
#include "TH1F.h"
5+
#include <TStyle.h>
6+
#include <TCanvas.h>
7+
#include <iostream>
8+
void outTree::Loop()
9+
{
10+
// In a ROOT session, you can do:
11+
// Root > .L outTree.C
12+
// Root > outTree t
13+
// Root > t.GetEntry(12); // Fill t data members with entry number 12
14+
// Root > t.Show(); // Show values of entry 12
15+
// Root > t.Show(16); // Read and show values of entry 16
16+
// Root > t.Loop(); // Loop on all entries
17+
//
18+
19+
// This is the loop skeleton where:
20+
// jentry is the global entry number in the chain
21+
// ientry is the entry number in the current Tree
22+
// Note that the argument to GetEntry must be:
23+
// jentry for TChain::GetEntry
24+
// ientry for TTree::GetEntry and TBranch::GetEntry
25+
//
26+
// To read only selected branches, Insert statements like:
27+
// METHOD1:
28+
// fChain->SetBranchStatus("*",0); // disable all branches
29+
// fChain->SetBranchStatus("branchname",1); // activate branchname
30+
// METHOD2: replace line
31+
// fChain->GetEntry(jentry); //read all branches
32+
//by b_branchname->GetEntry(ientry); //read only this branch
33+
if (fChain == 0) return;
34+
35+
TH1F* h = new TH1F("h", "muon spectrum", 1000, .0, .5);
36+
TH1F* h1 = new TH1F("h1", "Pulse Output1", 2499, -2.68000004411e-08, 2.31600001399e-08);
37+
TH1F* h2 = new TH1F("h2", "Pulse Output2", 2499, -2.68000004411e-08, 2.31600001399e-08);
38+
TH1F* h3 = new TH1F("h3", "Pulse Output3", 2499, -2.68000004411e-08, 2.31600001399e-08);
39+
float min2 = 1.0;
40+
41+
Long64_t nentries = fChain->GetEntriesFast();
42+
43+
Long64_t nbytes = 0, nb = 0;
44+
for (Long64_t jentry=0; jentry<nentries;jentry++) {
45+
Long64_t ientry = LoadTree(jentry);
46+
if (ientry < 0) break;
47+
nb = fChain->GetEntry(jentry); nbytes += nb;
48+
// if (Cut(ientry) < 0) continue;
49+
//std::cout << "entry: " << jentry << std::endl;
50+
51+
float min = 1.0;
52+
min2 = 1.0;
53+
int size = Time->size();
54+
//std::cout << "vector size: " << Amp->size() << " Time: " << Time->at(0) << " " << Time->at(1) << " " << Time->at(2) << " " << Time->at(size-1) << std::endl;
55+
//std::cout << "time stamp: " << ptime << std::endl;
56+
for(int j = 0; j < Amp->size(); j++){
57+
if(jentry = 1)h1->Fill(Time->at(j),Amp->at(j));
58+
if(jentry = 109)h2->Fill(Time->at(j),Amp->at(j));
59+
if(jentry = 267)h3->Fill(Time->at(j),Amp->at(j));
60+
if(Amp->at(j) < min2){
61+
min2 = Amp->at(j);
62+
}
63+
}
64+
65+
h->Fill(TMath::Abs(min2));
66+
}
67+
68+
h1->Draw();
69+
TFile* f1 = new TFile("test.root","RECREATE");
70+
h->Write();
71+
h1->Write();
72+
h2->Write();
73+
h3->Write();
74+
f1->Close();
75+
76+
}

outTree.h

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
//////////////////////////////////////////////////////////
2+
// This class has been automatically generated on
3+
// Fri Aug 9 14:57:01 2013 by ROOT version 5.34/09
4+
// from TTree outTree/outTree
5+
// found on file: /media/data/cmorgoth/scope_data/NoCrystalData/NoCrystalData.root
6+
//////////////////////////////////////////////////////////
7+
8+
#ifndef outTree_h
9+
#define outTree_h
10+
11+
#include <TROOT.h>
12+
#include <TChain.h>
13+
#include <TFile.h>
14+
15+
// Header file for the classes stored in the TTree if any.
16+
#include <vector>
17+
18+
// Fixed size dimensions of array or collections stored in the TTree if any.
19+
20+
class outTree {
21+
public :
22+
TTree *fChain; //!pointer to the analyzed TTree or TChain
23+
Int_t fCurrent; //!current Tree number in a TChain
24+
25+
// Declaration of leaf types
26+
Double_t ptime;
27+
std::vector<float> *Amp;
28+
std::vector<float> *Time;
29+
30+
// List of branches
31+
TBranch *b_ptime; //!
32+
TBranch *b_Amp; //!
33+
TBranch *b_Time; //!
34+
35+
outTree(TTree *tree=0);
36+
virtual ~outTree();
37+
virtual Int_t Cut(Long64_t entry);
38+
virtual Int_t GetEntry(Long64_t entry);
39+
virtual Long64_t LoadTree(Long64_t entry);
40+
virtual void Init(TTree *tree);
41+
virtual void Loop();
42+
virtual Bool_t Notify();
43+
virtual void Show(Long64_t entry = -1);
44+
};
45+
46+
#endif
47+
48+
#ifdef outTree_cxx
49+
outTree::outTree(TTree *tree) : fChain(0)
50+
{
51+
// if parameter tree is not specified (or zero), connect the file
52+
// used to generate this class and read the Tree.
53+
if (tree == 0) {
54+
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/media/data/cmorgoth/scope_data/NoCrystalData/NoCrystalData.root");
55+
if (!f || !f->IsOpen()) {
56+
f = new TFile("/media/data/cmorgoth/scope_data/NoCrystalData/NoCrystalData.root");
57+
}
58+
f->GetObject("outTree",tree);
59+
60+
}
61+
Init(tree);
62+
}
63+
64+
outTree::~outTree()
65+
{
66+
if (!fChain) return;
67+
delete fChain->GetCurrentFile();
68+
}
69+
70+
Int_t outTree::GetEntry(Long64_t entry)
71+
{
72+
// Read contents of entry.
73+
if (!fChain) return 0;
74+
return fChain->GetEntry(entry);
75+
}
76+
Long64_t outTree::LoadTree(Long64_t entry)
77+
{
78+
// Set the environment to read one entry
79+
if (!fChain) return -5;
80+
Long64_t centry = fChain->LoadTree(entry);
81+
if (centry < 0) return centry;
82+
if (fChain->GetTreeNumber() != fCurrent) {
83+
fCurrent = fChain->GetTreeNumber();
84+
Notify();
85+
}
86+
return centry;
87+
}
88+
89+
void outTree::Init(TTree *tree)
90+
{
91+
// The Init() function is called when the selector needs to initialize
92+
// a new tree or chain. Typically here the branch addresses and branch
93+
// pointers of the tree will be set.
94+
// It is normally not necessary to make changes to the generated
95+
// code, but the routine can be extended by the user if needed.
96+
// Init() will be called many times when running on PROOF
97+
// (once per file to be processed).
98+
99+
// Set object pointer
100+
Amp = 0;
101+
Time = 0;
102+
// Set branch addresses and branch pointers
103+
if (!tree) return;
104+
fChain = tree;
105+
fCurrent = -1;
106+
fChain->SetMakeClass(1);
107+
108+
fChain->SetBranchAddress("ptime", &ptime, &b_ptime);
109+
fChain->SetBranchAddress("Amp", &Amp, &b_Amp);
110+
fChain->SetBranchAddress("Time", &Time, &b_Time);
111+
Notify();
112+
}
113+
114+
Bool_t outTree::Notify()
115+
{
116+
// The Notify() function is called when a new file is opened. This
117+
// can be either for a new TTree in a TChain or when when a new TTree
118+
// is started when using PROOF. It is normally not necessary to make changes
119+
// to the generated code, but the routine can be extended by the
120+
// user if needed. The return value is currently not used.
121+
122+
return kTRUE;
123+
}
124+
125+
void outTree::Show(Long64_t entry)
126+
{
127+
// Print contents of entry.
128+
// If entry is not specified, print current entry
129+
if (!fChain) return;
130+
fChain->Show(entry);
131+
}
132+
Int_t outTree::Cut(Long64_t entry)
133+
{
134+
// This function may be called from Loop.
135+
// returns 1 if entry is accepted.
136+
// returns -1 otherwise.
137+
return 1;
138+
}
139+
#endif // #ifdef outTree_cxx

test.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "outTree.h"
2+
#include <iostream>
3+
4+
int main(){
5+
6+
outTree* out = new outTree();
7+
out->Loop();
8+
9+
return 0;
10+
}

0 commit comments

Comments
 (0)