<commit_before>/*

TOF DA for online calibration

*/

#define FILE_TOTAL "TOFdaTotal.root"
#define FILE_RUN "TOFdaRun.root"

// DATE
extern "C" {
#include <daqDA.h>
}
#include <event.h>
#include <monitor.h>

//AliRoot
#include <AliTOFRawStream.h>
#include <AliRawReaderDate.h>
#include <AliRawReader.h>
#include <AliTOFGeometry.h>
#include <AliTOFGeometryV5.h>
#include <AliT0RawReader.h>
#include <AliDAQ.h>
#include <AliTOFHitData.h>
#include <AliTOFHitDataBuffer.h>

//ROOT
#include <TFile.h>
#include <TKey.h>
#include <TH2S.h>
#include <TObject.h>
#include <TMath.h>
#include <TSystem.h>


/* Main routine
      Arguments: 
      1- monitoring data source
*/

int main(int argc, char **argv) {
  
  AliTOFGeometry * geomV5 = new AliTOFGeometryV5();
  AliTOFGeometry * geom = new AliTOFGeometry();

  static const Int_t size = geomV5->NPadXSector()*geomV5->NSectors();
  static const Int_t nbins = 500;
  static const Int_t binmin = -20;
  const Float_t c = 2.99792458E10; //speed of light
  TH1F::AddDirectory(0);
  TH2S * htofPartial = new TH2S("htof","histo with delays", size,-0.5,size*1.-0.5,nbins,binmin-0.5,nbins*1.+binmin-0.5);
  
  // decoding the events
  
  int status;
  if (argc!=2) {
    printf("Wrong number of arguments\n");
    return -1;
  }

  /* define data source : this is argument 1 */  
  status=monitorSetDataSource( argv[1] );
  if (status!=0) {
    printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
    return -1;
  }

  /* declare monitoring program */
  status=monitorDeclareMp( __FILE__ );
  if (status!=0) {
    printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
    return -1;
  }

  /* define wait event timeout - 1s max */
  monitorSetNowait();
  monitorSetNoWaitNetworkTimeout(1000);
  
  /* log start of process */
  printf("TOF DA started\n");  

  /* init some counters */
  int nevents_physics=0;
  int nevents_total=0;

  struct eventHeaderStruct *event;
  eventTypeType eventT;
  Int_t iev=0;

  /* main loop (infinite) */
  for(;;) {
    
    /* check shutdown condition */
    if (daqDA_checkShutdown()) {break;}
    
    /* get next event (blocking call until timeout) */
    status=monitorGetEventDynamic((void **)&event);
    if (status==MON_ERR_EOF) {
      printf ("End of File detected\n");
      break; /* end of monitoring file has been reached */
    }
    
    if (status!=0) {
      printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
      break;
    }
    
    /* retry if got no event */
    if (event==NULL) {
      continue;
    }

    iev++; 

   /* use event - here, just write event id to result file */
    nevents_total++;
    eventT=event->eventType;
    switch (event->eventType){
      
      /* START OF RUN */
    case START_OF_RUN:
      break;
      /* END START OF RUN */
      
    /* END OF RUN */
    case END_OF_RUN:
      break;
      
    case PHYSICS_EVENT:
      nevents_physics++;
      AliRawReader *rawReader = new AliRawReaderDate((void*)event);
      //rawReader->RequireHeader(kFALSE);

      //T0 event
      Int_t meantime = 0;     
      AliT0RawReader *rawReaderT0 = new AliT0RawReader(rawReader);
      if (!rawReaderT0->Next()) {
        printf("T0: no raw data found!\n");
      } else {<commit_msg>fix for accessing T0 data (C.Zampolli)<commit_after>/*

TOF DA for online calibration

*/

#define FILE_TOTAL "TOFdaTotal.root"
#define FILE_RUN "TOFdaRun.root"

// DATE
#include <daqDA.h>
#include <event.h>
#include <monitor.h>

//AliRoot
#include <AliTOFRawStream.h>
#include <AliRawReaderDate.h>
#include <AliRawReader.h>
#include <AliTOFGeometry.h>
#include <AliTOFGeometryV5.h>
#include <AliT0RawReader.h>
#include <AliDAQ.h>
#include <AliTOFHitData.h>
#include <AliTOFHitDataBuffer.h>

//ROOT
#include <TFile.h>
#include <TKey.h>
#include <TH2S.h>
#include <TObject.h>
#include <TMath.h>
#include <TSystem.h>


/* Main routine
      Arguments: 
      1- monitoring data source
*/

int main(int argc, char **argv) {
  
  AliTOFGeometry * geomV5 = new AliTOFGeometryV5();
  AliTOFGeometry * geom = new AliTOFGeometry();

  static const Int_t size = geomV5->NPadXSector()*geomV5->NSectors();
  static const Int_t nbins = 500;
  static const Int_t binmin = -20;
  const Float_t c = 2.99792458E10; //speed of light
  TH1F::AddDirectory(0);
  TH2S * htofPartial = new TH2S("htof","histo with delays", size,-0.5,size*1.-0.5,nbins,binmin-0.5,nbins*1.+binmin-0.5);
  
  // decoding the events
  
  int status;
  if (argc!=2) {
    printf("Wrong number of arguments\n");
    return -1;
  }

  /* define data source : this is argument 1 */  
  status=monitorSetDataSource( argv[1] );
  if (status!=0) {
    printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
    return -1;
  }

  /* declare monitoring program */
  status=monitorDeclareMp( __FILE__ );
  if (status!=0) {
    printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
    return -1;
  }

  /* define wait event timeout - 1s max */
  monitorSetNowait();
  monitorSetNoWaitNetworkTimeout(1000);
  
  /* log start of process */
  printf("TOF DA started\n");  

  /* init some counters */
  int nevents_physics=0;
  int nevents_total=0;

  struct eventHeaderStruct *event;
  eventTypeType eventT;
  Int_t iev=0;

  /* main loop (infinite) */
  for(;;) {
    
    /* check shutdown condition */
    if (daqDA_checkShutdown()) {break;}
    
    /* get next event (blocking call until timeout) */
    status=monitorGetEventDynamic((void **)&event);
    if (status==MON_ERR_EOF) {
      printf ("End of File detected\n");
      break; /* end of monitoring file has been reached */
    }
    
    if (status!=0) {
      printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
      break;
    }
    
    /* retry if got no event */
    if (event==NULL) {
      continue;
    }

    iev++; 

   /* use event - here, just write event id to result file */
    nevents_total++;
    eventT=event->eventType;
    switch (event->eventType){
      
      /* START OF RUN */
    case START_OF_RUN:
      break;
      /* END START OF RUN */
      
    /* END OF RUN */
    case END_OF_RUN:
      break;
      
    case PHYSICS_EVENT:
      nevents_physics++;
      AliRawReader *rawReader = new AliRawReaderDate((void*)event);
      //rawReader->RequireHeader(kFALSE);

      //T0 event
      Int_t meantime = 0;     
      AliT0RawReader *rawReaderT0 = new AliT0RawReader(rawReader);
      rawReaderT0->SetOnlineMode(kTRUE);
      if (!rawReaderT0->Next()) {
        printf("T0: no raw data found!\n");
      } else {
{'fraction_non_alphanumeric': 0.13853866018532585, 'fraction_numerical': 0.019140209630867384, 'mean_word_length': 2.987886129618413, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6147561', 'n_tokens_mistral': 2417, 'n_tokens_neox': 2280, 'n_words': 558}