Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SectorMap_Display.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SectorMap_Display.C
1 //sPHENIX Sector Mapping of modules R1 R2 and R3 May 19, 2023
2 //Jennifer James
3 #include "TString.h"
4 #include "TFile.h"
5 #include "TSystem.h"
6 #include "TTree.h"
7 #include "TH1F.h"
8 #include "TH3I.h"
9 #include "TCanvas.h"
10 #include "TNtuple.h"
11 #include <iostream>
12 
13 // forward declaration
14 void Ana( TNtuple*, TNtuple*, TNtuple*, char[2], int, double tot[24], double dead[24], int );
15 
17 {
18 
19  char name[100];
20  int run_num;
21 
22  cout << "Input run number: ";
23  cin >> run_num;
24 
25  //string runNumber = "pedestal-00010616";
26 
27  const char* run_str[24] = { "00", "01", "02", "03" ,"04", "05", "06", "07", "08", "09", "10" , "11", "12" , "13" , "14", "15" , "16" , "17", "18" , "19", "20", "21" , "22", "23" };
28  double tot[24] = {0};
29  double dead[24] = {0};
30 
31  double tot_ult[24]={0};
32  double dead_ult[24]={0};
33 
34  sprintf(name, "pedestal-%d-outfile.root", run_num);
35 
36  //TFile h_outfile10305("pedestal-10616-outfile.root", "RECREATE");
37  TFile h_outfile10305(name, "RECREATE");
38  TNtuple *h_Alive=new TNtuple("h_Alive","Location Tntuple Cuts","chan_id:fee_id:module_id:pedMean:pedStdi:sec_id");
39  TNtuple *h_AliveTot=new TNtuple("h_AliveTot","Location Tntuple No Cuts","chan_id:fee_id:module_id:pedMean:pedStdi:sec_id");
40  TNtuple *h_AliveNoise=new TNtuple("h_AliveNoise","Location Tntuple Cuts","chan_id:fee_id:module_id:pedMean:pedStdi:sec_id:noise");
41 
42  for( int i = 0; i < 24; i++ )
43  {
44  char run[2]; //define character string
45  std::sprintf(run,run_str[i]); //print run_str values indexed at i<72
46 
47  Ana( h_Alive, h_AliveTot,h_AliveNoise, run, run_num, tot, dead, i); //create Ana function
48 
49  tot_ult[i] += tot[i]; //find total channels
50  dead_ult[i] += dead[i]; //find dead channels
51  }
52 
53  h_outfile10305.cd();
54  h_Alive->Write();
55  h_AliveTot->Write();
56  h_outfile10305.Close();
57 
58  }
59 
60 // Define Ana function
61 
62 void Ana(TNtuple *Alive, TNtuple *AliveTot, TNtuple *AliveNoise, char run[2] = "11", int runNumber = 00000, double tot[24]={0}, double dead[24]={0}, int j = 0)
63 { // Ana starts
64 
65  //const TString filename2( Form( "/sphenix/u/llegnosky/Livechan_Pedestals_Noise/outputfile_TPC_ebdc%s_pedestal-00010616.root", run) );
66  const TString filename2( Form( "/sphenix/u/llegnosky/Livechan_Pedestals_Noise/run_%d/outputfile_TPC_ebdc%s_pedestal-000%d.root", runNumber,run,runNumber) );
67 
68  TFile* infile2 = TFile::Open(filename2);
69 
70  if(!infile2) return;
71 
72  TTree *treesd;
73  treesd = (TTree*) infile2->Get("outputTree");
74 
75  Int_t isAlive, chan, fee, module, slot;
76  Float_t pedMean, pedStdi;
77 
78  treesd->SetBranchAddress("isAlive",&isAlive);
79  treesd->SetBranchAddress("chan",&chan);
80  treesd->SetBranchAddress("fee",&fee);
81  treesd->SetBranchAddress("module",&module);
82  treesd->SetBranchAddress("slot", &slot);
83  treesd->SetBranchAddress("pedMean",&pedMean);
84  treesd->SetBranchAddress("pedStdi",&pedStdi);
85 
86  std::cout << "sector = "<< run <<std::endl;
87 
88  UInt_t nEntries = treesd->GetEntries();
90  float sec = std::stof(fs);
91 
92  std::cout << "sector from char = " << sec << std::endl;
93 
94  // defining a cut of the mean and standard deviation
95  for (int i=0;i<nEntries;i++){
96  treesd->GetEntry(i);
97 
98  double pedestal = pedMean;
99  double noise = pedStdi;
100 
101  AliveTot->Fill(1.0*chan,1.0*fee,1.0*module,pedMean,pedStdi,1.0*sec);
102 
103  if (isAlive == 1){
104  Alive->Fill(1.0*chan,1.0*fee,1.0*module,pedMean, pedStdi, 1.0*sec);
105  }
106  }
107 }