]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/T0Laserda.cxx
Readme for calibration/performance train (Marian)
[u/mrichter/AliRoot.git] / T0 / T0Laserda.cxx
index 989e08f10ddd0c0ba17ca59199ed882d6d50fe8d..6812a423a0c245bb45f2948b7007c544eb236120 100644 (file)
@@ -1,19 +1,19 @@
 /*
-TOF DA for online calibration
-
+T0 DA for online calibration
 Contact: Michal.Oledzki@cern.ch
-Link: www.if.pw.edu.pl:/~oledzki
-Run Type: PHYSICS
+Link: http://users.jyu.fi/~mioledzk/
+Run Type: STANDALONE
 DA Type: MON
-Number of events needed: depending on the run, being run-level
-Input Files: 
+Number of events needed: 400000 
+Input Files: inLaser.dat, external parameters
 Output Files: daLaser.root, to be exported to the DAQ FXS
-Trigger types used: PHYSICS_EVENT
+Trigger types used: CALIBRATION_EVENT
 
 */
 
 #define FILE_OUT "daLaser.root"
-
+#define FILE_IN "inLaser.dat"
 #include <daqDA.h>
 #include <event.h>
 #include <monitor.h>
@@ -31,7 +31,6 @@ Trigger types used: PHYSICS_EVENT
 #include "TROOT.h"
 #include "TPluginManager.h"
 #include "TFile.h"
-#include "TFile.h"
 #include "TKey.h"
 #include "TH2S.h"
 #include "TObject.h"
@@ -44,8 +43,9 @@ Trigger types used: PHYSICS_EVENT
 #include "TF1.h"
 #include "TSpectrum.h"
 #include "TVirtualFitter.h"
