KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVFAZIADB.cpp
1//Created by KVClassFactory on Tue Jan 20 11:52:49 2015
2//Author: ,,,
3
4#include "KVFAZIADB.h"
5#include "TSystem.h"
6#include "KVNumberList.h"
7#include "KVDataSetManager.h"
8#include "KVRunListLine.h"
9
10#include "KVDBParameterList.h"
11#include "KVDBParameterSet.h"
12#include "IRODS.h"
13#include "TRandom.h"
14#include "KVMultiDetArray.h"
15
16KVFAZIADB* gFaziaDB;
17
19
20
21// BEGIN_HTML <!--
22/* -->
23<h2>KVFAZIADB</h2>
24<h4>database for FAZIA detector</h4>
25<!-- */
26// --> END_HTML
28
29
30
32
33void KVFAZIADB::init()
34{
35 //default initialisations
36
37 fDBType = "FAZIADB";
38
39 fExceptions = AddTable("Exceptions", "List signals with different PSA parameters");
40 fCalibrations = AddTable("Calibrations", "Available calibration for FAZIA detectors");
41 fOoODets = nullptr;
42 //filenames to manage the data transfer via IRODS
43 fDONEfile = "FromKVFAZIADB_transferdone.list";
44 fFAILEDfile = "FromKVFAZIADB_transferfailed.list";
45
46 Info("init", "file names for tranfert:\n%s\n%s", fDONEfile.Data(), fFAILEDfile.Data());
47}
48
49
50
52
54 "FAZIA experiment parameter database")
55{
56 init();
57}
58
59
60
61
63
65 "FAZIA experiment parameter database")
66{
67 init();
68}
69
70
71
74
76{
77 //reset global pointer gFaziaDB if it was pointing to this database
78
79 if (gFaziaDB == this)
80 gFaziaDB = 0;
81}
82
83
84
86
88{
90 gFaziaDB = this;
91
92}
93
94
95
96
100
102{
103
104 //Use KVINDRARunListReader utility subclass to read complete runlist
105
106 //get full path to runlist file, using environment variables for the current dataset
107
113 ReadComments();
115 gMultiDetArray->MakeCalibrationTables(this);
117
118}
119
120
121
126
128{
129 //Read first runlist.dat file if exists
130 //and then read
131 //runsheets
133 KVFAZIADBRun* run = 0;
134 TObjArray* toks = 0;
135
136 std::ifstream fin;
137 if (!OpenCalibFile("Runlist", fin)) {
138 Error("ReadNewRunList()", "Could not open file %s",
139 GetCalibFileName("Runlist").Data());
140 return;
141 }
142 Info("ReadNewRunList()", "Reading run list ...");
143
144 while (fin.good() && !fin.eof()) {
145 line.ReadLine(fin);
146 if (line.Length() > 1 && !line.BeginsWith("#") && !line.BeginsWith("Version")) {
147 run = new KVFAZIADBRun;
148
149 toks = line.Tokenize("|");
150 for (Int_t ii = 0; ii < toks->GetEntries(); ii += 1) {
151 KVString couple = ((TObjString*)toks->At(ii))->GetString();
152 couple.Begin("=");
153 KVString name = couple.Next();
154 name = name.Strip(TString::kBoth);
155 KVString value = "";
156 if (!couple.End()) {
157 value = couple.Next();
158 value = value.Strip(TString::kBoth);
159 }
160 if (name == "run") {
161 run->SetNumber(value.Atoi());
162 }
163 else if (name == "read events") {
164 run->SetEvents(value.Atoi());
165 }
166 else if (name == "good events") {
167 run->SetGoodEvents(value.Atoi());
168 }
169 else if (name == "starting date") {
170 run->SetStartDate(value);
171 }
172 else if (name == "stopping date") {
173 run->SetEndDate(value);
174 }
175 else if (name == "aqcuisition status") {
176 run->SetACQStatus(value);
177 }
178 else if (name == "wrong number of blocks") { //events rejected due to the wrong number of blocks
180 }
181 else if (name == "block errors") { //events rejected due to internal error in one block
183 }
184 else if (name == "nfiles") { //number of acquisition files
185 run->SetNumberOfAcqFiles(value.Atoi());
186 }
187 else if (name == "duration") { //duration in seconds of the run
188 run->SetDuration(value.Atof());
189 }
190 else if (name == "frequency") { //number of evts per seconds (aquisition rate)
191 run->SetFrequency(value.Atof());
192 }
193 else if (name == "triggerrate") { //trigger rate
194 run->SetTriggerRate(value.Atof());
195 }
196 else if (name == "mtrigger") { //trigger multiplicity
197 run->SetTrigger(value.Atof());
198 }
199 else if (name == "deadtime") { //deadtime of the acquisition between 0 and 1
200 run->SetDeadTime(value.Atof());
201 }
202 else if (name == "trig info") { //number of trigger block in the acquisition file
203 run->SetNumberOfTriggerBlocks(value.Atoi());
204 }
205 else if (name == "size(GB)") { //size in GB
206 run->SetSize(value.Atof());
207 }
208 else {
209 //Info("ReadNewRunList","Unknown field %s=%s",name.Data(),value.Data());
210 }
211 }
212 delete toks;
213 if (run->GetNumber() < 1) {
214 delete run;
215 }
216 else {
217 //run->ReadRunSheet();
218 AddRun(run);
219 }
220 }
221 }
222 fin.close();
223
224 std::ifstream ffin;
225 if (!OpenCalibFile("Runsheets", ffin)) {
226 Error("ReadNewRunList()", "Could not open file %s",
227 GetCalibFileName("Runsheets").Data());
228 return;
229 }
230 Info("ReadNewRunList()", "Reading run sheets ...");
231
232 Bool_t newrun = kFALSE;
233 while (ffin.good() && !ffin.eof()) {
234 line.ReadLine(ffin);
235 if (line.Length() > 1 && !line.BeginsWith("#") && !line.BeginsWith("Version")) {
236
237 toks = line.Tokenize("|");
238 for (Int_t ii = 0; ii < toks->GetEntries(); ii += 1) {
239 KVString couple = ((TObjString*)toks->At(ii))->GetString();
240 couple.Begin("=");
241 KVString name = couple.Next();
242 name = name.Strip(TString::kBoth);
243 KVString value = "";
244 if (!couple.End()) {
245 value = couple.Next();
246 value = value.Strip(TString::kBoth);
247 }
248 if (name == "run") {
249 Int_t number = value.Atoi();
250 newrun = kFALSE;
251 if (!(run = GetRun(number))) {
252 run = new KVFAZIADBRun();
253 run->SetNumber(number);
254 newrun = kTRUE;
255 }
256 }
257 else if (name == "read events") {
258 run->SetEvents(value.Atoi());
259 }
260 else if (name == "good events") {
261 run->SetGoodEvents(value.Atoi());
262 }
263 else if (name == "starting date") {
264 run->SetStartDate(value);
265 }
266 else if (name == "stopping date") {
267 run->SetEndDate(value);
268 }
269 else if (name == "aqcuisition status") {
270 run->SetACQStatus(value);
271 }
272 else if (name == "wrong number of blocks") { //events rejected due to the wrong number of blocks
274 }
275 else if (name == "block errors") { //events rejected due to internal error in one block
277 }
278 else if (name == "nfiles") { //number of acquisition files
279 run->SetNumberOfAcqFiles(value.Atoi());
280 }
281 else if (name == "duration") { //duration in seconds of the run
282 run->SetDuration(value.Atof());
283 }
284 else if (name == "frequency") { //number of evts per seconds (aquisition rate)
285 run->SetFrequency(value.Atof());
286 }
287 else if (name == "triggerrate") { //trigger rate
288 run->SetTriggerRate(value.Atof());
289 }
290 else if (name == "mtrigger") { //trigger multiplicity
291 run->SetTrigger(value.Atof());
292 }
293 else if (name == "deadtime") { //deadtime of the acquisition between 0 and 1
294 run->SetDeadTime(value.Atof());
295 }
296 else if (name == "trig info") { //number of trigger block in the acquisition file
297 run->SetNumberOfTriggerBlocks(value.Atoi());
298 }
299 else {
300 //Info("ReadNewRunList","Unknown field %s=%s",name.Data(),value.Data());
301 }
302 }
303 delete toks;
304 if (newrun) {
305 if (run->GetNumber() < 1) {
306 delete run;
307 }
308 else {
309 AddRun(run);
310 }
311 }
312 }
313 }
314 ffin.close();
315}
316
317
318
325
327{
328//Perform the tranfer via irods to ccali for the indicated directory [file]
329//return status of the iput command
330// OK if the transfer is done
331// not OK if it has failed
332//
333
334 IRODS ir;
335 Int_t retour = ir.put(
336 Form("-%s %s", option.Data(), file.Data()),
337 Form("%s/%s/%s", ccali_rep.Data(), gDataSet->GetDataPathSubdir(), gDataSet->GetDataTypeSubdir("bin"))
338 );
339 return (retour == 0);
340
341 /*
342 //some lines to test all the process
343 Double_t val = gRandom->Uniform(0,1);
344 printf("%s %lf\n",file.Data(),val);
345 return (val<0.5);
346 */
347
348}
349
350
351
356
358{
359// test the status of the transfer
360// write to the corresponding file : done or failed
361//
362
363 Bool_t retour = TransferAcquisitionFileToCcali(Form("%s/run%06d", path.Data(), run), ccali_rep, option);
364 if (retour) {
365 FILE* ff = fopen(fDONEfile.Data(), "a");
366 fprintf(ff, "%d\n", run);
367 fclose(ff);
368 }
369 else {
370 FILE* ff = fopen(fFAILEDfile.Data(), "a");
371 fprintf(ff, "%d\n", run);
372 fclose(ff);
373 }
374
375 return retour;
376
377}
378
379
380
384
386{
387
388//Remove file where failed tranfer runs are listed
389//
390 KVNumberList lFAILED;
391 gSystem->Exec(Form("rm %s", fFAILEDfile.Data()));
392
393//Loop on run list
394//If transfer fails, the run number is kept in a kvnumberlist
395//for status at the end
396//
397 lrun.Begin();
398 while (!lrun.End()) {
399 Int_t run = lrun.Next();
400 if (!TransferRunToCcali(run, path, ccali_rep, option)) {
401 lFAILED.Add(run);
402 }
403 }
404
405//print list of failed tranfers
406 if (!lFAILED.IsEmpty())
407 Warning("TransferRunListToCcali", "Transfer failed for %d runs :\n%s", lFAILED.GetNValues(), lFAILED.AsString());
408
409}
410
411
412
414
415void KVFAZIADB::StartTransfer(TString filename, TString ccali_rep, TString option)
416{
417
418 Int_t run;
419 TString datadir = "";
420
421//-----------
422// list of runs for which transfer failed during the last tentative
423//-----------
424 KVNumberList lFAILED;
425 KVFileReader fr;
427 while (fr.IsOK()) {
428 fr.ReadLine(0);
429 if (fr.GetCurrentLine() != "") {
430 run = fr.GetCurrentLine().Atoi();
431 lFAILED.Add(run);
432 }
433 }
434 fr.CloseFile();
435
436//-----------
437// list of runs for which transfer succeeded since the beginning
438//-----------
439 KVNumberList lDONE;
440 fr.Clear();
442 while (fr.IsOK()) {
443 fr.ReadLine(0);
444 if (fr.GetCurrentLine() != "") {
445 run = fr.GetCurrentLine().Atoi();
446 lDONE.Add(run);
447 }
448 }
449 if (lDONE.GetNValues() > 0)
450 Info("StartTransfer", "%d runs already tranfered:\n%s", lDONE.GetNValues(), lDONE.AsString());
451 fr.CloseFile();
452
453//-----------
454// all runs produced
455//-----------
456
457 KVNumberList lALL;
458 fr.Clear();
459 fr.OpenFileToRead(filename.Data());
460 while (fr.IsOK()) {
461
462 fr.ReadLine("|");
463 if (fr.GetCurrentLine().BeginsWith("#")) {
465 line.ReplaceAll("#", "");
466 line = line.StripAllExtraWhiteSpace();
467 line.Begin("=");
468 KVString name = line.Next();
469 if (!line.End() && name == "--dir") {
470 datadir = line.Next();
471 Info("ReadDBFile", "acquisition file directory: %s", datadir.Data());
472 }
473 }
474 else {
475 if (datadir == "") {
476 fr.CloseFile();
477 Warning("ReadDBFile", "no data directory has been found ...");
478 return;
479 }
480 if (fr.GetNparRead() > 0) {
481 for (Int_t ii = 0; ii < fr.GetNparRead(); ii += 1) {
482
483 KVString couple = fr.GetReadPar(ii);
484 couple.Begin("=");
485 KVString name = couple.Next();
486 name = name.Strip(TString::kBoth);
487 KVString value = "";
488 if (!couple.End()) {
489 value = couple.Next();
490 value = value.Strip(TString::kBoth);
491 }
492 if (name == "run") {
493 run = value.Atoi();
494 if (!lDONE.Contains(run))
495 lALL.Add(run);
496 }
497 }
498 }
499 }
500 }
501 fr.CloseFile();
502
503 if (lALL.GetNValues() > 0) {
504 Info("StartTransfer", "Start transfer for %d runs:\n%s", lALL.GetNValues(), lALL.AsString());
505 TransferRunListToCcali(lALL, datadir.Data(), ccali_rep, option);
506 }
507 else
508 Info("StartTransfer", "no runs to tranfer ...");
509
510}
511
512
513
514
516
517const Char_t* KVFAZIADB::GetFileName(const Char_t* meth, const Char_t* keyw)
518{
519
520 TString basic_name = GetCalibFileName(keyw);
521 if (basic_name == "") {
522 Info(meth, "No name found for \"%s\" file", keyw);
523 return "";
524 }
525 Info(meth, "Search for %s for dataset %s ...", basic_name.Data(), gDataSet->GetName());
526 static TString fp;
527 fp = gDataSet->GetFullPathToDataSetFile(basic_name.Data());
528 if (fp == "") {
529 Info(meth, "\tNo file found ...");
530 return "";
531 }
532 return fp.Data();
533
534}
535
536
537
539
541{
542
543 TString fp = GetFileName(meth, keyw);
544 if (fp == "")
545 return 0;
546
547 KVFileReader* fr = new KVFileReader();
548 if (!fr->OpenFileToRead(fp.Data())) {
549 Error(meth, "Error in opening file %s", fp.Data());
550 delete fr;
551 return 0;
552 }
553
554 Info(meth, "Reading %s file", fp.Data());
555 return fr;
556
557}
558
559
560
562
563TEnv* KVFAZIADB::GetFileTEnv(const Char_t* meth, const Char_t* keyw)
564{
565
566 TString fp = GetFileName(meth, keyw);
567 if (fp == "")
568 return 0;
569
570 Info(meth, "Reading %s file", fp.Data());
571 TEnv* env = new TEnv();
572 env->ReadFile(fp.Data(), kEnvAll);
573 return env;
574
575}
576
577
578
580
582{
583 KVFileReader* fr = GetKVFileReader("ReadExceptions()", "Exceptions");
584 if (!fr)
585 return;
586
587 TList* ll = new TList();
588 KVNumberList lruns;
589 KVDBParameterList* dbp = 0;
590
591 ll->SetOwner(kFALSE);
592 while (fr->IsOK()) {
593 fr->ReadLine(":");
594 if (fr->GetNparRead() == 2) {
595 if (fr->GetReadPar(0) == "RunRange") {
596 if (ll->GetEntries() > 0) {
597 LinkListToRunRange(ll, lruns);
598 ll->Clear();
599 }
600 lruns.SetList(fr->GetReadPar(1));
601 //printf("nouvelle plage : %s\n", lruns.AsString());
602 }
603 else {
604 KVString name(fr->GetReadPar(0));
605 name.Begin(".");
606 KVString sdet = name.Next();
607
608 KVString sig = name.Next();
609 if (sig == "QH1" || sig == "QL1" || sig == "I1") sdet.Prepend("SI1-");
610 else if (sig == "Q2" || sig == "I2") sdet.Prepend("SI2-");
611 else if (sig == "Q3") sdet.Prepend("CSI-");
612
613 KVString par = name.Next();
614 if (!(dbp = (KVDBParameterList*)ll->FindObject(Form("%s.%s", sdet.Data(), sig.Data())))) {
615 dbp = new KVDBParameterList(Form("%s.%s", sdet.Data(), sig.Data()), sdet.Data());
616 dbp->AddKey("Runs", "List of Runs");
618 ll->Add(dbp);
619 dbp->GetParameters()->SetValue("RunRange", lruns.AsString());
620 dbp->GetParameters()->SetValue("Detector", sdet.Data());
621 dbp->GetParameters()->SetValue("Signal", sig.Data());
622 }
623 dbp->GetParameters()->SetValue(par.Data(), fr->GetDoubleReadPar(1));
624 }
625 }
626 }
627
628 if (ll->GetEntries() > 0) {
629 LinkListToRunRange(ll, lruns);
630 ll->Clear();
631 }
632
633 delete ll;
634 delete fr;
635
636}
637
638
640
642{
643 KVFileReader* fr = GetKVFileReader("ReadComments()", "Comments");
644 if (!fr)
645 return;
646
647 KVFAZIADBRun* dbrun = 0;
648 while (fr->IsOK()) {
649 fr->ReadLine("|");
650 if (fr->GetCurrentLine().BeginsWith("#")) {
651
652 }
653 else if (fr->GetCurrentLine() == "") {
654
655 }
656 else {
657 if (fr->GetNparRead() == 2) {
658 KVString srun(fr->GetReadPar(0));
659 srun.Begin("=");
660 srun.Next();
661 KVNumberList lruns(srun.Next());
662 KVString comments(fr->GetReadPar(1));
663 lruns.Begin();
664 while (!lruns.End()) {
665 Int_t run = lruns.Next();
666 dbrun = (KVFAZIADBRun*)GetRun(run);
667 if (dbrun)
668 dbrun->SetComments(comments.Data());
669 }
670 }
671 }
672 }
673 delete fr;
674
675}
676
677
678
680
682{
683
684 TEnv* env = GetFileTEnv("ReadRutherfordCounting()", "RutherfordCounting");
685 if (!env)
686 return;
687
688 TIter next(env->GetTable());
689 TEnvRec* rec = 0;
690 KVFAZIADBRun* dbrun = 0;
691 while ((rec = (TEnvRec*)next())) {
692 TString sname(rec->GetName());
693 dbrun = GetRun(sname.Atoi());
694 dbrun->SetRutherfordCount(TString(rec->GetValue()).Atoi());
695 }
696 delete env;
697}
698
699
700
702
704{
705 KVFileReader* fr = GetKVFileReader("ReadRutherfordCrossSection()", "RutherfordCrossSection");
706 if (!fr)
707 return;
708
709 KVFAZIADBRun* dbrun = 0;
710 KVDBSystem* dbsys = 0;
711 while (fr->IsOK()) {
712 fr->ReadLine(":");
713 if (fr->GetCurrentLine().BeginsWith("#")) {
714
715 }
716 else if (fr->GetCurrentLine() == "") {
717
718 }
719 else {
720 if (fr->GetNparRead() == 2) {
721 dbsys = GetSystem(fr->GetReadPar(0));
722 if (dbsys) {
723 Double_t val = fr->GetDoubleReadPar(1);
724 TIter next(dbsys->GetRuns());
725 while ((dbrun = (KVFAZIADBRun*)next())) {
726 dbrun->SetRutherfordCrossSection(val);
727 }
728 }
729 }
730 }
731 }
732 fr->CloseFile();
733 delete fr;
734
735}
736
737
738
740
742{
743
744 KVFileReader* fr = GetKVFileReader("ReadCalibrationFiles()", "CalibrationFiles");
745 if (!fr)
746 return;
747
748 while (fr->IsOK()) {
749 fr->ReadLine(0);
750 if (fr->GetCurrentLine().BeginsWith("#") || fr->GetCurrentLine() == "") {}
751 else {
753 }
754 }
755 fr->CloseFile();
756 delete fr;
757
758}
759
760
762
763void KVFAZIADB::ReadCalibFile(const Char_t* filename)
764{
765
766 Bool_t find = kFALSE;
767 TString fullpath = "";
768 if (gSystem->Exec(Form("test -e %s/%s", GetDataSetDir(), filename)) == 0) {
769 //Info("ReadCalibFile", "%s/%s do not exist", GetDataSetDir(), filename);
770 //return;
771 find = kTRUE;
772 fullpath.Form("%s/%s", GetDataSetDir(), filename);
773 }
774 else if (gSystem->Exec(Form("test -e %s", filename)) == 0) {
775 //Info("ReadCalibFile", "%s do not exist", filename);
776 //return;
777 find = kTRUE;
778 fullpath.Form("%s", filename);
779 }
780 if (!find) {
781 Info("ReadCalibFile", "%s does not exist or not found", filename);
782 return;
783 }
784
785 Info("ReadCalibFile", "file : %s found", fullpath.Data());
786 TEnv env;
787 env.ReadFile(Form("%s", fullpath.Data()), kEnvAll);
788 TIter next(env.GetTable());
789 TEnvRec* rec = 0;
790 KVDBParameterSet* par = 0;
791 KVNumberList default_run_list = GetRunList();
792
793 TString ssignal = "";
794 TString stype = "";
795
796 while ((rec = (TEnvRec*)next())) {
797 TString sname(rec->GetName());
798 if (sname == "Signal") {
799 ssignal = rec->GetValue();
800 }
801 else if (sname == "CalibType") {
802 stype = rec->GetValue();
803 }
804 else if (sname == "RunList") {
805 default_run_list.Set(rec->GetValue());
806 }
807 else {
808 KVString lval(rec->GetValue());
809 Int_t np = 0;
810 lval.Begin(",");
811 while (!lval.End()) {
812 KVString sval = lval.Next();
813 np += 1;
814 }
815 par = new KVDBParameterSet(sname.Data(), stype.Data(), np);
816
817 np = 0;
818 lval.Begin(",");
819 while (!lval.End()) {
820 par->SetParameter(np++, lval.Next().Atof());
821 }
823 LinkRecordToRunRange(par, default_run_list);
824 }
825 }
826
827 if (ssignal == "") Error("ReadCalibFile", "No signal defined");
828 if (stype == "") Error("ReadCalibFile", "No calibration type defined");
829}
830
831
832
836
838{
839
840 //Lit le fichier ou sont listes les dedtecteurs ne marchant plus au cours
841 //de la manip
842 TEnv* env = GetFileTEnv("ReadOoODetectors()", "OoODet");
843 if (!env)
844 return;
845
846 fOoODets = AddTable("OoO Detectors", "Name of out of order detectors");
847
848 KVDBRecord* dbrec = 0;
849
850 TEnvRec* rec = 0;
851
852 TIter it(env->GetTable());
853 while ((rec = (TEnvRec*)it.Next())) {
854 KVString srec(rec->GetName());
855 KVNumberList nl(rec->GetValue());
856
857 if (srec.Contains(",")) {
858 srec.Begin(",");
859 while (!srec.End()) {
860 dbrec = new KVDBRecord(srec.Next(), "OoO Detector");
861 dbrec->AddKey("Runs", "List of Runs");
862 fOoODets->AddRecord(dbrec);
863 LinkRecordToRunRange(dbrec, nl);
864 }
865 }
866 else {
867 dbrec = new KVDBRecord(rec->GetName(), "OoO Detector");
868 dbrec->AddKey("Runs", "List of Runs");
869 fOoODets->AddRecord(dbrec);
870 LinkRecordToRunRange(dbrec, nl);
871 }
872 }
873 delete env;
874}
875
876
877//---------------------------------------
879//---------------------------------------
880
881
895
896{
897 /*
898 Use this method in order to read runs written on disk
899 during the experiment
900 File is produced with main information for each run :
901 number of files
902 size
903 starting date
904 Information on runs has to completed after reading acquisition file
905 specially information on trigger and deatdime
906
907 usage : acqfiles_dir is the repository where acquisition files are written
908
909 2 output files are written
910 - runlist.dat containing all runs
911 - database.log giving a summarize of stored data
912 the two file names are set by default in .kvrootrc
913
914 */
915 if (gSystem->Exec(Form("test -d %s", acqfiles_dir.Data())) != 0) {
916 Error("BuildQuickAndDirtyDataBase", "%s is not an existing directory", acqfiles_dir.Data());
917 return;
918 }
919
920 TString sfout = GetCalibFileName("Runlist");
921 FILE* fout = fopen(sfout.Data(), "w");
922 fprintf(fout, "# DataSet %s\n", gDataSet->GetName());
923 fprintf(fout, "# Runlist generated by KVFAZIADB::BuildQuickAndDirtyDataBase from files located at:\n");
924 fprintf(fout, "# --dir=%s\n", acqfiles_dir.Data());
925
926 TString sflog = GetCalibFileName("DBLog");
927 FILE* flog = fopen(sflog.Data(), "w");
928 fprintf(flog, "# DataSet %s\n", gDataSet->GetName());
929 fprintf(flog, "# Log generated by KVFAZIADB::BuildQuickAndDirtyDataBase from files located at:\n");
930 fprintf(flog, "# --dir=%s\n", acqfiles_dir.Data());
931
932 Int_t run, nfiles;
933 Long64_t size = 0;
934 Long64_t totalsize = 0;
935 Int_t date, idx;
936 KVDatime kvdate;
937
938 KVString ldir = gSystem->GetFromPipe(Form("du %s", acqfiles_dir.Data()));
939 ldir.Begin("\n");
940 Int_t numberofruns = 0;
941 KVNumberList lruns;
942
943 while (!ldir.End()) {
944 KVString sdir = ldir.Next();
945 sdir.Begin("\t");
946 size = sdir.Next().Atoll(); // /TMath::Power(2,10)+1; //read values are in KB
947 sdir = gSystem->BaseName(sdir.Next());
948 if (sscanf(sdir.Data(), "run%d", &run) == 1) {
949 totalsize += size;
950 Int_t dmin = 0;
951 Int_t dmax = 0;
952 KVString lfile = gSystem->GetFromPipe(Form("ls %s/%s", acqfiles_dir.Data(), sdir.Data()));
953 lfile.Begin("\n");
954 nfiles = 0;
955 while (!lfile.End()) {
956 KVString sfile = lfile.Next();
957 //FzEventSet-1434434675-41784.pb
958 if (sscanf(sfile.Data(), "FzEventSet-%d-%d.pb", &date, &idx) == 2) {
959 if (dmin == 0) {
960 dmin = dmax = date;
961 }
962 else {
963 if (date < dmin) dmin = date;
964 if (date > dmax) dmax = date;
965 }
966 nfiles += 1;
967 }
968 }
969 if (nfiles == 0 || size == 0) {
970 Warning("BuildQuickAndDirtyDataBase", "%d -> empty run", run);
971 }
972 kvdate.Set(dmin);
973 fprintf(fout, "run=%d | starting date=%s | nfiles=%d | size(GB)=%1.2lf\n", run, kvdate.AsString(), nfiles, size * TMath::Power(2., -20));
974 numberofruns += 1;
975 lruns.Add(run);
976 }
977 else {
978 Double_t conv = TMath::Power(2., -30);
979 fprintf(flog, "total size %lld - %lld\n", size, totalsize);
980 fprintf(flog, "total size (TB) %1.2lf - %1.2lf\n", size * conv, totalsize * conv);
981 fprintf(flog, "number of runs %d\n", numberofruns);
982 fprintf(flog, "last run %d done at %s\n", lruns.Last(), kvdate.AsString());
983 }
984 }
985
986 fclose(fout);
987 fclose(flog);
988}
989
990
int Int_t
size_t size(const MatrixT &matrix)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
kEnvAll
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Interface to IRODS (Integrated Rule-Oriented Data System) DMS client.
Definition IRODS.h:15
virtual Int_t put(const Char_t *source, const Char_t *target=".")
put a new file into IRODS space.
Definition IRODS.cpp:101
To store calibration parameters in a database ,.
KVNameValueList * GetParameters()
To store calibration parameters in a database ,.
void SetParameter(UShort_t i, Double_t val)
Record folder for the database.
Definition KVDBRecord.h:43
virtual Bool_t AddKey(KVDBKey *key, Bool_t check=kTRUE)
virtual Int_t GetNumber() const
Definition KVDBRecord.h:73
void SetEvents(ULong64_t evt_number)
Definition KVDBRun.h:170
void SetSize(Double_t s)
Definition KVDBRun.h:178
void SetComments(const KVString &comments)
Definition KVDBRun.h:182
void SetStartDate(const KVString &date)
Definition KVDBRun.h:186
void SetEndDate(const KVString &d)
Definition KVDBRun.h:194
void SetTrigger(Int_t trig)
Definition KVDBRun.h:99
void SetNumber(Int_t n)
Definition KVDBRun.h:93
Database class used to store information on different colliding systems studied during an experiment....
Definition KVDBSystem.h:52
KVUnownedList * GetRuns() const
Returns a sorted list of all the runs associated with this system.
Definition KVDBSystem.h:117
virtual Bool_t AddRecord(KVDBRecord *add)
Definition KVDBTable.cpp:74
virtual Bool_t AddTable(KVDBTable *table)
virtual const Char_t * GetDataPathSubdir() const
Returns name of top-level directory in data repository used to store data files for this dataset.
Definition KVDataSet.h:95
TString GetFullPathToDataSetFile(const Char_t *filename)
const Char_t * GetDataTypeSubdir(const Char_t *type) const
Definition KVDataSet.h:99
Extension of TDatime to handle various useful date formats.
Definition KVDatime.h:33
Base class to describe database of an experiment ,,.
Definition KVExpDB.h:20
virtual void ReadSystemList()
Definition KVExpDB.cpp:249
virtual void cd()
Definition KVExpDB.cpp:577
void AddRun(KVDBRun *r)
Definition KVExpDB.h:67
TString GetCalibFileName(const Char_t *type) const
Definition KVExpDB.h:109
const KVNumberList & GetRunList() const
Definition KVExpDB.h:80
virtual void LinkListToRunRange(TList *list, const KVNumberList &nl)
Link the records contained in the list to the set of runs (see LinkRecordToRunRanges).
Definition KVExpDB.cpp:200
const Char_t * GetDataSetDir() const
Definition KVExpDB.h:136
virtual void LinkRecordToRunRange(KVDBRecord *rec, UInt_t first_run, UInt_t last_run)
Definition KVExpDB.cpp:87
virtual KVDBSystem * GetSystem(const Char_t *system) const
Definition KVExpDB.h:85
Bool_t OpenCalibFile(const Char_t *type, std::ifstream &fs) const
Definition KVExpDB.cpp:433
TString fDataSet
the name of the dataset to which this database is associated
Definition KVExpDB.h:23
Database entry for a run in a FAZIA experiment.
void SetNumberOfAcqFiles(Int_t)
void SetDuration(Double_t)
void SetGoodEvents(Int_t)
void SetError_InternalBlockError(Int_t)
void SetError_WrongNumberOfBlocks(Int_t)
void SetRutherfordCrossSection(Double_t)
void SetRutherfordCount(Int_t)
void SetACQStatus(const KVString &status)
void SetFrequency(Double_t)
void SetTriggerRate(Double_t)
void SetDeadTime(Double_t)
void SetNumberOfTriggerBlocks(Double_t)
Experiment database for FAZIA.
Definition KVFAZIADB.h:22
void ReadComments()
const Char_t * GetFileName(const Char_t *meth, const Char_t *keyw)
Bool_t TransferRunToCcali(Int_t run, TString path, TString ccali_rep="/fazia", TString option="frv")
TString fFAILEDfile
Definition KVFAZIADB.h:37
virtual void cd()
Definition KVFAZIADB.cpp:87
void ReadRutherfordCrossSection()
Bool_t TransferAcquisitionFileToCcali(TString file, TString ccali_rep="/fazia", TString option="frv")
TString fDONEfile
Definition KVFAZIADB.h:36
void TransferRunListToCcali(KVNumberList lrun, TString path, TString ccali_rep="/fazia", TString option="frv")
void init()
default initialisations
Definition KVFAZIADB.cpp:33
void BuildQuickAndDirtyDataBase(TString)
KVDBTable * fExceptions
table of exceptions
Definition KVFAZIADB.h:27
void ReadNewRunList()
KVFileReader * GetKVFileReader(const Char_t *meth, const Char_t *keyw)
KVDBTable * fCalibrations
table for calibrations
Definition KVFAZIADB.h:28
void ReadRutherfordCounting()
void ReadExceptions()
KVFAZIADBRun * GetRun(Int_t run) const
Definition KVFAZIADB.h:48
void ReadCalibrationFiles()
void StartTransfer(TString filename="runlist.dat", TString ccali_rep="/fazia", TString option="frv")
virtual ~KVFAZIADB()
reset global pointer gFaziaDB if it was pointing to this database
Definition KVFAZIADB.cpp:75
virtual void Build()
KVDBTable * fOoODets
(optional) Liste les detecteurs hors service
Definition KVFAZIADB.h:29
TEnv * GetFileTEnv(const Char_t *meth, const Char_t *keyw)
virtual void ReadOoODetectors()
void ReadCalibFile(const Char_t *filename)
Handle reading columns of numeric data in text files.
KVString GetCurrentLine()
ReadStatus ReadLine(const KVString &pattern="")
Double_t GetDoubleReadPar(Int_t pos) const
void Clear(Option_t *="")
Int_t GetNparRead() const
Bool_t IsOK()
KVString GetReadPar(Int_t pos) const
Bool_t OpenFileToRead(const KVString &filename)
virtual void MakeCalibrationTables(KVExpDB *)
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray")
void SetValue(const Char_t *name, value_type value)
Strings used to represent a set of ranges of values.
Bool_t Contains(Int_t val) const
returns kTRUE if the value 'val' is contained in the ranges defined by the number list
const Char_t * AsString(Int_t maxchars=0) const
Bool_t End(void) const
Int_t GetNValues() const
void Begin(void) const
void SetList(const TString &)
void Add(Int_t)
Add value 'n' to the list.
void Set(const TString &l)
Bool_t IsEmpty() const
Int_t Last() const
Returns largest number included in list.
Int_t Next(void) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition KVString.h:73
void Begin(TString delim) const
Definition KVString.cpp:565
Bool_t End() const
Definition KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition KVString.cpp:695
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
void Set()
const char * AsString() const
THashList * GetTable() const
virtual Int_t ReadFile(const char *fname, EEnvLevel level)
TObject * Next()
void Clear(Option_t *option="") override
TObject * FindObject(const char *name) const override
void Add(TObject *obj) override
const char * GetName() const override
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Int_t Atoi() const
Double_t Atof() const
const char * Data() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(char c, Ssiz_t rep=1)
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Long64_t Atoll() const
virtual Int_t Exec(const char *shellcmd)
virtual const char * BaseName(const char *pathname)
virtual TString GetFromPipe(const char *command)
long long Long64_t
TLine * line
void Info(const char *location, const char *fmt,...)
rec
Double_t Power(Double_t x, Double_t y)
ClassImp(TPyArg)