//*-- AUTHOR : I. Froehlich //*-- Modified : 05.07.2005 by T. Perez //*-- Modified : 07.07.2005 by T. Perez //*-- Modified : 01.02.2006 by T. Perez Now pointer to Track Categories are checked before use. //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////////////// // // HHypDeltaTofAlg // // Algorithm which removes combinations acconding to time-of-flight // differences // // This code is most likely infunctional, as the algorithm is not // implemented correctly (see warnings). This code should be // examined, corrected or even better rewritten. // // Features: // 1. TimeOfFlight from HSpline has already been recalculated due to the // lack of START detector. But this should affect time differences. // Original Time can anyhow be recover with a little bit more work. // 2. It will only work with less than 10 particles in an event. Anyhow this // is harcoded somewhere else, it should be changed top something more // flexible. // 3. We should pass DEBUG flag as a execution parameter. // -> On "init" or "constructor" -- debugFlag=0 default. // 4. Many variables can be declared earlier and the reused. to save time (?). // 5. Can we have to differnt TrackingAlgos in the same file for 2 different // HPidTrackCands? --> Now i assume NO. so its checked once per pair. // MOMENTUM ALGORITHMS INDEXES defined in "$HADDIR/pid/piddef.h" // ALG_KICK 0 // ALG_KICK123 1 // ALG_SPLINE 2 // ALG_RUNGEKUTTA 4 // tracking cats defined here : /misc/halo/anal/dev/mdctrackG/hmdctrackgdef.h // // Tiago Perez. // // Added new method getTrackInfo(). This method handles all that complicated // pointers to retrieve track info. Then sets TOF_EXP and pathLength // T. Perez //////////////////////////////////////////////////////////////////////// #warning "This code is not written in a way to be compatible with other hyp features" #warning "and (most likely)" #warning "will not work as the algorithm is not implemented correctly" #warning "(and THIS is really serious)" #warning "Advise: Use HypDeltaTofMeanAlg instead." using namespace std; #include "hhypDeltaTofAlg.h" #include "TVector3.h" #define deltaTOFdebug 0 ClassImp(HHypDeltaTofAlg) HHypDeltaTofAlg::HHypDeltaTofAlg(Char_t *name_i, Option_t par[]) :HHypBaseAlgorithm(name_i,par) { dtof = -1; sigmaDeltaTof = -1; tof1_exp = -1; tof2_exp = -1; tof1_theo = -1; tof2_theo = -1; beta1_th = -1; beta2_th = -1; pathLength1 = -1; pathLength2 = -1; momIndex1 = -1; momIndex2 = -1; trackIndex1 = -1; trackIndex2 = -1; } HHypDeltaTofAlg::~HHypDeltaTofAlg() { } Bool_t HHypDeltaTofAlg::execute() { if (mylist->getNpart() < 2) return kFALSE; //needs at least 2 particles // Resetting the list and start looping over the combinations // Loop is only done over the VALID combinations mylist->CombIteratorReset(); if (deltaTOFdebug == 1) cerr << "-------------------------------------" << endl; Int_t j = 0; while (mylist->CombIterator()) { j++; // ************** START DEBUG MSG 1/3 ***************************// if (deltaTOFdebug == 1) cerr<<"Combination # "<getProbAlg() << endl; // ************** END DEBUG MSG 1/3 ***************************// dtof = 0; sigmaDeltaTof = 0; Double_t chi2 = 0; Double_t chi = 0; Int_t i = 0; Double_t mean = 0; for (i = 0; i < (mylist->getNpart() - 1); i++) { //loop over all REAMINING particles /* particle 0 is the reference particle */ hyppid1 = mylist->getPid(0); particle1 = (HPidTrackCand *) mylist->getPidTrackCand(0); hyppid2 = mylist->getPid(i + 1); particle2 = mylist->getPidTrackCand(i + 1); // making DeltaTof here //get mom algo momIndex1 = particle1->getTrackData()->getBestMomAlg(); momIndex2 = particle2->getTrackData()->getBestMomAlg(); // ************** START DEBUG MSG 2 ***************************// if (deltaTOFdebug == 1){ cerr<<" HHypDeltaTofAlg::"<<__func__<<"(): L"<<__LINE__<getPid()<<*/" hyppid1 :"<getPid()<<*/" hyppid2 :"<resetProbAlg(exp(-chi2)); //store more data here.... mylist->setUserValue(DELTATOF_DTOF, dtof); mylist->setUserValue(DELTATOF_SIGMA, sigmaDeltaTof); mylist->setUserValue(DELTATOF_OFFSET,tof1_theo - tof1_exp - mean); mylist->setUserValue(DELTATOF_CHI2,chi2); //cout << "tof1_theo " // << tof1_theo << " tof exp:" << tof1_exp << " mean:" << mean << " chi:" << chi << " dtof:" << dtof <getNpart(); for (UInt_t j = 0; j < ntracks; j++) { //look if we have the particles HPidTrackCand *track = mylist->getPidTrackCand(j); if (track) { Int_t pid = mylist->getPid(j); Double_t beta = track->getTrackData()->getBeta(ALG_RUNGEKUTTA) * track->getTrackData()->getPolarity(ALG_RUNGEKUTTA); Double_t mom = track->getTrackData()->getMomenta(ALG_RUNGEKUTTA); qa->Fill(pid, mom, beta, dtof, sigmaDeltaTof, mylist->getProbAlg()); } } } // ************** START DEBUG 3/3 ***********************// if (deltaTOFdebug == 1) { cerr<<"\t dtof "<resetProbAlg(exp(-0.5*chi)); } //END Iterator if (exitIdx > -1) return kTRUE; return kFALSE; } // End Execute() Bool_t HHypDeltaTofAlg::init() { // need to get name from channel TString input(channel->Get(initList)); if (histofile) qa = new TNtuple(input + TString("_dtof_debug"), "Spectra ntuple", "pid:mom:beta:dtof:sigma:probalg"); return kTRUE; } Bool_t HHypDeltaTofAlg::reinit() { return kTRUE; } Bool_t HHypDeltaTofAlg::finalize() { if (histofile) qa->Write(); return kTRUE; } Bool_t HHypDeltaTofAlg::getTrackInfo(Int_t momIndex1, Int_t momIndex2) { if (deltaTOFdebug == 1){ cerr<<" HHypDeltaTofAlg::"<<__func__<<"(): L"<<__LINE__<getCurrentEvent()->getCategory(catPidTrackCand); /* HCategory *pidCandidateCat = (HCategory *) gHades->getCurrentEvent()->getCategory(catPidCandidate); HPidCandidate *pidCand1 = (HPidCandidate *) pidCandidateCat->getObject(particle1-> getPidCandidateIndex()); HPidCandidate *pidCand2 = (HPidCandidate *) pidCandidateCat->getObject(particle2-> getPidCandidateIndex()); */ HPidTrackCand *pidTrackCand1 =particle1; //(HPidTrackCand *) pidTrackCandCat->getObject(pidCand1->getTrackCandIndex()); HPidTrackCand *pidTrackCand2 =particle2; //(HPidTrackCand *) pidTrackCandCat->getObject(pidCand2->getTrackCandIndex()); pidTrackCandCat = pidTrackCand1->buildPidTrackCandCategory(); // DEFAULT VALUES to -1 tof1_exp = -1; // Exp TOF pathLength1 = -1; // Path Length tof2_exp = -1; // Exp TOF pathLength2 = -1; // Path Length if (momIndex1 == ALG_SPLINE) { if (deltaTOFdebug == 1){ cerr<<" HHypDeltaTofAlg::"<<__func__<<"(): L"<<__LINE__<<" :: Using SPLINE momentum"<itsTrackData.nSplineTrackInd; trackIndex2 = pidTrackCand2->itsTrackData.nSplineTrackInd; HCategory *splineCat = (HCategory *) gHades->getCurrentEvent()->getCategory(catSplineTrack); if (splineCat==NULL){ cerr<<" HHypDeltaTofAlg::"<<__func__<<"(): L"<<__LINE__<<" :: No RungeKutta Tracking Category Found !"<getObject(trackIndex1); HSplineTrack *track2 = (HSplineTrack *) splineCat->getObject(trackIndex2); // get Tracking Values tof1_exp = track1->getTof(); // Exp TOF pathLength1 = track1->getTofDist(); // Path Length tof2_exp = track2->getTof(); // Exp TOF pathLength2 = track2->getTofDist(); // Path Length } else if (momIndex1 == ALG_RUNGEKUTTA) { if (deltaTOFdebug == 1){ cerr<<" HHypDeltaTofAlg::"<<__func__<<"(): L"<<__LINE__<<" :: Using RK momentum"<itsTrackData.nRKTrackInd; trackIndex2 = pidTrackCand2->itsTrackData.nRKTrackInd; HCategory *trackCat = (HCategory *) gHades->getCurrentEvent()->getCategory(catRKTrackB); if (trackCat==NULL){ cerr<<" HHypDeltaTofAlg::"<<__func__<<"(): L"<<__LINE__<<" :: No RungeKutta Tracking Category Found !"<getObject(trackIndex1); HRKTrackB *track2 = (HRKTrackB *) trackCat->getObject(trackIndex2); // get Tracking Values tof1_exp = track1->getTof(); // Exp TOF pathLength1 = track1->getTofDist(); // Path Length tof2_exp = track2->getTof(); // Exp TOF pathLength2 = track2->getTofDist(); // Path Length } else { cerr<<" HHypDeltaTofAlg::"<<__func__<<"(): L"<<__LINE__<<" : MOMENTUM ALG not not found !!! \n" << endl; } return kTRUE; }