-#include "TProfile.h"
-
+//#include "TProfile.h"
+int cqbx,cqby,clbx,clby,mod;
+float cqlx,cqmx,cqly,cqmy,cllx,clmx,clly,clmy;
 /* Main routine
       Arguments: 
       1- monitoring data source
@@ -60,6 +60,39 @@ int main(int argc, char **argv) {
                                        "RIO",
                                        "TStreamerInfo()"); 
   
+  if(daqDA_DB_getFile(FILE_IN, FILE_IN)){
+     printf("Couldn't get input file >>inLaser.dat<< from DAQ_DB !!!\n");
+     return -1;
+  }
+  
+  FILE *inp;
+  char c;
+  inp = fopen(FILE_IN, "r");  
+  if(!inp){
+       printf("Input file >>inLaser.dat<< not found !!!\n");
+       return -1;
+  }
+
+  while((c=getc(inp))!=EOF) {
+    switch(c) {
+      case 'a': {fscanf(inp, "%d", &cqbx ); break;} //N of X bins hCFD_QTC
+      case 'b': {fscanf(inp, "%f", &cqlx ); break;} //Low x hCFD_QTC
+      case 'c': {fscanf(inp, "%f", &cqmx ); break;} //High x hCFD_QTC
+      case 'd': {fscanf(inp, "%d", &cqby ); break;} //N of Y bins hCFD_QTC
+      case 'e': {fscanf(inp, "%f", &cqly ); break;} //Low y hCFD_QTC
+      case 'f': {fscanf(inp, "%f", &cqmy ); break;} //High y hCFD_QTC
+      case 'g': {fscanf(inp, "%d", &clbx ); break;} //N of X bins hCFD_LED
+      case 'h': {fscanf(inp, "%f", &cllx ); break;} //Low x hCFD_LED
+      case 'i': {fscanf(inp, "%f", &clmx ); break;} //High x hCFD_LED
+      case 'j': {fscanf(inp, "%d", &clby ); break;} //N of Y bins hCFD_LED
+      case 'k': {fscanf(inp, "%f", &clly ); break;} //Low y hCFD_LED
+      case 'l': {fscanf(inp, "%f", &clmy ); break;} //High y hCFD_LED
+      case 'm': {fscanf(inp, "%d", &mod  ); break;} //Modulo number
+    }
+  }
+  fclose(inp);
+
   if (argc!=2) {
     printf("Wrong number of arguments\n");
     return -1;
@@ -91,24 +124,20 @@ int main(int argc, char **argv) {
   printf("T0 monitoring program started\n");  
 
   // Allocation of histograms - start
-  TH1F *hCFD[24];
-  TH2F *hCFD_QTC[24];
-  TH2F *hCFD_LED[24]; 
-
-   for(Int_t ic=0; ic<24; ic++) {
-      hCFD_QTC[ic] = new TH2F(Form("CFD_QTC%d",ic+1),"CFD_QTC",800,0.5,8000.5,200,10000.5,20000.5);
-      hCFD_LED[ic] = new TH2F(Form("CFD_LED%d",ic+1),"CFD_LED",100,-500.0,500.0,100,14600.0,14700.0);
-      if(ic<12){
-       hCFD[ic] = new TH1F(Form("T0_C_%d_CFD",ic+1),"CFD", 3000,0., 30000.);   
-      }
-      else{
-        hCFD[ic] = new TH1F(Form("T0_A_%d_CFD",ic-11),"CFD", 3000,0., 30000.); 
-      }
+  TH2F *hCFDvsQTC[24][10];
+  TH2F *hCFDvsLED[24][10]; 
+
+   for(Int_t ic=0; ic<24; ic++) 
+       for(Int_t im=0;im<10;im++)
+    {
+      hCFDvsQTC[ic][im] = new TH2F(Form("CFDvsQTC%d_%d",ic+1,im+1),"CFDvsQTC",cqbx,cqlx,cqmx,cqby,cqly,cqmy);
+      hCFDvsLED[ic][im] = new TH2F(Form("CFDvsLED%d_%d",ic+1,im+1),"CFDvsLED",clbx,cllx,clmx,clby,clly,clmy);
     }
 
   // Allocation of histograms - end
 
   Int_t iev=0;
+  Int_t mip=0;
   /* main loop (infinite) */
   for(;;) {
     struct eventHeaderStruct *event;
@@ -134,8 +163,6 @@ int main(int argc, char **argv) {
       continue;
     }
  
-    iev++; 
-
     /* use event - here, just write event id to result file */
     eventT=event->eventType;
    
@@ -147,68 +174,70 @@ int main(int argc, char **argv) {
       case END_OF_RUN:
        break;
 
-//      case CALIBRATION_EVENT:
-      case PHYSICS_EVENT:
-      printf(" event number = %i \n",iev);
+      case CALIBRATION_EVENT:
+//      case PHYSICS_EVENT:
+      iev++; 
 
+      if(iev==1){
+           printf("First event - %i\n",iev);
+      }
 
       // Initalize raw-data reading and decoding
       AliRawReader *reader = new AliRawReaderDate((void*)event);
           
       // Enable the following two lines in case of real-data
-   //       reader->LoadEquipmentIdsMap("T0map.txt");
-    //     reader->RequireHeader(kFALSE);
-     //          reader->RequireHeader(kTRUE);
+         reader->RequireHeader(kTRUE);
       AliT0RawReader *start = new AliT0RawReader(reader, kTRUE);
 
       // Read raw data
-      Int_t allData[105][5];
-      for(Int_t i0=0;i0<105;i0++)
+      Int_t allData[106][5];
+      for(Int_t i0=0;i0<106;i0++)
        for(Int_t j0=0;j0<5;j0++)
                allData[i0][j0] = 0;
      
-      if(start->Next())
-      for (Int_t i=0; i<105; i++) {
-       for(Int_t iHit=0;iHit<5;iHit++){
+       if(start->Next()){
+        for (Int_t i=0; i<106; i++) {
+        for(Int_t iHit=0;iHit<5;iHit++){
          allData[i][iHit]= start->GetData(i,iHit);
+         }
         }
-      }
+       }
        else 
-       printf("No T0 data found!!\n");
+        printf("No data for T0 found!!!\n");
 
       // Fill the histograms
-       
+
+      if(iev<10000){
+        mip=0;
+       }else 
+       if((iev%mod)==0.0){
+       mip++;
+//     printf("mip = %d\n",mip);
+       if(mip>=9) mip=9;}
+      
+
       for (Int_t ik = 0; ik<24; ik+=2)
-         for (Int_t iHt=0; iHt<5; iHt++){
+         for (Int_t iHt=0; iHt<1; iHt++){
                 Int_t cc = ik/2;
-               if((allData[cc+1][iHt]-allData[0][0])>0){
-                hCFD[cc]->Fill(allData[cc+1][iHt]-allData[0][0]);
-               }
                if(allData[ik+25][iHt]!=0 && allData[ik+26][iHt]!=0 && allData[cc+1][iHt]!=0){
-                 hCFD_QTC[cc]->Fill((allData[ik+25][iHt]-allData[ik+26][iHt]) , (allData[cc+1][iHt]-allData[0][0]));
-                
+                 hCFDvsQTC[cc][mip]->Fill((allData[ik+25][iHt]-allData[ik+26][iHt]) , (allData[cc+1][iHt]-allData[0][0]+5000));
+               } 
                 if(allData[cc+13][iHt]!=0 && allData[cc+1][iHt]!=0){
-                hCFD_LED[cc]->Fill(allData[cc+13][iHt]-allData[cc+1][iHt],allData[cc+1][iHt]-allData[0][0]);
-                }
+                hCFDvsLED[cc][mip]->Fill(allData[cc+13][iHt]-allData[cc+1][iHt],allData[cc+1][iHt]-allData[0][0]+5000);
+               }
        }
 
       for (Int_t ik = 24; ik<48; ik+=2)
-         for (Int_t iHt=0; iHt<5; iHt++){
+         for (Int_t iHt=0; iHt<1; iHt++){
                 Int_t cc = ik/2;
-                if((allData[cc+45][iHt]-allData[0][0])>0){
-                 hCFD[cc]->Fill(allData[cc+45][iHt]-allData[0][0]);
-                }
-
-                if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0){
-                if(allData[cc+45][iHt]!=0)
-                 hCFD_QTC[cc]->Fill(allData[ik+57][iHt]-allData[ik+58][iHt],allData[cc+45][iHt]-allData[0][0]);
-                }
+                if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0 && allData[cc+45][iHt]!=0){
+                 hCFDvsQTC[cc][mip]->Fill(allData[ik+57][iHt]-allData[ik+58][iHt],allData[cc+45][iHt]-allData[0][0]+5000);
+               }
                 if(allData[cc+57][iHt]!=0 && allData[cc+45][iHt]!=0){
-                 hCFD_LED[cc]->Fill(allData[cc+57][iHt]-allData[cc+45][iHt],allData[cc+45][iHt]-allData[0][0]);
-                 }
+                 hCFDvsLED[cc][mip]->Fill(allData[cc+57][iHt]-allData[cc+45][iHt],allData[cc+45][iHt]-allData[0][0]+5000);
+                }
        }
-
-       
+      
      delete start;
        start = 0x0;
      reader->Reset();
@@ -216,29 +245,36 @@ int main(int argc, char **argv) {
 
     }
 
-
-
     /* free resources */
     free(event);
     
     /* exit when last event received, no need to wait for TERM signal */
     if (eventT==END_OF_RUN) {
       printf("EOR event detected\n");
+      printf("Number of events processed - %i\n ",iev);
       break;
     }
   }
-printf("After loop, before writing histos\n");
+  printf("After loop, before writing histos\n");
   // write a file with the histograms
   TFile *hist = new TFile(FILE_OUT,"RECREATE");
 
-  for(Int_t j=0;j<24;j++){
-     hCFD_QTC[j]->Write();
-     hCFD_LED[j]->Write();
-     hCFD[j]->Write();
+  for(Int_t j=0;j<24;j++)
+   for(Int_t k=0;k<10;k++)
+    {
+     hCFDvsQTC[j][k]->Write();
+     hCFDvsLED[j][k]->Write();
     }
   hist->Close();
   delete hist;
 
+  status=0;
+
+  /* export file to FXS */
+  if (daqDA_FES_storeFile(FILE_OUT, "LASER")) {
+    status=-2;
+  }
+
   return status;
 }