macros.C
| 1 |
#define macros_cxx
|
|---|---|
| 2 |
#include "macros.h" |
| 3 |
#include <TH2.h> |
| 4 |
#include <TStyle.h> |
| 5 |
#include <TCanvas.h> |
| 6 |
|
| 7 |
void macros::Loop()
|
| 8 |
{
|
| 9 |
// In a ROOT session, you can do:
|
| 10 |
// Root > .L macros.C
|
| 11 |
// Root > macros t
|
| 12 |
// Root > t.GetEntry(12); // Fill t data members with entry number 12
|
| 13 |
// Root > t.Show(); // Show values of entry 12
|
| 14 |
// Root > t.Show(16); // Read and show values of entry 16
|
| 15 |
// Root > t.Loop(); // Loop on all entries
|
| 16 |
//
|
| 17 |
|
| 18 |
// This is the loop skeleton where:
|
| 19 |
// jentry is the global entry number in the chain
|
| 20 |
// ientry is the entry number in the current Tree
|
| 21 |
// Note that the argument to GetEntry must be:
|
| 22 |
// jentry for TChain::GetEntry
|
| 23 |
// ientry for TTree::GetEntry and TBranch::GetEntry
|
| 24 |
//
|
| 25 |
// To read only selected branches, Insert statements like:
|
| 26 |
// METHOD1:
|
| 27 |
// fChain->SetBranchStatus("*",0); // disable all branches
|
| 28 |
// fChain->SetBranchStatus("NeEvent_SQY_L[16]",1); // activate branchname
|
| 29 |
// fChain->SetBranchStatus("NeEvent_SQX_L[32]",1); // activate branchname
|
| 30 |
// METHOD2: replace line
|
| 31 |
// fChain->GetEntry(jentry); //read all branches
|
| 32 |
// NeEvent_SQY_L->GetEntry(ientry); //read only this branch
|
| 33 |
// if (fChain == 0) return;
|
| 34 |
|
| 35 |
TFile * fout= new TFile("positionSQ20mkm_thick_13.06.18_.root","recreate"); |
| 36 |
TTree * tout = new TTree("Position"," "); |
| 37 |
Double_t xa,ya,x20; |
| 38 |
tout->Branch("y_1mm",&ya,"y/d"); |
| 39 |
tout->Branch("x_1mm",&xa,"x/d"); |
| 40 |
tout->Branch("x_20mkm",&x20,"x20/d"); |
| 41 |
|
| 42 |
Long64_t nentries = fChain->GetEntriesFast(); |
| 43 |
|
| 44 |
Long64_t nbytes = 0, nb = 0; |
| 45 |
for (Long64_t jentry=0; jentry<nentries;jentry++) { |
| 46 |
Long64_t ientry = LoadTree(jentry); |
| 47 |
if (ientry < 0) break; |
| 48 |
nb = fChain->GetEntry(jentry); nbytes += nb; |
| 49 |
// if (Cut(ientry) < 0) continue;
|
| 50 |
|
| 51 |
for(int i=0;i<16;i++) |
| 52 |
{
|
| 53 |
if(NeEvent_SQY_L[i]>200 && NeEvent_SQY_L[i]<1500) {ya=(i+0.5)*58./16.-29.; } //length of thick detector is 58mm; 0.5 means we took center of stripe |
| 54 |
if (NeEvent_SQX_L[i]>200 && NeEvent_SQX_L[i]<1500) {xa=(i+0.5)*58./32-29.;} |
| 55 |
if (NeEvent_SQY_R[i]>200 && NeEvent_SQY_R[i]<1500) {x20=(i+0.5)*50./16.-29.+4.65625;} |
| 56 |
} // 15th stripe for xa corresponds to the 7th stripe x20, difference
|
| 57 |
15*58/32+58/64-50/32-7*50/16=4.65625mm |
| 58 |
|
| 59 |
|
| 60 |
for(int j=16;j<32;j++) |
| 61 |
{
|
| 62 |
if(NeEvent_SQX_L[j]>200 && NeEvent_SQX_L[j]<1500) {xa=(j+0.5)*58./32.-29.; } |
| 63 |
} |
| 64 |
tout->Fill(); |
| 65 |
} |
| 66 |
fout->cd(); |
| 67 |
tout->Write(); |
| 68 |
fout->Close(); |
| 69 |
} |
| 70 |
|