#include <stdlib.h>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <assert.h>
#include <iostream>
#include "global_variables.h"
#include "LegsMakerTrueTag.h"
ClassImp(LegsMakerTrueTag) 
//____________________________________________________________________
// select true tagger hits

 LegsMakerTrueTag::LegsMakerTrueTag(Int_t add)
    : LegsMaker("TrueTag", "select true tagger hits",  add)
{
  Init();
  this->cd("../");
}  

 void LegsMakerTrueTag::Init()
{
  // user initialization, create histos  etc
  tdcRaw = new TH2F("tdcRaw","tdc raw",200,0,2100,65,0,65);
  tdcCal = new TH2F("tdcCal","tdc calibrated",200,0,200,65,0,65);
  numHitVsTagBinDiff = new TH2F("numHitVsTagBinDiff","correlation between # hits and tag bin difference",10,0,10,65,0,65);
  numHit = new TH1F("numHit","number of hits in Tag TDC",10,0,10);

  return;
}

 bool LegsMakerTrueTag::Make()
{
  // called by LegsRun every event 
  if(GeantSimulation()) return false;
  static LegsDB* lDB = LegsDB::Instance();
  if(it->GetTagCount() == 0) 
    {
      cout << "  if there are no tagger hits - why use" <<  this->GetName() <<  "  maker ?" << endl;
      return false;
    }
  

  assert(it->GetTagCount() != 0);

  static Int_t counter;
  counter=0;
  static float tof;
  static vector<Int_t> tagId(65,0); // enough for the whole tagger
  //   // get rid of multi and acidental hits in tagger
  for(Int_t i = 0; i < it->GetTagCount(); i++)
    {
      tdcRaw->Fill((float)it->GetTagTdc(i), (float)it->GetTagID(i));
      tof = it->fDB->GetTagTof(it->GetTagID(i),it->GetTagTdc(i));
      tdcCal->Fill(tof,(float)it->GetTagID(i));
      Float_t peak, width;
      lDB->GetTrueTagBin(peak,width);
      if(it->fDB->GetTagTof(it->GetTagID(i),it->GetTagTdc(i)) < peak - width ||
 	 it->fDB->GetTagTof(it->GetTagID(i),it->GetTagTdc(i)) > peak + width) 
 	{
	  continue;
	}
      else
	{
	  // 	  Int_t bin = it->GetTrueTagBin();
	  // 	  if(bin == it->GetTagID(i)) flag = true;
 	  tagId[counter] = it->GetTagID(i);
 	  counter++; // number of hits in true window same event
 	}
      
      if(counter >= 2)
	{
	  Int_t diff = abs(tagId[0] -tagId[1]);
	  numHitVsTagBinDiff->Fill((float)counter,(float)diff);
	}
    }
  numHit->Fill((float)counter);
  return true;
} 

 void LegsMakerTrueTag::RunEnd()
{
  cout << " I don't use LegsMakerTrueTag::RunEnd()  " << endl;
}



ROOT page - Home page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.