|
//____________________________________________________________________ // // Class BrMrsTofMatchingModule // // Module scanning the global track table and picking up those // matching valid tof hits. // Selected pairs saved into table of BrTofTrackMatch named "MRS Matching" // // Algorithm (Event method): // ------------------------- // // 1- pick up tables of TOFW hits and MRS tracks // if one of them missing, return // // 2- // a- Select tof hits by checking the TDCs and ADCs of both tubes // // b- loop over tracks and sub-loop over hits // i - evaluate the dX between track projection and hit position // ii - minimize this distance and store the "winner" hit // slat number in an array that has the dimension of // the track table. It might be that the minimal dX is // beyond the matching criterium, then, the hit id is -1 // // c- check "multiple hits" when more than 1 track share the same // hit. In that case, ignore these tracks (it doesn't remove // completely multiple hits since there might be one track // only pointing to such hits - the other tracks having not // been reconstructed) // // d- loop over remaining matchings and store result into table // of BrTofTrackMatch object (cf class implementation file) // // Note: due to the problem in the TPM2 tracks (slopes) that causes tracks to // be off at the slats at the edge, an effective correction to the hit pos is introduced. // to correct the Hit - used in finding the 'best' hit. // //____________________________________________________________________ // // $Id: BrMrsTofMatchingModule.cxx,v 1.9 2002/08/30 16:27:09 hagel Exp $ // $Author: hagel $ // $Date: 2002/08/30 16:27:09 $ // $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov> // #ifndef BRAT_BrMrsTofMatchingModule #include "BrMrsTofMatchingModule.h" #endif #ifndef ROOT_TDirectory #include "TDirectory.h" #endif #ifndef WIN32 #include <iostream> #include <iomanip> #include <fstream> #else #include <iomanip.h> #include <fstream.h> #include <iostream.h> #endif #ifndef BRAT_BrDataTable #include "BrDataTable.h" #endif #ifndef BRAT_BrTofDig #include "BrTofDig.h" #endif #ifndef BRAT_BrDetectorTrack #include "BrDetectorTrack.h" #endif #ifndef BRAT_BrRunInfoManager #include "BrRunInfoManager.h" #endif #ifndef BRAT_BrParameterDbManager #include "BrParameterDbManager.h" #endif #ifndef BRAT_BrCalibrationManager #include "BrCalibrationManager.h" #endif #ifndef BRAT_BrGeometryDbManager #include "BrGeometryDbManager.h" #endif #ifndef BRAT_BrSpectrometerTracks #include "BrSpectrometerTracks.h" #endif #ifndef BRAT_BrTofTrackMatch #include "BrTofTrackMatch.h" #endif //____________________________________________________________________ ClassImp(BrMrsTofMatchingModule); //____________________________________________________________________ BrMrsTofMatchingModule::BrMrsTofMatchingModule() : BrModule() { // Default constructor. DO NOT USE SetState(kSetup); fTofwCalib = 0; fTpm2Vol = 0; fPanelVol = 0; fPanelPar = 0; fTofwPar = 0; fNumMatchedSlats = 0; SetDefaultParameters(); } //____________________________________________________________________ BrMrsTofMatchingModule::BrMrsTofMatchingModule(const Char_t* name, const Char_t* title) : BrModule(name, title) { // Named Constructor SetState(kSetup); fTofwCalib = 0; fTpm2Vol = 0; fPanelVol = 0; fPanelPar = 0; fTofwPar = 0; fNumMatchedSlats = 0; SetDefaultParameters(); } //____________________________________________________________________ void BrMrsTofMatchingModule::SetDefaultParameters() { // default parameters for (Int_t p = 0; p < 6; p++) SetTpm2PanXOffset(p, 0); SetMaxDX(); // default is +/- 1.5 cm SetTdcRange(); // default is [10, 4000] SetMaxAdc(); // default is 100000 SetXHitCorr(); // default is 0.0095 (fixing TPM2 problem for 2001/02 in an effective way. SetNtuple(); // default is false } //____________________________________________________________________ void BrMrsTofMatchingModule::DefineHistograms() { // Define histograms. They are: // <fill in here> if (GetState() != kInit) { Stop("DefineHistograms", "Must be called after Init"); return; } TDirectory* saveDir = gDirectory; TDirectory* histDir = gDirectory->mkdir("MRS_TofMatch"); histDir->cd(); // list of histograms if (fNtuple) fNtMatch = new TNtuple("Match", "Matched TOFW hits and MRS tracks", "nTrack:yTrack:xTrack:tTime:bTime:slat:tEner:bEner" ":xHit:momentum:panel"); fDxAll = new TH1F("dXAll", "#DeltaX MRS Track - TOFW hit, all combination", 400, -20, 20); fDxMatch = new TH1F("dXMatch", "#DeltaX MRS Track - TOFW hit within " "matching condition", 400, -20, 20); fPanelStat = new TH1F("panelStat", "Panel statistics of hit-track pairs", fTofwPar->GetNoPanels()*3, 0.5, fTofwPar->GetNoPanels() + 0.5); fMatchStat = new TH1F("tofwStat", "Number of matchings per event", 21, -0.5, 20.5); fSlatDiff = new TH1F("slatDiff", "Matched hit slat - track pointed slat", 10, -4.5, 5.5); fAccptSlatDist = new TH1F("AcceptedSlats","Accepted Slat Dist",200,0,200); fAccptMatchedSlatDist = new TH1F("AcceptedMatchedSlats","Accepted Matched Slat Dist",200,0,200); histDir->mkdir("Panels"); histDir->cd("Panels"); fMatchPanStat = new TH1F* [fTofwPar->GetNoPanels()]; fPanelDx = new TH1F* [fTofwPar->GetNoPanels()]; fX2dAll = new TH2F* [fTofwPar->GetNoPanels()]; fX2dMatch = new TH2F* [fTofwPar->GetNoPanels()]; for (Int_t p = 0; p < fTofwPar->GetNoPanels(); p++) { fPanelDx[p] = new TH1F(Form("panel%dDx", p+1), Form("#DeltaX MRS Track - Panel %d hit", p+1), 400, -20, 20); fX2dAll[p] = new TH2F(Form("XAllPanel%d", p+1), Form("Panel %d, X correlation, all combinations", p+1), 51, -25.5, 25.5, 510, -25.5, 25.5); fX2dMatch[p] = new TH2F(Form("XMatchPanel%d", p+1), Form("Panel %d, X correlation, matching only", p+1), 51, -25.5, 25.5, 510, -25.5, 25.5); fMatchPanStat[p] = new TH1F(Form("panel%dStat",p+1), Form("Panel %d: Number of matchings per event", p+1), 21, -0.5, 20.5); } gDirectory = saveDir; } //____________________________________________________________________ void BrMrsTofMatchingModule::Init() { // Job-level initialisation SetState(kInit); // Detector parameters and calibrations InitParams(); // geometry InitGeo(); // check tof pedestal calibration CheckTofCal(); // initialize all slat to good (let's be optimistic :) fValidSlat = new Bool_t [fTofwPar->GetNoSlats()]; } //____________________________________________________________________ void BrMrsTofMatchingModule::InitParams() { // private // ---------------------------------------------- // initialize detector parameters and calibration // ---------------------------------------------- BrParameterDbManager* parDb = BrParameterDbManager::Instance(); BrCalibrationManager* calDb = BrCalibrationManager::Instance(); fTofwCalib = (BrTofCalibration*)calDb-> Register("BrTofCalibration", "TOFW"); fTofwPar = (BrDetectorParamsTof*)parDb-> GetDetectorParameters("BrDetectorParamsTof", "TOFW"); fPanelPar = new BrDetectorParamsTof* [fTofwPar->GetNoPanels()]; for (Int_t p = 0; p < fTofwPar->GetNoPanels(); p++) fPanelPar[p] = (BrDetectorParamsTof*)parDb-> GetDetectorParameters("BrDetectorParamsTof", Form("TFP%d",p+1)); } //____________________________________________________________________ void BrMrsTofMatchingModule::InitGeo() { // private // ------------------------------- // initialize geometry // ------------------------------- BrGeometryDbManager* geoDb = BrGeometryDbManager::Instance(); fTpm2Vol = (BrDetectorVolume*)geoDb-> GetDetectorVolume("BrDetectorVolume", "TPM2"); fPanelVol = new BrDetectorVolume* [fTofwPar->GetNoPanels()]; for (Int_t p = 0; p < fTofwPar->GetNoPanels(); p++) fPanelVol[p] = (BrDetectorVolume*)geoDb-> GetDetectorVolume("BrDetectorVolume", Form("TFP%d", p+1)); } //____________________________________________________________________ void BrMrsTofMatchingModule::CheckTofCal() { // private // --------------------------- // check pedestal calibration // --------------------------- Int_t nSlats = fTofwPar->GetNoSlats(); // use pedestals and widths BrCalibration::EAccessMode mode = BrCalibration::kRead; // check needed calibration, if already loaded (ascii file) // by the tof pedestal module (cf brat guide) // if not, try to get them from DB if (!fTofwCalib->GetAccessMode("topPedestal") || !fTofwCalib->GetAccessMode("botPedestal") || !fTofwCalib->GetAccessMode("topPedestalWidth") || !fTofwCalib->GetAccessMode("botPedestalWidth")) { mode = BrCalibration::kRead; fTofwCalib->Use("topPedestal" ,mode, nSlats); fTofwCalib->Use("botPedestal", mode, nSlats); fTofwCalib->Use("topPedestalWidth", mode, nSlats); fTofwCalib->Use("botPedestalWidth", mode, nSlats); } } //____________________________________________________________________ void BrMrsTofMatchingModule::Begin() { // Run-level initialisation SetState(kBegin); Info(10,"Begin","RevisionExists = %d",fTofwCalib->RevisionExists("*")); if (!fTofwCalib->RevisionExists("*")) { Abort("Begin", "Could not find pedestal revision. Aborting..."); return; } // check calibrated slats for(Int_t s = 0; s < fTofwPar->GetNoSlats(); s++) { fValidSlat[s] = kTRUE; if (!IsValid(fTofwCalib->GetBotPedestal(s+1)) || !IsValid(fTofwCalib->GetTopPedestal(s+1)) || !IsValid(fTofwCalib->GetBotPedestalWidth(s+1)) || !IsValid(fTofwCalib->GetTopPedestalWidth(s+1))){ fValidSlat[s] = kFALSE; if(Verbose()){ cout << "Not valid Slat from DB " << setw(8) << s << endl; if(!IsValid(fTofwCalib->GetBotPedestal(s+1))) cout << " Top Pedestal" << endl; if(!IsValid(fTofwCalib->GetTopPedestal(s+1))) cout << " Bot Pedestal" << endl; if(!IsValid(fTofwCalib->GetBotPedestalWidth(s+1))) cout << " Top AdcGain" << endl; if(!IsValid(fTofwCalib->GetTopPedestalWidth(s+1))) cout << " Bot AdcGain" << endl; } } } } //____________________________________________________________________ void BrMrsTofMatchingModule::Event(BrEventNode* inNode, BrEventNode* outNode) { // Per event method SetState(kEvent); // Algorithm // ---------- // // 1- pick up tables of TOFW hits and MRS tracks // if one of them missing, return // // 2- // a- Select tof hits by checking the TDCs and ADCs of both tubes // // b- loop over tracks and sub-loop over hits // i - evaluate the dX between track projection and hit position // ii - minimize this distance and store the "winner" hit // slat number in an array that has the dimension of // the track table. It might be that the minimal dX is // beyond the matching criterium, then, the hit id is -1 // // c- check "multiple hits" when more than 1 track share the same // hit. In that case, ignore these tracks (it doesn't remove // completely multiple hits since there might be one track // only pointing to such hits - the other tracks having not // been reconstructed) // // d- loop over remaining matchings and store result into table // of BrTofTrackMatch object (cf class implementation file) // // ----------------------------------------------------------------- BrDataTable* glbTracks = inNode->GetDataTable("MrsTracks");; if (!glbTracks) glbTracks = outNode->GetDataTable("MrsTracks"); // dig tof BrDataTable* hits = inNode->GetDataTable("DigTof TOFW"); if (!hits) hits = outNode->GetDataTable("DigTof TOFW"); if (!glbTracks || !hits) { if (Verbose() > 10) Warning("Event", "No tracks or hits"); return; } Int_t ntrk = glbTracks->GetEntries(); // number of global tracks in event Int_t nhit = hits->GetEntries(); // number of tof hits in event // ------------------------------------------------------- // ------ 1st: selection of tof hits ------ // array of accepted hits BrTofDig* tofHit[nhit]; for (Int_t i = 0; i < nhit; i++) tofHit[i] = 0; // number of accepted hits Int_t acptHit = 0; for(Int_t h = 0; h < nhit; h++) { BrTofDig* hit = (BrTofDig*)hits->At(h); Int_t slat = hit->GetSlatno(); // check if slat ok if (!fValidSlat[slat-1]) continue; // pedestals Float_t tPed = fTofwCalib->GetTopPedestal(slat); Float_t bPed = fTofwCalib->GetBotPedestal(slat); Float_t tWid = fTofwCalib->GetTopPedestalWidth(slat); Float_t bWid = fTofwCalib->GetBotPedestalWidth(slat); // hit info Double_t tadc = hit->GetAdcUp() - tPed; Double_t badc = hit->GetAdcDown() - bPed; Double_t ttdc = hit->GetTdcUp(); Double_t btdc = hit->GetTdcDown(); // adc and tdc checks if (tadc < fNoPedWidth*tWid || badc < fNoPedWidth*bWid || tadc > fMaxAdc || badc > fMaxAdc || ttdc > fMaxTdc || btdc > fMaxTdc || ttdc < fMinTdc || btdc < fMinTdc) continue; tofHit[acptHit] = hit; acptHit++; if(HistOn()) fAccptSlatDist->Fill(slat); } if(Verbose()>5){ cout << "Matched tracks " << ntrk; } // ---------------------------------------------------------------- // 2nd ------ loop over tracks, find best hit for given track // ---------------------------------------------------------------- Int_t matchIdx[ntrk]; // array of matching index for (Int_t t = 0; t < ntrk; t++) { // loop for track projection matchIdx[t] = -1; // initialize matching index BrMrsTrack* trk = (BrMrsTrack*)glbTracks->At(t); // check that the track status is OK if (trk->GetStatus() != BrMatchedTrack::kOk) continue; // WATCH OUT: here the stuff is in global coord. BrVector3D trkProj = trk->GetProjOnTof(); Double_t dX = 999999.; // min diff in X between hit and back track proj // ---- loop over hits for(Int_t h = 0; h < acptHit; h++) { Int_t slat = tofHit[h]->GetSlatno(); Int_t sl = slat; Int_t panel = GetPanelId(slat); // convert track proj into local panel frame BrVector3D local; fPanelVol[panel]->GlobalToLocal(trkProj, local, 0); // evaluate X hit position on panel: for (Int_t p = 0; p < panel; p++) sl -= fPanelPar[p]->GetNoSlats(); // local slat num in panel Double_t xHit = fPanelPar[panel]->GetSlatPos(sl)[0]; // correct for the offset in X between tof plane and tpc xHit += fTpm2PanXOffset[panel]; // have now X hit position on tof plane // gonna minimize the difference with track proj X cut xHit -= fXhitCorr*(slat-62); Double_t diffX = local(0) - xHit; if (HistOn()) { fDxAll->Fill(diffX); fPanelDx[panel]->Fill(diffX); fX2dAll[panel]->Fill(xHit, local(0)); } // ignore cases where we are too far off if (TMath::Abs(diffX) > fMaxDX) continue; if (TMath::Abs(diffX) < TMath::Abs(dX)) { dX = diffX; matchIdx[t] = h; } } } // ------- check multiple hits for (Int_t t = 0; t < ntrk - 1; t++) for (Int_t i = t + 1; i < ntrk; i++) { if (matchIdx[i] == -1 || matchIdx[t] == -1) continue; if (matchIdx[i] == matchIdx[t]) { // multiple hit (?) matchIdx[i] = -1; matchIdx[t] = -1; } } //----------------------------------------------- // can save stuff into table of BrTofTrackMatch //----------------------------------------------- // evaluate the number of matched pairs Int_t nPairs = 0; Int_t nPanPairs[fTofwPar->GetNoPanels()]; for (Int_t p = 0; p < fTofwPar->GetNoPanels(); p++) nPanPairs[p] = 0; for (Int_t t = 0; t < ntrk; t++) { if (matchIdx[t] == -1) continue; BrTofDig* hit = tofHit[matchIdx[t]]; Int_t slat = hit->GetSlatno(); nPairs++; nPanPairs[GetPanelId(slat)]++; } if (HistOn()) { fMatchStat->Fill(nPairs); for (Int_t p = 0; p < fTofwPar->GetNoPanels(); p++) fMatchPanStat[p]->Fill(nPanPairs[p]); } if (!nPairs) return; // ---------------------------- // prepare output table BrDataTable* matchTab = new BrDataTable("MRS Matching"); // loop over pairs for (Int_t t = 0; t < ntrk; t++) { if (matchIdx[t] == -1) continue; BrTofDig* hit = tofHit[matchIdx[t]]; Int_t slat = hit->GetSlatno(); BrMrsTrack* trk = (BrMrsTrack*)glbTracks->At(t); // create object BrTofTrackMatch* tt = new BrTofTrackMatch(); tt->SetMatching(trk->GetTrackId(), slat, GetPanelId(slat)); matchTab->Add(tt); fNumMatchedSlats++; if(HistOn()) fAccptMatchedSlatDist->Fill(slat); //----------------------- if (!HistOn()) continue; BrVector3D trkProj = trk->GetProjOnTof(); fPanelStat->Fill(GetPanelId(slat)+1); fSlatDiff->Fill(slat - trk->GetPointedSlat()); Double_t ttdc = hit->GetTdcUp(); Double_t tadc = hit->GetAdcUp() - fTofwCalib->GetTopPedestal(slat); Double_t btdc = hit->GetTdcDown(); Double_t badc = hit->GetAdcDown() - fTofwCalib->GetBotPedestal(slat); Int_t sl = slat; BrVector3D local; Int_t panel = GetPanelId(slat); for (Int_t p = 0; p < panel; p++) sl -= fPanelPar[p]->GetNoSlats(); // local slat num in panel fPanelVol[panel]->GlobalToLocal(trkProj, local, 0); Double_t xHit = fPanelPar[panel]->GetSlatPos(sl)[0] + fTpm2PanXOffset[panel]; xHit -= fXhitCorr*(slat-62); fDxMatch->Fill(local(0) - xHit); fX2dMatch[panel]->Fill(xHit, local(0)); if (fNtuple) fNtMatch->Fill(nPairs, local(1), local(0), ttdc, btdc, slat, tadc, badc, xHit, trk->GetMomentum(), panel); } // check match table if (matchTab->GetEntries()) outNode->AddDataTable(matchTab); else delete matchTab; } //____________________________________________________________________ void BrMrsTofMatchingModule::Finish() { cout<<"Module "<<GetName()<<" Summary"<<endl; cout<<"Number Matched TOF hits: "<<fNumMatchedSlats<<endl; } //_____________________________________________________________ Int_t BrMrsTofMatchingModule::GetPanelId(Int_t slat) { // ----------------------------------------- // returns TOFW panel id given a slat number // ----------------------------------------- Int_t panel = -1; Int_t firstSlat[fTofwPar->GetNoPanels()]; // find first slat number of each panel (1 - 21 - 42 - 63 etc) firstSlat[0] = 1; for (Int_t p = 1; p < fTofwPar->GetNoPanels(); p++) firstSlat[p] = fPanelPar[p-1]->GetNoSlats() + firstSlat[p-1]; for (Int_t p = 0; p < fTofwPar->GetNoPanels(); p++) { // last slat of panel p Int_t fsl = firstSlat[p] + fPanelPar[p]->GetNoSlats() - 1; if (slat >= firstSlat[p] && slat <= fsl) { panel = p; break; } } return panel; } //____________________________________________________________________ void BrMrsTofMatchingModule::Print(Option_t* option) const { // Print module information // See BrModule::Print for options. // In addition this module defines the Option: // <fill in here> TString opt(option); opt.ToLower(); BrModule::Print(option); if (opt.Contains("d")) cout << endl << " Original author: Djamel Ouerdane" << endl << " Last Modifications: " << endl << " $Author: hagel $" << endl << " $Date: 2002/08/30 16:27:09 $" << endl << " $Revision: 1.9 $ " << endl << endl << "-------------------------------------------------" << endl; } //____________________________________________________________________ // // $Log: BrMrsTofMatchingModule.cxx,v $ // Revision 1.9 2002/08/30 16:27:09 hagel // Added matched slat distribution // // Revision 1.8 2002/06/21 18:37:40 videbaek // Make the xHitcorrection an adjusteble parameter. Default is 0.0095 which should // be good for the 2001/02 analysis. // // Revision 1.7 2002/04/16 11:48:33 ekman // Check that the status of the mrs track is OK before matching with tof hits. // // Revision 1.6 2002/04/09 02:09:31 ouerdane // removed name restriction from constructor (useless) // // Revision 1.5 2001/11/05 07:11:39 ouerdane // changed FFS to Ffs, BFS to Bfs, MRS to Mrs. Fixed bugs in BFS module // // Revision 1.4 2001/10/19 14:51:42 ouerdane // small error in panel local slat number determination // // Revision 1.3 2001/10/08 11:30:04 cholm // Changed to use new DB access classes // // Revision 1.2 2001/10/02 20:20:39 ouerdane // remove member fNoPanels and setter method since it is now part of the // tof detector parameter class. // Corrected errors due to fast rewriting of the modules. should be ok now. // // Revision 1.1 2001/10/02 02:05:25 ouerdane // Added modules combining and saving Tracks and Tof hits // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|