#define macros_cxx #include "macros.h" #include #include #include void macros::Loop() { // In a ROOT session, you can do: // Root > .L macros.C // Root > macros t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("NeEvent_SQY_L[16]",1); // activate branchname // fChain->SetBranchStatus("NeEvent_SQX_L[32]",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches // NeEvent_SQY_L->GetEntry(ientry); //read only this branch // if (fChain == 0) return; TFile * fout= new TFile("positionSQ20mkm_thick_13.06.18_.root","recreate"); TTree * tout = new TTree("Position"," "); Double_t xa,ya,x20; tout->Branch("y_1mm",&ya,"y/d"); tout->Branch("x_1mm",&xa,"x/d"); tout->Branch("x_20mkm",&x20,"x20/d"); Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; for(int i=0;i<16;i++) { 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 if (NeEvent_SQX_L[i]>200 && NeEvent_SQX_L[i]<1500) {xa=(i+0.5)*58./32-29.;} if (NeEvent_SQY_R[i]>200 && NeEvent_SQY_R[i]<1500) {x20=(i+0.5)*50./16.-29.+4.65625;} } // 15th stripe for xa corresponds to the 7th stripe x20, difference 15*58/32+58/64-50/32-7*50/16=4.65625mm for(int j=16;j<32;j++) { if(NeEvent_SQX_L[j]>200 && NeEvent_SQX_L[j]<1500) {xa=(j+0.5)*58./32.-29.; } } tout->Fill(); } fout->cd(); tout->Write(); fout->Close(); }