+ totevt += nevents_physics++;
+
+ fp1 = fopen("PMD_GAIN_CONFIGFILE","w+");
+
+ if (totevt < maxevt)
+ {
+ printf("-----------------------------------------------\n");
+ printf("*** Required Number of Events not reached ***\n");
+ printf("*** Number of Events processed = %d ***\n",totevt);
+ printf("*** Writing the intermediate ASCII file ***\n");
+ printf("-----------------------------------------------\n");
+
+ calibgain.WriteTempFile("pmd_gain_tempfile.dat");
+
+ // Store the Intermediate ascii file in the DB
+ status = daqDA_DB_storeFile("pmd_gain_tempfile.dat","pmd_gain_tempfile.dat");
+
+ filestatus = 1;
+ fprintf(fp1,"%d %d %d\n",filestatus,totevt,maxevt);
+
+ // Store the configfile in the DB
+ status = daqDA_DB_storeFile("PMD_GAIN_CONFIGFILE","PMD_GAIN_CONFIGFILE");
+
+ }
+ else if (totevt >= maxevt)
+ {
+ printf("-----------------------------------------------\n");
+ printf("*** Required Number of Events reached = %d ***\n",totevt);
+ printf("*** Writing the PMDGAINS.root file ***\n");
+ printf("-----------------------------------------------\n");
+
+ calibgain.Analyse(ic);
+
+ TFile * gainRun = new TFile ("PMDGAINS.root","RECREATE");
+ ic->Write();
+ gainRun->Close();
+
+ filestatus = 0;
+ totevt = 0;
+ fprintf(fp1,"%d %d %d\n",filestatus,totevt,maxevt);
+
+ // Store the configfile in the DB
+ status = daqDA_DB_storeFile("PMD_GAIN_CONFIGFILE","PMD_GAIN_CONFIGFILE");
+
+ }
+ fclose(fp1);