#include #include #include #include "TTree.h" #include "TBranch.h" #include "TFile.h" #include "TTreeReaderValue.h" #include "TTreeReader.h" #include "TString.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TApplication.h" #include "TCanvas.h" #include "TPad.h" #include "TBranch.h" #include "TCut.h" #include "TH1D.h" #include "TH2D.h" #include "TMultiGraph.h" #include "TROOT.h" void Ibeam_chain_peak_filelist_graph() { TString runlistFileName = "file_names.txt"; ifstream runlistFile(runlistFileName.Data()); //cout << runlistFileName.Data() << endl; if (!runlistFile) { cout << "No run list file found!" << endl; exit(1); } //tempo / corrente vector used for global graph vector tempo; vector corrente; vector campo; vector corrente_int; vector integrale; vector corrente_tot; vector Mib; Float_t offset = 0; TCanvas *c1 = new TCanvas("c1", "Graph"); c1->Divide(1,3); TMultiGraph *mg = new TMultiGraph(); //mg->SetTitle("I_TES vs time"); while(!runlistFile.eof()) { //loop over input file //open current file TString fileName; runlistFile >> fileName; if(fileName!=""){ cout << "Input file: " << fileName << endl; TFile *myFile = TFile::Open(fileName); //TFile* file = new TFile("2023-06-12_run_tot.root"); TTree* run = (TTree*) myFile->Get("run"); //Define TreeReader for current file TTreeReader myReader("run", myFile); TTreeReaderValue time(myReader, "time"); TTreeReaderValue I_TES(myReader, "I_TES"); TTreeReaderValue I_TES_int(myReader, "I_TES_int"); TTreeReaderValue field(myReader, "field"); TTreeReaderValue I_discharge_r(myReader, "I_discharge_r"); TTreeReaderValue I_filament_r(myReader, "I_filament_r"); TTreeReaderValue I_FC_Mib(myReader, "I_FC_Mib"); while(myReader.Next()) { float TES = *I_TES; float FC_MiB = *I_FC_Mib; float sum = TES + FC_MiB; if(sum > 50E-9){ continue; } corrente_tot.push_back(sum); tempo.push_back(*time); corrente.push_back(*I_TES); corrente_int.push_back(*I_TES_int); Mib.push_back(*I_FC_Mib); } //cout << tempo.size() << endl; //cout << corrente.size() << endl; // if (integrale > 10E-7){ // cout << i << " " << integrale << endl; // } /*for(int i =8800; i <9000; i++){ cout << corrente[i] << endl; }*/ float value = 0; for (int i = 0; i < corrente_tot.size(); i++) { value += (tempo[i+1] - tempo[i]) * corrente_tot[i]; //cout << value << endl; integrale.push_back(value); //corrente_tot[i] = corrente_tot[i]*10000; } //cout << corrente_tot[i] << endl; //cout << corrente_tot.size() << endl; /*cout << tempo[i] << endl; cout << corrente[i] << endl; */ //cout << tempo[i] << " " << tempo[i+1] - tempo[i] << " " << corrente[i] << " " << integrale[i] << endl; // cout << corrente[i] << endl; // cout << corrente[8837] << endl; //cout << corrente_int.size()<< endl; TGraph *g1 = new TGraph(tempo.size(), &tempo[0], &corrente[0]); g1->SetMarkerColor(kBlue); //g1->SetMarkerStyle(21); //g1->SetMarkerSize(0.5); TGraph *g2 = new TGraph(tempo.size(), &tempo[0], &corrente_tot[0]); g2->SetMarkerColor(kRed); //g2->SetMarkerStyle(22); //g2->SetMarkerSize(0.5); TGraph *g3 = new TGraph(tempo.size(), &tempo[0], &Mib[0]); g3->SetMarkerColor(kGreen); mg->Add(g1); mg->Add(g2); mg->Add(g3); } } mg->Draw("AP"); //mg->GetXaxis()->SetRangeUser(0, 10500); //mg->GetYaxis()->SetRangeUser(0, 50E-5); //mg->GetXaxis()->SetTitle("time [s]"); //mg->GetYaxis()->SetTitle("I_TES / I_TES_int [A]"); //mg->GetYaxis()->SetTitleOffset(1.2); c1->Modified(); c1->Update(); } //close macro