26 #define USE_CANVASINTAB 28 #ifdef USE_CANVASINTAB 29 #include "CanvasInTab.hh" 44 #include <TApplication.h> 45 #include <TGApplication.h> 52 #include <TGraphErrors.h> 56 #include <TGFileBrowser.h> 57 #include <TGFileDialog.h> 66 const char *gOpenAsTypes[] = {
67 "ROOT files",
"*.root",
72 fi.fFileTypes = gOpenAsTypes;
76 new TGFileDialog(gClient->GetRoot(),
77 gClient->GetRoot(), kFDOpen, &fi);
105 if(&right ==
this)
return *
this;
134 fRelatErr(right.fRelatErr),
140 if(
this == &right)
return *
this;
149 std::vector<double>
fG;
163 char speciesName[500];
168 TTree* tree = (TTree*)file->Get(
"species");
169 tree->SetBranchAddress(
"speciesID", &speciesID);
170 tree->SetBranchAddress(
"number", &number);
171 tree->SetBranchAddress(
"nEvent", &nEvent);
172 tree->SetBranchAddress(
"speciesName", &speciesName);
173 tree->SetBranchAddress(
"time", &time);
174 tree->SetBranchAddress(
"sumG", &sumG);
175 tree->SetBranchAddress(
"sumG2", &sumG2);
177 Long64_t
nentries = tree->GetEntries();
182 cout <<
"No entries found in the tree species contained in the file " 183 << file->GetPath() << endl;
191 std::map<int, std::map<double, SpeciesInfoAOS>> speciesTimeInfo;
201 infoAOS.
fG2 += sumG2;
203 infoAOS.
fName = speciesName;
208 std::map<int, SpeciesInfoSOA> speciesInfo;
210 auto it_SOA = speciesTimeInfo.begin();
211 auto end_SOA = speciesTimeInfo.end();
213 for (; it_SOA!=end_SOA ; ++it_SOA)
215 const int _speciesID = it_SOA->first;
218 auto it2 = it_SOA->second.begin();
219 auto end2 = it_SOA->second.end();
221 info.
fName = it2->second.fName;
222 const size_t size2 = it_SOA->second.size();
223 info.
fG.resize(size2);
224 info.
fGerr.resize(size2);
225 info.
fTime.resize(size2);
227 for(
int i2 = 0 ;it2!=end2;++it2, ++i2)
231 double _SumG2 = infoAOS.
fG2;
232 double _MeanG = infoAOS.
fG/infoAOS.
fNEvent;
233 double _Gerr = sqrt((_SumG2/infoAOS.
fNEvent - pow(_MeanG,2))
236 info.
fG[i2] = _MeanG;
237 info.
fGerr[i2] = _Gerr;
238 info.
fTime[i2] = it2->first;
245 #ifdef USE_CANVASINTAB 246 CanvasInTab* myFrame =
247 new CanvasInTab(gClient->GetRoot(), 500, 500);
253 for (; it !=
end; ++it)
255 speciesID = it->first;
259 if(info.
fG.empty())
continue;
261 TGraphErrors* gSpecies =
new TGraphErrors(info.
fG.size(),
267 #ifdef USE_CANVASINTAB 268 int nCanvas = myFrame->AddCanvas(info.
fName.c_str());
269 myFrame->GetCanvas(nCanvas);
270 TCanvas* cSpecies = myFrame->GetCanvas(nCanvas);
272 TCanvas* cSpecies =
new TCanvas(info.
fName.c_str(),
277 int color = (2+speciesID)%TColor::GetNumberOfColors();
278 if(color == 5 || color==10 || color==0) ++
color;
282 gSpecies->SetMarkerStyle(20+speciesID);
283 gSpecies->SetMarkerColor(color);
286 gSpecies->SetTitle((info.
fName 290 gSpecies->GetXaxis()->SetTitle(
"Time [ns]");
291 gSpecies->GetYaxis()->SetTitle(
"G [molecules/100 eV]");
292 gSpecies->Draw(
"ap");
296 #ifdef USE_CANVASINTAB 297 int nCanvas = myFrame->GetNCanvas();
298 for(
int i = 0 ; i < nCanvas ; ++i)
300 myFrame->GetCanvas(i)->Update();
309 if(filePath == 0 || strlen(filePath) == 0)
311 perror(
"You must provide a valid file");
315 TFile*
file = TFile::Open(filePath);
319 perror (
"Error opening ntuple file");
325 perror (
"Error opening ntuple file");
330 cout <<
"Opening ntple file " << filePath << endl;
338 #define _PROCESS_ONE_FILE_ ProcessSingleFile 341 int main(
int argc,
char **argv)
344 int initialArgc = argc;
345 vector<char*> initialArgv(argc);
346 for(
int i = 0 ; i < argc ; ++i)
348 initialArgv[i] = argv[i];
352 TApplication* rootApp =
new TApplication(
"PlotG",&argc, argv);
354 const char* filePath = 0;
359 filePath = fileInfo->fFilename;
360 if(fileInfo->fFileNamesList && fileInfo->fFileNamesList->GetSize()>1)
364 perror(
"Multiple selection of files not supported, implement your own!");
379 filePath = initialArgv[1];
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
std::vector< double > fTime
#define _PROCESS_ONE_FILE_
std::vector< double > fGerr
SpeciesInfoSOA(const SpeciesInfoSOA &right)
SpeciesInfoAOS & operator=(const SpeciesInfoAOS &right)
SpeciesInfoSOA & operator=(const SpeciesInfoSOA &right)
int main(int argc, char **argv)
std::size_t color(std::string const &procname)
void ProcessSingleFile(TFile *file)
const TGFileInfo * OpenRootFile()
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
SpeciesInfoAOS(const SpeciesInfoAOS &right)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)