示例#1
0
/*---------------------------------------------------------------*/
SiliconData *MMMSiliconSort(float *ADC_import, int ntdc, int *TDC_channel_import, float *TDC_value_import)
{
  SiliconData *si = new SiliconData();

  //Loop over ADC and TDC events and do the following:
  //Check whether there are front-back coincidences for a detector and test the energies
  //Check to see whether there's a TDC event for the same channel as the front hit ADC - TDCs are apparently in single-hit mode. Don't need to worry about multihits
  //Calculate the theta and phi for the valid events
  multiTDC mTDC;// = new multiTDC();
  mTDC.multiTDCSort(ntdc, TDC_channel_import, TDC_value_import);

  for(int k=0;k<mTDC.GetSize();k++)//Loop over all of the TDC values - there should only be a small number of these relative to the ADC values
  {
    if(MMMTDCFrontTest(mTDC.GetChannel(k)))
      {
	for(int l=0;l<mTDC.GetSize();l++)//Loop over all of the TDC values *again* but in this case, looking for the N sides
	  {
	    if(MMMTDCBackTest(mTDC.GetChannel(l)) && MMMTDCFrontBackTest(mTDC.GetChannel(k),mTDC.GetChannel(l)))
	      {
		int DetNum = MMMTDCIdentifyDetector(mTDC.GetChannel(k),mTDC.GetChannel(l));
		if(DetNum>0)
		  {	
		    for(int i=MMMADCChannelLimits[DetNum-1][0];i<=MMMADCChannelLimits[DetNum-1][1];i++)
		      {
			//Don't want to run for events w
			if(MMMADCTDCChannelTestPSide(i,mTDC.GetChannel(k)) && ADC_import[i]>0)
			  {
			    for(int j=MMMADCChannelLimits[DetNum-1][2];j<=MMMADCChannelLimits[DetNum-1][3];j++)
			      {
				if(ADC_import[j]>0)
				  {
				    double energyi = MMMEnergyCalc(i,ADC_import[i]);
				    double energyj = MMMEnergyCalc(j,ADC_import[j]);
				    
				    //Test whether the hits are in the front and back of the same detector and whether the energies are good
				    if(MMMFrontBackTest(i,j,energyi,energyj,si) && MMMADCTDCChannelTestNSide(j,mTDC.GetChannel(l)))
				      {
					si->SetEnergy(0.5*(energyi+energyj));
					si->SetTheta(MMMThetaCalc(i));
					si->SetPhi(MMMPhiCalc(j));
					
					si->SetTime(mTDC.GetValue(k));
					si->SetTimeFront(mTDC.GetValue(k));
					si->SetTimeBack(mTDC.GetValue(l));
					
					si->SetDetectorHit(MMMDetHitNumber(i,j));
					si->SetADCChannelFront(i);
					si->SetADCChannelBack(j);
					si->SetStripFront(MMMStripFront(i));
					si->SetStripBack(MMMStripBack(j));
					  
					si->SetTDCChannelFront(mTDC.GetChannel(k));
					si->SetTDCChannelBack(-1);
					si->SetADCValueFront(ADC_import[i]);
					si->SetADCValueBack(ADC_import[j]);
					  
					si->SetTDCValueFront(mTDC.GetValue(k));
					si->SetTDCValueBack(-1);
					si->SetEnergyFront(energyi);
					si->SetEnergyBack(energyj);
					  
					si->SetMult(mTDC.GetMult(k));
				      }
				  }
			      }
			  }
		      }
		  }
	      }
	  }
      }
  }
  
  si->SetHits(si->SizeOfEvent());
  if(!si->TestEvent())si->ClearEvent(); //If the event fails for some reason, we void it and clear it here. The number of these should be logged and, ideally, should be zero. A VOIDED EVENT IS ONE IN WHICH ALL SILICON DATA ARE THROWN AWAY BECAUSE THE RESULT IS **WRONG**. There are more energy hits than theta hits, for example. IT THEY ARE HAPPENING, THEN YOU'VE DONE IT WRONG.
  //printf("MMM.c L88");
  //MMMGhostBuster(SiliconData *si);

  mTDC.ClearEvent();
  return si;
}
示例#2
0
SiliconData *MMMSiliconSort(float *ADC_import, int ntdc, int *TDC_channel_import, float *TDC_value_import)
{
  SiliconData *si = new SiliconData();
  MMMInit();
  //Loop over ADC and TDC events and do the following:
  
  //Check whether there are front-back coincidences for a detector and test the energies
  //Check to see whether there's a TDC event for the same channel as the front hit ADC - TDCs are apparently in single-hit mode. Don't need to worry about multihits
  //Calculate the theta and phi for the valid events
  multiTDC *mTDC = new multiTDC(ntdc, TDC_channel_import, TDC_value_import);
//    printf("L37\n");
  for(int k=0;k<mTDC->GetSize();k++)//Loop over all of the TDC values - there should only be a small number of these relative to the ADC values
  {
//     if(TDC_channel_import[k]>6*128)//This limits the code to only consider TDC values in the last TDC module, which is the one that deals with the silicon timing values
    {
      for(int i=0;i<ADCsize;i++)
      {
	//Don't want to run for events which are below pedestal. Set this to be 250 generally for the moment. In future, might want to increase it a bit
	if(MMMADCTDCChannelTest(i,mTDC->GetChannel(k)) && ADC_import[i]>300)
	{
	  for(int j=0;j<ADCsize;j++)
	  {
	    if(ADC_import[j]>300)
	    {
	      double energyi = MMMEnergyCalc(i,ADC_import[i]);
	      double energyj = MMMEnergyCalc(j,ADC_import[j]);
	      
	      //Test whether the hits are in the front and back of the same detector and whether the energies are good
	      if(MMMFrontBackTest(i,j,energyi,energyj,si))
	      {
// 		printf("TEST57\n");
		si->SetEnergy(0.5*(energyi+energyj));
		si->SetTheta(MMMThetaCalc(i));
		si->SetPhi(MMMPhiCalc(i));
		si->SetTime(mTDC->GetValue(k));
// 		si->SetTime(TDC_value_import[k]);
		// 		si->SetTime(0);
		
		si->SetDetectorHit(MMMDetHitNumber(i,j));
		si->SetADCChannelFront(i);
		si->SetADCChannelBack(j);
		si->SetStripFront(MMMStripFront(i));
		si->SetStripBack(MMMStripBack(j));
		si->SetTDCChannelFront(mTDC->GetChannel(k));
// 		si->SetTDCChannelFront(TDC_channel_import[k]);
		// 		si->SetTDCChannelFront(-1);
		si->SetTDCChannelBack(-1);
		si->SetADCValueFront(ADC_import[i]);
		si->SetADCValueBack(ADC_import[j]);
		
		si->SetTDCValueFront(mTDC->GetValue(k));
// 		si->SetTDCValueFront(TDC_value_import[k]);
		// 		si->SetTDCValueFront(-1);
		si->SetTDCValueBack(-1);
		si->SetEnergyFront(energyi);
		si->SetEnergyBack(energyj);

		si->SetMult(mTDC->GetMult(k));
	      }
	    }
	  }
	}
      }
    }
  }
  
  si->SetHits(si->SizeOfEvent());
  if(!si->TestEvent())si->ClearEvent(); //If the event fails for some reason, we void it and clear it here. The number of these should be logged and, ideally, should be zero. A VOIDED EVENT IS ONE IN WHICH ALL SILICON DATA ARE THROWN AWAY BECAUSE THE RESULT IS **WRONG**. There are more energy hits than theta hits, for example. IT THEY ARE HAPPENING, THEN YOU'VE DONE IT WRONG.

  mTDC->ClearEvent();
  
  delete mTDC;
  
  return si;
}