Beispiel #1
0
//---------------------------------------------------------------------
void MMMSiliconSort(float *ADC_import, int ntdc, int *TDC_channel_import, float *TDC_value_import, SiliconData *si)
{
  //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)))
	      { 
		//printf("MMMSiliconSort L116 test\n");
		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++)
		    int i = MMMADCChannelLimits[DetNum-1][0] + (mTDC.GetChannel(k) - MMMTDCChannelLimits[DetNum-1][0]);
		      {
		        //printf("MMMSiliconSort L122 test\n");
			//Don't want to run for events w
			if(MMMADCTDCChannelTestPSide(i,mTDC.GetChannel(k)) && ADC_import[i]>0)
			  {
			    //printf("MMMSiliconSort L126 test\n");
			    //for(int j=MMMADCChannelLimits[DetNum-1][2];j<=MMMADCChannelLimits[DetNum-1][3];j++)
			    int j = MMMADCChannelLimits[DetNum-1][2] + (mTDC.GetChannel(l) - MMMTDCChannelLimits[DetNum-1][2]);
			      {
			        //printf("MMMSiliconSort L129 test\n");
				if(ADC_import[j]>0)
				  {//printf("test\n");
				    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)) && 0.5*(energyi+energyj)>400)
				      {				
	                                //printf("MMMSiliconSort L134 test\n");
					si->SetEnergy(energyi);

					si->SetTheta(MMMThetaCalc(i)); // RN 7 March 16: I propose a different way
					si->SetPhi(MMMPhiCalc(DetNum,j));     // RN 7 March 16: I proposa a different way
					
					si->SetTime(mTDC.GetValue(k));
					si->SetTimeFront(mTDC.GetValue(k));
					si->SetTimeBack(mTDC.GetValue(l));

					si->SetOffsetTime(mTDC.GetValue(k) - TDCOffsets[mTDC.GetChannel(k)]);
					
					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(mTDC.GetChannel(l));

					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());
  //printf("SiliconData PrintEvent routine: Silicon hits: %d\n",si->SizeOfEvent());
  //si->PrintEvent();
  //printf("MMM.c L180\n");
  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 L182\n");
  //MMMGhostBuster(SiliconData *si);

  mTDC.ClearEvent();
  //return si;

}
Beispiel #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;
}