#include "CTShowerArray.h" #include "CTShowerArraySite.h" #include "CTShowerEvent.h" #include "CTShower.h" #include "CTShowerHit.h" #include "CTShowerReconstructor.h" #include "CTShowerUI.h" #include "CTShowerSimulator.h" #include "CTShowerAnalyzer.h" #include "CTShowerTrigger.h" #include "CTNearestNeighbors.h" #include "TApplication.h" #include #include "TH2.h" #include #include #include #include #include #include extern long long gUTC_TO_UNIX; extern long long gUNIX_TO_PACIFIC; int main(int argc, char** argv) { // expected input: [start_utcsecond] [end_utcsecond] Double_t utcsec = atof(argv[1]); Double_t firstsec = utcsec; Double_t lastsec = atof(argv[2]); int i = 0; Double_t ok = 0, prevok = 0; int CITsites[12]; Double_t t1 = utcsec - gUTC_TO_UNIX-gUNIX_TO_PACIFIC; time_t local_t1 = (time_t)t1; struct tm* locTime = localtime(&local_t1); Double_t healthy[14]; CITsites[0] = 0003; CITsites[1] = 1001; CITsites[2] = 1002; CITsites[3] = 1003; CITsites[4] = 1004; CITsites[5] = 1005; CITsites[6] = 1006; CITsites[7] = 2001; CITsites[8] = 3001; CITsites[9] = 4001; CITsites[10] = 96; CITsites[11] = 105; gChicosArray = new CTShowerArray(); CTShowerArraySite* site; // convert start and end times to MDY H:M:S t1 = firstsec - gUTC_TO_UNIX - gUNIX_TO_PACIFIC; local_t1 = (time_t)t1; locTime = localtime(&local_t1); int month1 = locTime->tm_mon+1; int date1 = locTime->tm_mday; int year1 = locTime->tm_year+1900; int hour1 = locTime->tm_hour; int minute1 = locTime->tm_min; int second1 = locTime->tm_sec; t1 = lastsec - gUTC_TO_UNIX - gUNIX_TO_PACIFIC; local_t1 = (time_t)t1; locTime = localtime(&local_t1); int month2 = locTime->tm_mon+1; int date2 = locTime->tm_mday; int year2 = locTime->tm_year+1900; int hour2 = locTime->tm_hour; int minute2 = locTime->tm_min; int second2 = locTime->tm_sec; char textfile[64]; sprintf(textfile,"./uptime_%.2d%.2d%.2d_%.2d%.2d%.2d.txt", month1,date1,year1,month2,date2,year2); char rootfile[64]; sprintf(rootfile,"./uptime_%.2d%.2d%.2d_%.2d%.2d%.2d.root", month1,date1,year1,month2,date2,year2); char fileheader1[64]; sprintf(fileheader1, "start:\t%.2d-%.2d-%.2d %.2d:%.2d:%.2d\n", month1,date1,year1,hour1,minute1,second1); char fileheader2[64]; sprintf(fileheader2, "end:\t%.2d-%.2d-%.2d %.2d:%.2d:%.2d\n\n", month2,date2,year2,hour2,minute2,second2); // text file of UTC times FILE *fp; fp = fopen(textfile, "w"); fprintf(fp, fileheader1); fprintf(fp, fileheader2); fprintf(fp, "bits:\t3, 1001, 1002, 1003, 1004, 1005, 1006, "); fprintf(fp, "2001, 3001, 4001, 96, 105\n\n"); // root tree of data TFile* fout = new TFile(rootfile,"RECREATE"); TNtupleD* nt = new TNtupleD("nt","Chiquita health","utc:s3:s1001:s1002:s1003:s1004:s1005:s1006:s2001:s3001:s4001:s96:s105:sum"); int date = 0, month = 0, year = 0; while ( utcsec <= lastsec) { ok=0; // reset bitflags t1 = utcsec - gUTC_TO_UNIX - gUNIX_TO_PACIFIC; local_t1 = (time_t)t1; locTime = localtime(&local_t1); if(date != locTime->tm_mday) { // get dynamic array each new day date = locTime->tm_mday; month = locTime->tm_mon+1; year = locTime->tm_year+1900; gChicosArray->SetArrayMDY(month, date, year); printf("%.2d-%.2d-%.2d\n", month, date, year); } gChicosArray->CheckHealth(utcsec); healthy[13] = 0; // reset number of ok sites for (i=0; i<12; i++) { ok = 10*ok; site = (gChicosArray->GetSite(CITsites[i])); healthy[i+1] = site->IsHealthy(); healthy[13] += healthy[i+1]; site->GetHealth(); if( site->IsHealthy() ) ok+=1; } healthy[0] = utcsec; nt->Fill(healthy); // fill root tree // print to text file if a site changes state if ( ok != prevok ) { fprintf(fp, "%10.0f\t%12.0f\n", utcsec, ok); } prevok = ok; utcsec += 60; } fout->Write(); fout->Close(); }