#include "THaTrackingDetector.h"
#include "THaTrack.h"
#include "THaSpectrometer.h"
#include "THaParticleInfo.h"
#include "THaScintillator.h"
#include "THaTrackProj.h"
#include "THaTrackingDetector.h"
#include "THaNonTrackingDetector.h"
#include "THaPidDetector.h"
#include "THaPIDinfo.h"
#include "THaTrack.h"
#include "TMath.h"
#include "TList.h"
#include "VarDef.h"
#include <cmath>
#include <string>
#include "TString.h"
#include "THaEvData.h"
#include "TClonesArray.h"
#include <iostream>
#include "THaScintHit.h"
#include "THaScintBar.h"
#include "THaScintPMT.h"
#include "THaAdcHit.h"
#include "THaTdcHit.h"
#include "THaPartialHit.h"
#include "THaTrack.h"
#include "THaTrackProj.h"
#include "THaScintPlaneDet.h"
#include "TMath.h"
#include "THaCoincTimeE06010.h"
using namespace std;
ClassImp(THaCoincTimeE06010);
ClassImp(TCoincInfo);
const Double_t THaCoincTimeE06010::fLTimeConvertion = 1e9;
const Double_t THaCoincTimeE06010::c = 0.299792458;
const Double_t THaCoincTimeE06010::fMissingRefWarningRatio = 0.001;
THaCoincTimeE06010::THaCoincTimeE06010( const char* name, const char* description,
THaBigBite *BigBite, THaHRS *HRS)
: THaPhysicsModule(name,description),
fBigBite(BigBite),fHRS(HRS)
{
DEBUG_LEVEL_RELATED_PERFORMACE_CHECKER;
DEBUG_HALL_A_ANALYZER_DEBUGER_INIT;
assert(fBigBite);
assert(fHRS);
fCoincInfo = new TClonesArray("TCoincInfo", 20);
}
THaCoincTimeE06010::~THaCoincTimeE06010()
{
delete fCoincInfo;
}
Int_t THaCoincTimeE06010::DefineVariables( EMode mode )
{
if( mode == kDefine && fIsSetup ) return kOK;
fIsSetup = ( mode == kDefine );
RVarDef vars[] = {
{ "n", "number of coinc combinations = N L Track * N BB Track", "GetNCoinc()"},
{ "bbrf", "BigBite RF Time, Array of n, idx by [L Track][BB Track]", "fCoincInfo.TCoincInfo.GetBBRFTime()"},
{ "lrf", "LHRS RF Time, Array of n, idx by [L Track][BB Track]", "fCoincInfo.TCoincInfo.GetLRFTime()"},
{ "trig","Coincident Trigger Time = DL.f1T3 + roll over" , "fCoinTriggerTime"},
{ "t", "Coincident Time, Array of n, idx by [L Track][BB Track]", "fCoincInfo.TCoincInfo.GetCoincTime()"},
{ 0 }
};
Int_t value = DefineVarsFromList( vars, mode );
return value + THaPhysicsModule::DefineVariables(mode);
}
void THaCoincTimeE06010::ClearEvent(void)
{
fNTrBB = fNTrL = 0;
fCoincInfo->Clear("C");
}
Int_t THaCoincTimeE06010::Process( const THaEvData& evdata )
{
ClearEvent();
Double_t refTDC=kBig, hitTDC=kBig;
fCoinTriggerTime = kBig*0.01;
UInt_t nrefhit = evdata.GetNumHits( fCoinTDCROC, fCoinTDCSlot, fCoinTDCRefChan );
static UInt_t totalN=0, missN=0;
totalN++;
if ( !nrefhit )
{
missN++;
if (totalN>4/fMissingRefWarningRatio &&
(Double_t)missN/(Double_t)totalN>fMissingRefWarningRatio)
Error(Here("GetData"),"No hit for reference channel @ roc=%d, slot=%d, chan=%d ",
fCoinTDCROC, fCoinTDCSlot, fCoinTDCRefChan);
refTDC = kBig*0.01;
}
else
{
if (nrefhit>1)
DEBUG_WARNING(Here("GetData"),"Multi hits (%d) for reference channel @ roc=%d, slot=%d, chan=%d ",
nrefhit, fCoinTDCROC, fCoinTDCSlot, fCoinTDCRefChan);
Int_t data = evdata.GetData( fCoinTDCROC, fCoinTDCSlot, fCoinTDCRefChan, 0 );
DEBUG_MASSINFO(Here("GetData"),"Get Data %d for roc=%d, slot=%d, chan=%d ",
data, fCoinTDCROC, fCoinTDCSlot, fCoinTDCRefChan);
refTDC = data;
}
UInt_t nhit = evdata.GetNumHits( fCoinTDCROC, fCoinTDCSlot, fCoinTDCChan );
if ( !nhit )
{
DEBUG_MASSINFO(Here("GetData"),"No hit for T3 channel @ roc=%d, slot=%d, chan=%d ",
fCoinTDCROC, fCoinTDCSlot, fCoinTDCChan);
}
else
{
Double_t bestt3diff = 1e30 , t3hittime = 1e30;
for(UInt_t hitid = 0; hitid<nhit; hitid++)
{
Int_t data = evdata.GetData( fCoinTDCROC, fCoinTDCSlot, fCoinTDCChan, 0 );
DEBUG_MASSINFO(Here("GetData"),"Get Data %d for roc=%d, slot=%d, chan=%d ",
data, fCoinTDCROC, fCoinTDCSlot, fCoinTDCChan);
hitTDC = data;
t3hittime = hitTDC - refTDC;
DEBUG_MASSINFO(Here("GetData"),"t3hittime = %f TDC Units ",t3hittime);
if (t3hittime >= (Double_t)fCoinTDCRollOver/2.) t3hittime-=fCoinTDCRollOver;
if (t3hittime < -(Double_t)fCoinTDCRollOver/2.) t3hittime+=fCoinTDCRollOver;
DEBUG_MASSINFO(Here("GetData"),"t3hittime = %f TDC Units, fCoinTDCRollOver/2 = %f",t3hittime,fCoinTDCRollOver/2.);
t3hittime *= fCoinTDCRes;
DEBUG_MASSINFO(Here("GetData"),"t3hittime = %f ns ",t3hittime);
if (abs(t3hittime - fCoinTriggerCenter)<bestt3diff)
{
fCoinTriggerTime = t3hittime;
bestt3diff = abs(t3hittime - fCoinTriggerCenter);
}
}
DEBUG_INFO(Here("GetData"),"fCoinTriggerTime = %f ns, bestt3diff = %f ns",fCoinTriggerTime,bestt3diff);
}
fNTrBB = fBigBite->GetNTracks();
fNTrL = fHRS->GetNTracks();
assert(fNTrBB>=0);
assert(fNTrL>=0);
for (UInt_t l=0;l<fNTrL;l++)
for (UInt_t bb=0;bb<fNTrBB;bb++)
CaclCoin(l, bb);
assert(fNTrBB * fNTrL == GetNCoinc());
return kOK;
}
void THaCoincTimeE06010::CaclCoin(UInt_t ltr, UInt_t bbtr)
{
DEBUG_INFO(Here("CaclCoin"),"Calculate Coin Time for L Tr#%d and BB Tr#%d ... ",ltr,bbtr);
Double_t BBRFTime= kBig;
Double_t LRFTime= kBig;
Double_t CoincTime= kBig;
THaTrackProj * ls2tr = (THaTrackProj *)(ls2->GetTrackHits()->At(ltr));
assert(ls2tr);
Int_t Ls2trpad = ls2tr -> GetChannel();
assert (Ls2trpad < ls2->GetNelem());
THaTrack * LTR = (THaTrack *)(fHRS->GetTracks()->At(ltr));
assert(LTR);
Double_t speed = c * LTR->GetP() / TMath::Sqrt(fHadronMass*fHadronMass+LTR->GetP()*LTR->GetP());
if (Ls2trpad>=0)
LRFTime = -(-fLTimeConvertion * (ls2->GetTimes())[Ls2trpad] +(ls2tr->GetPathLen() + LTR->GetPathLen())/speed);
else
LRFTime = kBig;
THaTrackProj * bbstr = (THaTrackProj *)(bbs->GetTrackHits()->At(bbtr));
assert(bbstr);
Int_t bbstrhit = bbstr -> GetChannel();
assert(bbstrhit<bbs->GetNHits());
THaTrack * BBTR = (THaTrack *)(fBigBite->GetTracks()->At(bbtr));
assert(BBTR);
if (bbstrhit>=0)
{
assert(bbs->GetHit(bbstrhit));
BBRFTime = -(-(bbs->GetHit(bbstrhit)->GetHitTOF()) + fBBTrx*BBTR->GetTheta());
}
CoincTime = -LRFTime - fCoinTriggerTime + BBRFTime
+ fTOff + fBaseTOff;
UInt_t idx = ltr*fNTrBB + bbtr;
assert(idx == GetNCoinc());
new ( (*fCoincInfo)[idx] ) TCoincInfo(BBRFTime, LRFTime, CoincTime);
DEBUG_INFO(Here("CaclCoin"),"BBRFTime= %f, LRFTime= %f, CoincTime= %f",BBRFTime, LRFTime, CoincTime);
return;
}
THaCoincTimeE06010::EStatus THaCoincTimeE06010::Init( const TDatime& run_time )
{
EStatus status = THaPhysicsModule::Init(run_time);
if (status!=kOK) return status;
DEBUG_INFO(Here("Init"),"Searching for L.s2 ...");
ls2 = (THaScintillator *) (fHRS->GetDetector("s2"));
DEBUG_INFO(Here("Init"),"Searching for BB.s ...");
bbs = (THaScintPlaneDet *) (fBigBite->GetDetector("s"));
if (!ls2)
{
Error("Init","Couldn't find L.s2. Make sure CT module is init after L spectrometer");
return kInitError;
}
if (!bbs)
{
Error("Init","Couldn't find BB.s. Scintillator is loaded to Bigbite");
return kInitError;
}
return kOK;
}
Int_t THaCoincTimeE06010::ReadDatabase(const TDatime& date)
{
DEBUG_INFO(Here("ReadDatabase"),"Start ReadDatabase ...");
fIsInit = kFALSE;
Int_t status = THaPhysicsModule::ReadDatabase(date);
if (status!=kOK){
Error(Here("ReadDatabase"),"THaBigBite::ReadDatabase(date) fail = %d",status);
return status;
}
DEBUG_INFO(Here("ReadDatabase"),"OpenFile Database ...");
FILE* file = OpenFile( date );
if( !file ) {
Error(Here("ReadDatabase"),"OpenFile( date ) fail = %d",kFileError);
return kFileError;
}
fHadronMass = fTOff = fBBTrx = fBaseTOff = 0;
fCoinTDCRes = 0.0602;
fCoinTriggerCenter = -200;
fCoinTDCROC = fCoinTDCSlot = fCoinTDCChan = fCoinTDCRefChan = 0;
DBRequest request[] =
{
{ "HadronMass", &fHadronMass, kDouble, 0, 1, 1 },
{ "TOff", &fTOff, kDouble, 0, 1, 1 },
{ "BBTrx", &fBBTrx, kDouble, 0, 1, 1 },
{ "BaseTOff", &fBaseTOff, kDouble, 0, 1, 1 },
{ "CoinTDCRes", &fCoinTDCRes, kDouble, 0, 0, 1 },
{ "CoinTDCRollOver", &fCoinTDCRollOver, kInt, 0, 0, 1 },
{ "CoinTDCROC", &fCoinTDCROC, kInt, 0, 0, 1 },
{ "CoinTDCSlot", &fCoinTDCSlot, kInt, 0, 0, 1 },
{ "CoinTDCChan", &fCoinTDCChan, kInt, 0, 0, 1 },
{ "CoinTDCRefChan", &fCoinTDCRefChan, kInt, 0, 0, 1 },
{ "CoinTriggerCenter", &fCoinTriggerCenter, kDouble, 0, 0, 1 },
{ 0 }
};
DEBUG_INFO(Here("ReadDatabase"),"LoadDB ...");
Int_t err = LoadDB( file, date, request, GetPrefix(), 1);
fclose(file);
if (err<0)
{
Error(Here("ReadDatabase"),"LoadDB: fail = %d",err);
return kFileError;
}
else if (err>0)
{
DEBUG_INFO(Here("ReadDatabase"),"LoadDB: missing keys = %d",err);
}
fIsInit = kTRUE;
#if DEBUG_LEVEL>=3 //start show info
TString sDebugOutput;
sDebugOutput=GetName();
sDebugOutput+=" Database read in successfully with:";
sDebugOutput+="\n \t fHadronMass\t= "; sDebugOutput+=fHadronMass;
sDebugOutput+="\n \t fTOff\t= "; sDebugOutput+=fTOff;
sDebugOutput+="\n \t fBBTrx\t= "; sDebugOutput+=fBBTrx;
sDebugOutput+="\n \t fBaseTOff\t= "; sDebugOutput+=fBaseTOff;
sDebugOutput+="\n \t fCoinTDCRes\t= "; sDebugOutput+=fCoinTDCRes;
sDebugOutput+="\n \t fCoinTDCRollOver\t= "; sDebugOutput+=fCoinTDCRollOver;
sDebugOutput+="\n \t fCoinTDCROC\t= "; sDebugOutput+=fCoinTDCROC;
sDebugOutput+="\n \t fCoinTDCSlot\t= "; sDebugOutput+=fCoinTDCSlot;
sDebugOutput+="\n \t fCoinTDCChan\t= "; sDebugOutput+=fCoinTDCChan;
sDebugOutput+="\n \t fCoinTDCRefChan\t= "; sDebugOutput+=fCoinTDCRefChan;
sDebugOutput+="\n \t fCoinTriggerCenter\t= "; sDebugOutput+=fCoinTriggerCenter;
sDebugOutput+="\n";
Info(Here("ReadDatabase"),sDebugOutput.Data());
#endif
return status;
}
Last update: Tue Jul 7 19:26:16 2009
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.