Exemple #1
0
int GetTemp(float *fTemp) {
  FILE *sysfile;
  char  strRead[kSTRMAX];
  int  nRaw, nRet;

  *fTemp = 0.0;

  if(nOffset == 0 || fScale == 0.0) {

    nRet = GetConstants();
    if(nRet)
      return nRet;
  }

  if((sysfile = fopen(kXADCPATH "in_temp0_raw", "ra")) == NULL) {
    fprintf(stderr, "ERROR: Can't open raw temp device file\n");
    return 3;
  }

  fgets(strRead, kSTRMAX-1, sysfile);
  fclose(sysfile);
  nRaw = atoi(strRead);

  *fTemp = (nRaw + nOffset) * fScale / 1000.;

  return 0;
}
FMalloc* FMacPlatformMemory::BaseAllocator()
{
	FMalloc* Malloc = nullptr;
	
#if FORCE_ANSI_ALLOCATOR
	Malloc = new FMallocAnsi();
#elif (WITH_EDITORONLY_DATA || IS_PROGRAM) && TBB_ALLOCATOR_ALLOWED
	Malloc = new FMallocTBB();
#else
	Malloc = new FMallocBinned((uint32)(GetConstants().PageSize&MAX_uint32), 0x100000000);
#endif
	
	// Configure CoreFoundation's default allocator to use our allocation routines too.
	CFAllocatorContext AllocatorContext;
	AllocatorContext.version = 0;
	AllocatorContext.info = nullptr;
	AllocatorContext.retain = nullptr;
	AllocatorContext.release = nullptr;
	AllocatorContext.copyDescription = nullptr;
	AllocatorContext.allocate = &FMacAllocatorAllocate;
	AllocatorContext.reallocate = &FMacAllocatorReallocate;
	AllocatorContext.deallocate = &FMacAllocatorDeallocate;
	AllocatorContext.preferredSize = &FMacAllocatorPreferredSize;
	
	CFAllocatorRef Alloc = CFAllocatorCreate(kCFAllocatorDefault, &AllocatorContext);
	CFAllocatorSetDefault(Alloc);
	
	return Malloc;
}
FMalloc* FMacPlatformMemory::BaseAllocator()
{
#if FORCE_ANSI_ALLOCATOR
	return new FMallocAnsi();
#elif WITH_EDITOR && TBB_ALLOCATOR_ALLOWED
	return new FMallocTBB();
#else
	return new FMallocBinned((uint32)(GetConstants().PageSize&MAX_uint32), 0x100000000);
#endif
}
void execTriggerTypedefs(){

   auto en = TEnum::GetEnum("trigger::TriggerObjectType");
   auto constants = en->GetConstants();

   if (!en){
      std::cerr << "No enumerator found!\n";
      return ;
   }

   std::cout << "Enum: " << en->GetName() << std::endl;

   for (auto constantAsObj : *constants){
      auto constant = (TEnumConstant*) constantAsObj;
      std::cout << " - Constant " << constant->GetName() << " has value " << constant->GetValue() << std::endl;
   }

}
Exemple #5
0
void hitForwardEMcal (float xin[4], float xout[4],
                      float pin[5], float pout[5], float dEsum,
                      int track, int stack, int history, int ipart)
{
    float x[3], t;
    float xfcal[3];

    if (!initialized) {

        mystr_t strings[50];
        float values[50];
        int nvalues = 50;
        int status = GetConstants("FCAL/fcal_parms", &nvalues, values, strings);

        if (!status) {

            int ncounter = 0;
            int i;
            for ( i=0; i<(int)nvalues; i++) {
                //printf("%d %s \n",i,strings[i].str);
                if (!strcmp(strings[i].str,"FCAL_ATTEN_LENGTH")) {
                    ATTEN_LENGTH  = values[i];
                    ncounter++;
                }

                if (!strcmp(strings[i].str,"FCAL_C_EFFECTIVE")) {
                    C_EFFECTIVE  = values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_WIDTH_OF_BLOCK")) {
                    WIDTH_OF_BLOCK  = values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_LENGTH_OF_BLOCK")) {
                    LENGTH_OF_BLOCK  = values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_TWO_HIT_RESOL")) {
                    TWO_HIT_RESOL  = values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_MAX_HITS")) {
                    FCAL_MAX_HITS  = (int)values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_THRESH_MEV")) {
                    THRESH_MEV  = values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_ACTIVE_RADIUS")) {
                    ACTIVE_RADIUS  = values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_CENTRAL_ROW")) {
                    CENTRAL_ROW  = (int)values[i];
                    ncounter++;
                }
                if (!strcmp(strings[i].str,"FCAL_CENTRAL_COLUMN")) {
                    CENTRAL_COLUMN  = (int)values[i];
                    ncounter++;
                }
            }
            const int nparams=10;
            if (ncounter==nparams) {
                printf("FCAL: ALL parameters loaded from Data Base\n");
            } else if (ncounter<nparams) {
                printf("FCAL: NOT ALL necessary parameters found in Data Base %d out of %d\n",ncounter,nparams);
            } else {
                printf("FCAL: SOME parameters found more than once in Data Base\n");
            }
        }
        initialized = 1;
    }

    x[0] = (xin[0] + xout[0])/2;
    x[1] = (xin[1] + xout[1])/2;
    x[2] = (xin[2] + xout[2])/2;
    t    = (xin[3] + xout[3])/2 * 1e9;
    transformCoord(x,"global",xfcal,"FCAL");

    /* post the hit to the truth tree */

    if ((history == 0) && (pin[3] > THRESH_MEV/1e3))
    {
        s_FcalTruthShowers_t* showers;
        int mark = (1<<30) + showerCount;
        void** twig = getTwig(&forwardEMcalTree, mark);
        if (*twig == 0)
        {
            s_ForwardEMcal_t* cal = *twig = make_s_ForwardEMcal();
            cal->fcalTruthShowers = showers = make_s_FcalTruthShowers(1);
            int a = thisInputEvent->physicsEvents->in[0].reactions->in[0].vertices->in[0].products->mult;
            showers->in[0].primary = (stack <= a);
            showers->in[0].track = track;
            showers->in[0].t = xin[3]*1e9;
            showers->in[0].x = xin[0];
            showers->in[0].y = xin[1];
            showers->in[0].z = xin[2];
            showers->in[0].px = pin[0]*pin[4];
            showers->in[0].py = pin[1]*pin[4];
            showers->in[0].pz = pin[2]*pin[4];
            showers->in[0].E = pin[3];
            showers->in[0].ptype = ipart;
            showers->in[0].trackID = make_s_TrackID();
            showers->in[0].trackID->itrack = gidGetId(track);
            showers->mult = 1;
            showerCount++;
        }
    }

    /* post the hit to the hits tree, mark block as hit */

    if (dEsum > 0)
    {
        int nhit;
        s_FcalTruthHits_t* hits;
        int row = getrow_wrapper_();
        int column = getcolumn_wrapper_();

        float dist = 0.5*LENGTH_OF_BLOCK-xfcal[2];
        float dEcorr = dEsum * exp(-dist/ATTEN_LENGTH);



        float tcorr = t + dist/C_EFFECTIVE;
        int mark = ((row+1)<<16) + (column+1);
        void** twig = getTwig(&forwardEMcalTree, mark);
        if (*twig == 0)
        {
            s_ForwardEMcal_t* cal = *twig = make_s_ForwardEMcal();
            s_FcalBlocks_t* blocks = make_s_FcalBlocks(1);
            blocks->mult = 1;
            blocks->in[0].row = row;
            blocks->in[0].column = column;
            blocks->in[0].fcalTruthHits = hits = make_s_FcalTruthHits(MAX_HITS);
            cal->fcalBlocks = blocks;
            blockCount++;
        }
        else
        {
            s_ForwardEMcal_t* cal = *twig;
            hits = cal->fcalBlocks->in[0].fcalTruthHits;
        }

        for (nhit = 0; nhit < hits->mult; nhit++)
        {
            if (fabs(hits->in[nhit].t - tcorr) < TWO_HIT_RESOL)
            {
                break;
            }
        }
        if (nhit < hits->mult)		/* merge with former hit */
        {
            hits->in[nhit].t =
                (hits->in[nhit].t * hits->in[nhit].E + tcorr*dEcorr)
                / (hits->in[nhit].E + dEcorr);
            hits->in[nhit].E += dEcorr;
        }
        else if (nhit < MAX_HITS)         /* create new hit */
        {
            hits->in[nhit].t = tcorr;
            hits->in[nhit].E = dEcorr;
            hits->mult++;
        }
        else
        {
            fprintf(stderr,"HDGeant error in hitforwardEMcal: ");
            fprintf(stderr,"max hit count %d exceeded, truncating!\n",MAX_HITS);
            exit(2);
        }
    }
}
Exemple #6
0
void hitStartCntr (float xin[4], float xout[4],
                   float pin[5], float pout[5], float dEsum,
                    int track, int stack, int history, int ipart)
{     
   float x[3], t;
   float dx[3], dr;
   float dEdx;
   float xlocal[3];

   if (!initialized) {

    mystr_t strings[50];
    float values[50];
    int nvalues = 50;
    int status = GetConstants("START_COUNTER/start_parms", &nvalues, values, strings);

    if (!status) {
      int ncounter = 0;
      int i;
      for ( i=0;i<(int)nvalues;i++){
        //printf("%d %s \n", i, strings[i].str);
        if (!strcmp(strings[i].str,"START_ATTEN_LENGTH")) {
          ATTEN_LENGTH  = values[i];
          ncounter++;
        }
        if (!strcmp(strings[i].str,"START_C_EFFECTIVE")) {
          C_EFFECTIVE  = values[i];
          ncounter++;
        }
        if (!strcmp(strings[i].str,"START_TWO_HIT_RESOL")) {
          TWO_HIT_RESOL  = values[i];
          ncounter++;
        }
        if (!strcmp(strings[i].str,"START_MAX_HITS")) {
          START_MAX_HITS  = (int)values[i];
          ncounter++;
        }
        if (!strcmp(strings[i].str,"START_THRESH_MEV")) {
          THRESH_MEV  = values[i];
          ncounter++;
        }
        if (!strcmp(strings[i].str,"START_LIGHT_GUIDE")) {
          LIGHT_GUIDE  = values[i];
          ncounter++;
        }
        if (!strcmp(strings[i].str,"START_ANGLE_COR")) {
          ANGLE_COR  = values[i];
          ncounter++;
        }
        if (!strcmp(strings[i].str,"START_BENT_REGION")) {
          BENT_REGION  = values[i];
          ncounter++;
        }
      }
      if (ncounter==8){
        printf("START: ALL parameters loaded from Data Base\n");
      } else if (ncounter<8){
        printf("START: NOT ALL necessary parameters found in Data Base %d out of 8\n",ncounter);
      } else {
        printf("START: SOME parameters found more than once in Data Base\n");
      }
    }

    // Attenuations correction constants for straight section
    int sc_straight_attenuation_a = GetColumn("START_COUNTER/attenuation_factor", &NCHANNELS, SC_STRAIGHT_ATTENUATION_A, "SC_STRAIGHT_ATTENUATION_A");
    if (sc_straight_attenuation_a) 
      printf("ERROR LOADING SC_STRAIGHT_ATTENUATION_A from START_COUNTER/attenuation_factor");
    int sc_straight_attenuation_b = GetColumn("START_COUNTER/attenuation_factor", &NCHANNELS, SC_STRAIGHT_ATTENUATION_B, "SC_STRAIGHT_ATTENUATION_B");
    if (sc_straight_attenuation_b) 
      printf("ERROR LOADING SC_STRAIGHT_ATTENUATION_B from START_COUNTER/attenuation_factor");
    int sc_straight_attenuation_c = GetColumn("START_COUNTER/attenuation_factor", &NCHANNELS, SC_STRAIGHT_ATTENUATION_C, "SC_STRAIGHT_ATTENUATION_C");
    if (sc_straight_attenuation_c) 
      printf("ERROR LOADING SC_STRAIGHT_ATTENUATION_C from START_COUNTER/attenuation_factor");

    // Attenuation correction constants for bend/nose section
    int sc_bendnose_attenuation_a = GetColumn("START_COUNTER/attenuation_factor", &NCHANNELS, SC_BENDNOSE_ATTENUATION_A, "SC_BENDNOSE_ATTENUATION_A");
    if (sc_bendnose_attenuation_a) 
      printf("ERROR LOADING SC_BENDNOSE_ATTENUATION_A from START_COUNTER/attenuation_factor");
    int sc_bendnose_attenuation_b = GetColumn("START_COUNTER/attenuation_factor", &NCHANNELS, SC_BENDNOSE_ATTENUATION_B, "SC_BENDNOSE_ATTENUATION_B");
    if (sc_bendnose_attenuation_b) 
      printf("ERROR LOADING SC_BENDNOSE_ATTENUATION_B from START_COUNTER/attenuation_factor");
    int sc_bendnose_attenuation_c = GetColumn("START_COUNTER/attenuation_factor", &NCHANNELS, SC_BENDNOSE_ATTENUATION_C, "SC_BENDNOSE_ATTENUATION_C");
    if (sc_bendnose_attenuation_c) 
      printf("ERROR LOADING SC_BENDNOSE_ATTENUATION_C from START_COUNTER/attenuation_factor");

    // Propagation time correction constants for straight section
    int sc_straight_propagation_a = GetColumn("START_COUNTER/propagation_speed", &NCHANNELS, SC_STRAIGHT_PROPAGATION_A, "SC_STRAIGHT_PROPAGATION_A");
    if (sc_straight_propagation_a) 
      printf("ERROR LOADING SC_STRAIGHT_PROPAGATION_A from START_COUNTER/propagation_speed");
    int sc_straight_propagation_b = GetColumn("START_COUNTER/propagation_speed", &NCHANNELS, SC_STRAIGHT_PROPAGATION_B, "SC_STRAIGHT_PROPAGATION_B");
    if (sc_straight_propagation_b) 
      printf("ERROR LOADING SC_STRAIGHT_PROPAGATION_B from START_COUNTER/propagation_speed");

    // Propagation time correction constants for bend section
    int sc_bend_propagation_a = GetColumn("START_COUNTER/propagation_speed", &NCHANNELS, SC_BEND_PROPAGATION_A, "SC_BEND_PROPAGATION_A");
    if (sc_bend_propagation_a) 
      printf("ERROR LOADING SC_BEND_PROPAGATION_A from START_COUNTER/propagation_speed");
    int sc_bend_propagation_b = GetColumn("START_COUNTER/propagation_speed", &NCHANNELS, SC_BEND_PROPAGATION_B, "SC_BEND_PROPAGATION_B");
    if (sc_bend_propagation_b) 
      printf("ERROR LOADING SC_BEND_PROPAGATION_B from START_COUNTER/propagation_speed");

    // Propagation time correction constants for nose section
    int sc_nose_propagation_a = GetColumn("START_COUNTER/propagation_speed", &NCHANNELS, SC_NOSE_PROPAGATION_A, "SC_NOSE_PROPAGATION_A");
    if (sc_nose_propagation_a) 
      printf("ERROR LOADING SC_NOSE_PROPAGATION_A from START_COUNTER/propagation_speed");
    int sc_nose_propagation_b = GetColumn("START_COUNTER/propagation_speed", &NCHANNELS, SC_NOSE_PROPAGATION_B, "SC_NOSE_PROPAGATION_B");
    if (sc_nose_propagation_b) 
      printf("ERROR LOADING SC_NOSE_PROPAGATION_B from START_COUNTER/propagation_speed");

    initialized = 1;
   }

   x[0] = (xin[0] + xout[0])/2;
   x[1] = (xin[1] + xout[1])/2;
   x[2] = (xin[2] + xout[2])/2;
   t    = (xin[3] + xout[3])/2 * 1e9;
   transformCoord(x,"global",xlocal,"local");
   dx[0] = xin[0] - xout[0];
   dx[1] = xin[1] - xout[1];
   dx[2] = xin[2] - xout[2];
   dr = sqrt(dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]);
   if (dr > 1e-3)
   {
      dEdx = dEsum/dr;
   }
   else
   {
      dEdx = 0;
   }

   /* float dbent  = 0.0; */
   /* float dpath  = 0.0; */
   /* if(xlocal[2] >= BENT_REGION){ */
   /*   dbent = ( xlocal[2] - BENT_REGION )*ANGLE_COR; */
   /*   dpath = BENT_REGION + dbent; */
   /* } else { */
   /*   dpath  = xlocal[2]; */
   /* } */

   /* float dEcorr = dEsum * exp(-dpath/ATTEN_LENGTH); */
   /* float tcorr  = t + dpath/C_EFFECTIVE; */


   //   printf("x_gl, z_gl, x_l, z_l %f %f %f\n",
   //  	  xin[0],xin[1],xin[2]);

   //   printf("x_gl, z_gl, x_l, z_l %f %f %f %f %f %f %f\n",
   //  	  x[0],x[1],x[2], xlocal[0],xlocal[1],xlocal[2],dpath);


   /* post the hit to the truth tree */

   if (history == 0)
   {
      int mark = (1<<30) + pointCount;
      void** twig = getTwig(&startCntrTree, mark);
      if (*twig == 0)
      {
         s_StartCntr_t* stc = *twig = make_s_StartCntr();
         s_StcTruthPoints_t* points = make_s_StcTruthPoints(1);
         stc->stcTruthPoints = points;
	 int a = thisInputEvent->physicsEvents->in[0].reactions->in[0].vertices->in[0].products->mult;
         points->in[0].primary = (stack <= a);
         points->in[0].track = track;
         points->in[0].t = t;
         points->in[0].z = x[2];
         points->in[0].r = sqrt(x[0]*x[0]+x[1]*x[1]);
         points->in[0].phi = atan2(x[1],x[0]);
         points->in[0].px = pin[0]*pin[4];
         points->in[0].py = pin[1]*pin[4];
         points->in[0].pz = pin[2]*pin[4];
         points->in[0].E = pin[3];
	 points->in[0].dEdx = dEdx;
	 points->in[0].ptype = ipart;
         points->in[0].sector = getsector_wrapper_();
         points->in[0].trackID = make_s_TrackID();
         points->in[0].trackID->itrack = gidGetId(track);
         points->mult = 1;
         pointCount++;
      }
   }

   /* post the hit to the hits tree, mark sector as hit */

   //   if( (ipart==8) && (x[2]<90.)){
   //     printf("x_gl, z_gl, x_l, z_l %f %f %f %f %f %f\n",
   //	    x[0],x[1],x[2], xlocal[0],xlocal[1],xlocal[2]);
   //   }


   if (dEsum > 0)
   {
      int nhit;
      s_StcTruthHits_t* hits;
      int sector = getsector_wrapper_();
       
      //      printf("x_gl, z_gl, x_l, z_l %f %f %f %f %f %f\n",
      //  x[0],x[1],x[2], xlocal[0],xlocal[1],xlocal[2]);
      
      float dbent  = 0.0;
      float dpath  = 0.0;
      if(xlocal[2] >= BENT_REGION){
      	dbent = ( xlocal[2] - BENT_REGION )*ANGLE_COR;
      	dpath = BENT_REGION + dbent;
      } else {
      	dpath  = xlocal[2];
      }

      /* float dEcorr = dEsum * exp(-dpath/ATTEN_LENGTH); */
      /* float tcorr  = t + dpath/C_EFFECTIVE; */

      /* printf("\n Sector %d Fired \n t = %.5f \n dEsum = %.5f \n dpath = %.5f \n",  */
      /* 	     sector, t, dEsum, dpath); */

      int sector_index = sector - 1;
      float dEcorr = 9.9E+9;
      float tcorr  = 9.9E+9;
      
      if (xlocal[2] <= STRAIGHT_LENGTH)
	{
	  dEcorr = dEsum * exp(dpath*SC_STRAIGHT_ATTENUATION_B[sector_index]);
	  tcorr  = t + dpath * SC_STRAIGHT_PROPAGATION_B[sector_index] + SC_STRAIGHT_PROPAGATION_A[sector_index];

	  /* printf("HIT OCCURED IN STRAIGHT SECTION \n"); */
	  /* printf("Attenuation Corrections: A = %.5f, B = %.5f, C = %.5f \n", SC_STRAIGHT_ATTENUATION_A[sector_index], SC_STRAIGHT_ATTENUATION_B[sector_index], SC_STRAIGHT_ATTENUATION_C[sector_index]); */
	  /* printf("Time Corrections: B = %.5f, A = %.5f \n", SC_STRAIGHT_PROPAGATION_B[sector_index], SC_STRAIGHT_PROPAGATION_A[sector_index]);  */
	}
      else if (xlocal[2] > STRAIGHT_LENGTH && xlocal[2] <= (STRAIGHT_LENGTH + BEND_LENGTH))
	{
	  dEcorr = dEsum * ((SC_BENDNOSE_ATTENUATION_A[sector_index] * exp(dpath*SC_BENDNOSE_ATTENUATION_B[sector_index]) + SC_BENDNOSE_ATTENUATION_C[sector_index]) / 
				  SC_STRAIGHT_ATTENUATION_A[sector_index]);
	  tcorr  = t + dpath * SC_BEND_PROPAGATION_B[sector_index] + SC_BEND_PROPAGATION_A[sector_index];

	  /* printf("HIT OCCURED IN BEND SECTION \n"); */
	  /* printf("Attenuation Corrections: A = %.5f, B = %.5f, C = %.5f \n", SC_BENDNOSE_ATTENUATION_A[sector_index], SC_BENDNOSE_ATTENUATION_B[sector_index], SC_BENDNOSE_ATTENUATION_C[sector_index]); */
	  /* printf("Time Corrections: B = %.5f,  A = %.5f \n", SC_BEND_PROPAGATION_B[sector_index], SC_BEND_PROPAGATION_A[sector_index]);  */
	}
      else if (xlocal[2] > (STRAIGHT_LENGTH + BEND_LENGTH) && xlocal[2] <= (STRAIGHT_LENGTH + BEND_LENGTH + NOSE_LENGTH))
	{
	  dEcorr = dEsum * ((SC_BENDNOSE_ATTENUATION_A[sector_index] * exp(dpath*SC_BENDNOSE_ATTENUATION_B[sector_index]) + SC_BENDNOSE_ATTENUATION_C[sector_index]) / 
				  SC_STRAIGHT_ATTENUATION_A[sector_index]);
	  
	  tcorr  = t + dpath * SC_NOSE_PROPAGATION_B[sector_index] + SC_NOSE_PROPAGATION_A[sector_index];

	  /* printf("HIT OCCURED IN NOSE SECTION \n"); */
	  /* printf("Attenuation Corrections: A = %.5f, B = %.5f, C = %.5f \n", SC_BENDNOSE_ATTENUATION_A[sector_index], SC_BENDNOSE_ATTENUATION_B[sector_index], SC_BENDNOSE_ATTENUATION_C[sector_index]); */
	  /* printf("Time Corrections: B = %.5f,  A = %.5f \n", SC_NOSE_PROPAGATION_B[sector_index], SC_NOSE_PROPAGATION_A[sector_index]); */ 
	}
      else return;

      /* printf("tcorr = %.5f \n dEcorr = %.5f \n", tcorr, dEcorr); */
    
      //      float dpath = xlocal[2]+(10.2-xlocal[0])*0.4;
      //      float tcorr = t + dpath/C_EFFECTIVE;
      //      float dEcorr = dEsum * exp(-dpath/ATTEN_LENGTH);
      int mark = sector;
      void** twig = getTwig(&startCntrTree, mark);
      if (*twig == 0)
      {
         s_StartCntr_t* stc = *twig = make_s_StartCntr();
         s_StcPaddles_t* paddles = make_s_StcPaddles(1);
         paddles->mult = 1;
         paddles->in[0].sector = sector;
         paddles->in[0].stcTruthHits = hits = make_s_StcTruthHits(MAX_HITS);
         stc->stcPaddles = paddles;
         paddleCount++;
      }
      else
      {
         s_StartCntr_t* stc = *twig;
         hits = stc->stcPaddles->in[0].stcTruthHits;
      }

      for (nhit = 0; nhit < hits->mult; nhit++)
      {
         if (fabs(hits->in[nhit].t - tcorr) < TWO_HIT_RESOL)
         {
            break;
         }
      }
      if (nhit < hits->mult)		/* merge with former hit */
      {
         if (tcorr < hits->in[nhit].t)
         {
            hits->in[nhit].ptype = ipart;
            hits->in[nhit].itrack = gidGetId(track);
         }
         hits->in[nhit].t = 
                 (hits->in[nhit].t * hits->in[nhit].dE + tcorr * dEcorr) /
                 (hits->in[nhit].dE + dEcorr);
			hits->in[nhit].dE += dEcorr;
      }
      else if (nhit < MAX_HITS)		/* create new hit */
      {
         hits->in[nhit].t = tcorr ;
         hits->in[nhit].dE = dEcorr;
         hits->in[nhit].ptype = ipart;
         hits->in[nhit].itrack = gidGetId(track);
         hits->mult++;
      }
      else
      {
         fprintf(stderr,"HDGeant error in hitStart: ");
         fprintf(stderr,"max hit count %d exceeded, truncating!\n",MAX_HITS);
         exit(2);
      }
   }
}
Exemple #7
0
int main(int argc, char **argv) {
  pthread_t   tidUpdate;
  int         nFlag, nQuit=0, c;
  KeySym      key;
  char        str[kSTRMAX];

  opterr = 0;
     
  while ((c = getopt (argc, argv, "hl:w:r:")) != -1) {
    switch (c) {

    case 'h':
      Usage();
      return 0;

    case 'l':
      fTempLimit = atof(optarg);
      break;
	
    case 'w':
      fTempWarn = atof(optarg);
      break;

    case 'r':
      nSleepSecs = atoi(optarg);
      break;

    case '?':
      if (optopt == 'l' || optopt == 'w' || optopt == 'r')
	fprintf (stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint (optopt))
	fprintf (stderr, "Unknown option `-%c'.\n", optopt);
      else
	fprintf (stderr,
		 "Unknown option character `\\x%x'.\n",
		 optopt);
      return 1;

    default:
      abort ();
    }
  }
  
  XInitThreads();

  if(InitX()) {
    return 1;
  } if(GetConstants()) {
    return 2;
  } if(pthread_create(&tidUpdate, NULL, &UpdateThread, NULL)) {
    fprintf(stderr, "ERROR: Can't create update thread.\n");
    return 3;
  }

  float fTemp;
  GetTemp(&fTemp);
  printf("Current Temp = %.1f\n", fTemp);

  while(1) {
    XEvent e;
    XNextEvent(dpy, &e);

    nFlag = 0;
    switch(e.type) {

    case Expose:
      nFlag = 1;
      break;

    case ClientMessage:
      
      if(e.xclient.data.l[0] == 42) {
	nFlag = 1;
      } else if(e.xclient.data.l[0] == wmDeleteMessage) {
	XDestroyWindow(dpy, e.xclient.window);
	nQuit = 1;
      }
      break;

    case KeyPress:
      if(XLookupString(&e.xkey, str, kSTRMAX-1, &key, 0)==1) {
	if(str[0] == 'q' || str[0] == 'Q') {
	  XDestroyWindow(dpy, win);
	  nQuit = 1;
	}
      }
      break;

    case ConfigureNotify:
      break;
    
    }

    if(nQuit)
      break;

    if(nFlag) {

      int rc = Redraw();
      if(rc) {
	fprintf(stderr, "ERROR: Redraw() returned %d\n", rc);
	break;
      }
    }
  }

  XCloseDisplay(dpy);
  pthread_kill(tidUpdate, 1);
  pthread_exit(NULL);
}