|
//____________________________________________________________________ // // Beam-Beam vertex module class // // Takes BB rdo objects/calhits and evaluate the vertex // by differentiating left and right // returns a BrBbVertex // This object contains: Z0, Time0 and method as times from // 1: big 2: small 3: fastest // BrBbCalHits 'rdo' objects // //____________________________________________________________________ // // $Id: BrBbVertexModule.cxx,v 1.12 2002/06/26 21:06:35 ouerdane Exp $ // $Author: ouerdane $ // $Date: 2002/06/26 21:06:35 $ // $Copyright: (C) 2001 BRAHMS Collaboration <brahmlib@rhic.bnl.gov> // #ifndef BRAT_BrBbVertexModule #include "BrBbVertexModule.h" #endif #ifndef BRAT_BrUnits #include "BrUnits.h" #endif #ifndef ROOT_TMath #include "TMath.h" #endif #ifndef ROOT_TDirectory #include "TDirectory.h" #endif #ifndef BRAT_BrCalibrationManager #include "BrCalibrationManager.h" #endif #include <BrIostream.h> //____________________________________________________________________ ClassImp(BrBbVertexModule); //____________________________________________________________________ BrBbVertexModule::BrBbVertexModule() { // Default constructor. DO NOT USE SetState(kSetup); fBblHits = 0; fBbrHits = 0; fVBig = 0; fVSmall = 0; fVFastest = 0; fUsedEvt = 0; fAccEvt = 0; fBigStat = 0; fSmallStat = 0; fFastestStat = 0; SetDefaultParameters(); } //____________________________________________________________________ BrBbVertexModule::BrBbVertexModule(const Char_t* name, const Char_t* title) : BrModule(name, title) { // Named Constructor SetState(kSetup); fBblHits = 0; fBbrHits = 0; fVBig = 0; fVSmall = 0; fVFastest = 0; fUsedEvt = 0; fAccEvt = 0; fBigStat = 0; fSmallStat = 0; fFastestStat = 0; SetDefaultParameters(); } //____________________________________________________________________ void BrBbVertexModule::SetDefaultParameters() { // set default parameter SetTreeOn(kFALSE); // default is false SetArrayDist(); // default is 219 cm SetZOffBig(); // default is 0 SetZOffSmall(); // default is 0 SetZOffFastest(); // default is 0 SetMaxTimeDiff(); // default is 0.5 ns SetOffsetCalib(kFALSE); // for offset calibration, must be true SetUseSqlOffset(kFALSE); // true if want to get offsets from sql DB } //____________________________________________________________________ BrBbVertexModule::~BrBbVertexModule() { // destructor if (fBblHits) delete fBblHits; if (fBbrHits) delete fBbrHits; if (fVBig) delete fVBig; if (fVSmall) delete fVSmall; if (fVFastest) delete fVFastest; } //____________________________________________________________________ void BrBbVertexModule::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(Form("%sVertex", GetName())); histDir->cd(); if (fTreeOn) { fBbVtxTree = new TTree("bbVtx", "BB Vertex and time0 Information"); fBbVtxTree->Branch("VtxBig", "BrBbVertex", &fVBig); fBbVtxTree->Branch("VtxSmall", "BrBbVertex", &fVSmall); fBbVtxTree->Branch("VtxFast", "BrBbVertex", &fVFastest); fBbVtxTree->Branch("LeftRdo", "BrBbCalHits", &fBblHits); fBbVtxTree->Branch("RightRdo", "BrBbCalHits", &fBbrHits); } // Make histograms here fVSB = new TH2F("Z0_SmallBig", "Vertex correlation between Small and Big tubes", 250, -250, 250, 250, -250, 250); fVSF = new TH2F("Z0_SmallFast", "Vertex correlation between Small and Fastest tubes", 250, -250, 250, 250, -250, 250); fVBF = new TH2F("Z0_BigFast", "Vertex correlation between Fastest and Big tubes", 250, -250, 250, 250, -250, 250); fTSB = new TH2F("T0_SmallBig", "Time0 correlation between Small and Big tubes", 200, 0, 100, 200, 0, 100); fTSF = new TH2F("T0_SmallFastest", "Time0 correlation between Small and Fastest tubes", 200, 0, 100, 200, 0, 100); fTBF = new TH2F("T0_BigFastest", "Time0 correlation between Fastest and Big tubes", 200, 0, 100, 200, 0, 100); fMethod = new TH1F("method", "Method statistics: " "0: failed, 1: big, 2: small, 3: fast tube", 20, -0.5, 3.5); fDiffSB = new TH1F("diffSmall_Big", "Difference Small - Big", 400, -20, 20); fDiffSF = new TH1F("diffSmall_Fastest", "Difference Small - Fastest", 400, -20, 20); fDiffBF = new TH1F("diffBig_Fastest", "Difference Big - Fastest", 400, -20, 20); fZBig = new TH1F("Z_Big", "Vertex from big tubes", 250, -250, 250); fZSmall = new TH1F("Z_Small", "Vertex from small tubes", 250, -250, 250); fZFastest = new TH1F("Z_Fastest", "Vertex from fastest tube", 250, -250, 250); fVertex = new TH1F("AcceptedVtx", "Accepted Vertex ", 250, -250, 250); fTBig = new TH1F("T0_Big", "Time0 from big tubes", 500, 0, 100); fTSmall = new TH1F("T0_Small", "Time0 from small tubes", 500, 0, 100); fTFastest = new TH1F("T0_Fastest", "Time0 from fastest tube", 500, 0, 100); fTime0 = new TH1F("Accepted_T0", "Accepted Time0 (ns)", 500, 0, 100); gDirectory = saveDir; } //____________________________________________________________________ void BrBbVertexModule::Init() { // Job-level initialisation SetState(kInit); // vertex objects fVBig = new BrBbVertex("BB Vertex Big", "BB Vertex Big"); fVSmall = new BrBbVertex("BB Vertex Small", "BB Vertex Small"); fVFastest = new BrBbVertex("BB Vertex Fastest", "BB Vertex Fastest"); if (fOffsetCalib) { SetZOffBig(0); SetZOffSmall(0); SetZOffFastest(0); } else if (fUseSqlOffset) { BrCalibrationManager* calman = BrCalibrationManager::Instance(); fCalibration = (BrVertexCalibration*)calman-> Register("BrVertexCalibration", "VERTEX"); BrCalibration::EAccessMode mode = BrCalibration::kRead; if (!fCalibration->GetAccessMode("BB")) { if (DebugLevel() > 3) Warning("Init", "BB Offsets will be read from DB"); fCalibration->Use("bbVertexOffset", mode, 6); } } } //____________________________________________________________________ void BrBbVertexModule::Begin() { // get the offsets from the calib object if (!fOffsetCalib && fUseSqlOffset) { if (!fCalibration->RevisionExists("*")) { Abort("Begin", "Cannot get offsets from the sql DB " "Set fUseSqlOffset to kFALSE and add offsets by hand with setters"); return; } SetZOffBig(fCalibration->GetBbBigOffset()); SetZOffSmall(fCalibration->GetBbSmallOffset()); SetZOffFastest(fCalibration->GetBbFastOffset()); } } //____________________________________________________________________ void BrBbVertexModule::Event(BrEventNode* inNode, BrEventNode* outNode) { // Per event method SetState(kEvent); // ------------------------------------------------- // Use for now algorithm of the old BrBbRdoModule // ------------------------------------------------- fBblHits = 0; fBbrHits = 0; fVBig->Clear(); fVBig->SetMethod(1); fVSmall->Clear(); fVSmall->SetMethod(2); fVFastest->Clear(); fVFastest->SetMethod(3); // get data from input node fBblHits = (BrBbCalHits*)inNode->GetObject("BbCalHits Left"); fBbrHits = (BrBbCalHits*)inNode->GetObject("BbCalHits Right"); // check output node (FIXE ME: use the switch module container) if (!fBblHits ) fBblHits = (BrBbCalHits*)outNode->GetObject("BbCalHits Left"); if (!fBbrHits) fBbrHits = (BrBbCalHits*)outNode->GetObject("BbCalHits Right"); if (!fBblHits || !fBbrHits) { if (Verbose() > 30) Warning("Event", "One array has NO hits. Giving up"); return; } fUsedEvt++; Int_t nl = fBblHits->GetEntries(); Int_t nr = fBbrHits->GetEntries(); if (!nl || !nr) return; // evaluate vertex with big tubes only // then small tubes only // then fastest tube Int_t lfast = fBblHits->GetFastest(); Int_t rfast = fBbrHits->GetFastest(); Vertex(fVBig, 37,44, 31,35, fZOffBig); // big tubes range Vertex(fVSmall, 1,36, 1,30, fZOffSmall); // small tube range Vertex(fVFastest, lfast,lfast, rfast,rfast, fZOffFastest); // fastest tubes // prepare output objects BrBbVertex* vtx = SaveBestVertex(outNode); // ------------------------- check vtxs: if (fVSmall->GetZ0() != 999) fSmallStat++; if (fVBig->GetZ0() != 999) fBigStat++; if (fVFastest->GetZ0() != 999) fFastestStat++; //------------------------------------------------- if (!HistOn()) return; // Z0 and T0 from the 3 methods fZSmall->Fill(fVSmall->GetZ0()); fTSmall->Fill(fVSmall->GetTime0()); fZBig->Fill(fVBig->GetZ0()); fTBig->Fill(fVBig->GetTime0()); fZFastest->Fill(fVFastest->GetZ0()); fTFastest->Fill(fVFastest->GetTime0()); // difference and correlation between vertices if (fVSmall->GetZ0() != 999 && fVBig->GetZ0() != 999) fDiffSB->Fill(fVSmall->GetZ0() - fVBig->GetZ0()); if (fVSmall->GetZ0() != 999 && fVFastest->GetZ0() != 999) fDiffSF->Fill(fVSmall->GetZ0() - fVFastest->GetZ0()); if (fVBig->GetZ0() != 999 && fVFastest->GetZ0() != 999) fDiffBF->Fill(fVBig->GetZ0() - fVFastest->GetZ0()); fVSB->Fill(fVBig->GetZ0(), fVSmall->GetZ0()); fVBF->Fill(fVFastest->GetZ0(), fVBig->GetZ0()); fVSF->Fill(fVFastest->GetZ0(), fVSmall->GetZ0()); fTSB->Fill(fVBig->GetTime0(), fVSmall->GetTime0()); fTBF->Fill(fVFastest->GetTime0(), fVBig->GetTime0()); fTSF->Fill(fVFastest->GetTime0(), fVSmall->GetTime0()); // tree if (fTreeOn) fBbVtxTree->Fill(); if (!vtx) { fMethod->Fill(0); fVertex->Fill(999); fTime0-> Fill(-1); return; } fMethod->Fill(vtx->GetMethod()); fVertex->Fill(vtx->GetZ0()); fTime0-> Fill(vtx->GetTime0()); } //____________________________________________________________________ void BrBbVertexModule::Vertex(BrBbVertex* vtx, Int_t lmin, Int_t lmax, Int_t rmin, Int_t rmax, Float_t zOffset) { // private method // ------------------------------------------------------------- // evaluate vertex with tubes between lmin, lmax and rmin, rmax // ------------------------------------------------------------- Float_t leftTime = 0; Float_t rightTime = 0; Float_t tmp = 0; Float_t nr = 0; Float_t nl = 0; // ----------------------------------------------- // -------- right array time for (Int_t i = 0; i < fBbrHits->GetEntries(); i++) { BrBbCalHits::BrBbHit* hit = fBbrHits->GetHit(i); if (hit->GetTubeNo() < rmin || hit->GetTubeNo() > rmax) continue; tmp += hit->GetTof(); nr++; } if (nr == 0) return; // average per tube rightTime = tmp/nr; // ----------------------------------------------- tmp = 0; // ------- left array time for (Int_t i = 0; i < fBblHits->GetEntries(); i++) { BrBbCalHits::BrBbHit* hit = fBblHits->GetHit(i); if (hit->GetTubeNo() < lmin || hit->GetTubeNo() > lmax) continue; tmp += hit->GetTof(); nl++; } if (nl == 0) return; // average per tube leftTime = tmp/nl; // ------------------------------------------------------------ // check now if there are some tubes too far off (from average) // ------------------------------------------------------------ nr = 0; nl = 0; tmp = 0; // -------- right array time for (Int_t i = 0; i < fBbrHits->GetEntries(); i++) { BrBbCalHits::BrBbHit* hit = fBbrHits->GetHit(i); if (hit->GetTubeNo() < rmin || hit->GetTubeNo() > rmax) continue; if (TMath::Abs(hit->GetTof() - rightTime) > fMaxTimeDiff) continue; tmp += hit->GetTof(); nr++; } if (nr == 0) return; // average per tube rightTime = tmp/nr; //----------------------------------------------- tmp = 0; // ------- left array time for (Int_t i = 0; i < fBblHits->GetEntries(); i++) { BrBbCalHits::BrBbHit* hit = fBblHits->GetHit(i); if (hit->GetTubeNo() < lmin || hit->GetTubeNo() > lmax) continue; if (TMath::Abs(hit->GetTof() - leftTime) > fMaxTimeDiff) continue; tmp += hit->GetTof(); nl++; } if (!nl) return; // average per tube leftTime = tmp/nl; // -------------- time 0 and vertex Double_t c = BrUnits::c_light; vtx->SetZ0(c/2 * (leftTime - rightTime) - zOffset); vtx->SetLeftTime(leftTime); vtx->SetRightTime(rightTime); vtx->SetTime0((leftTime + rightTime)/2 - (fArrayDist + zOffset)/c); } //__________________________________________________________________ BrBbVertex* BrBbVertexModule::SaveBestVertex(BrEventNode* outNode) { // add best vertex (?) to output node: // FIXME: for now, best is small, then big, then fastest // Note: fastest is usually pretty bad (/fv= 10/19/01) // See summary plots diffSF and compare to diffSB. BrBbVertex* vtx = 0; if (fVSmall->GetZ0() != 999) vtx = new BrBbVertex(*fVSmall); else if (fVBig->GetZ0() != 999) vtx = new BrBbVertex(*fVBig); else if (fVFastest->GetZ0() != 999) vtx = new BrBbVertex(*fVFastest); // save all if required (e.g. for offset calibration) if (fOffsetCalib) { if (fVSmall->GetZ0() != 999) outNode->AddObject(new BrBbVertex(*fVSmall)); if (fVBig->GetZ0() != 999) outNode->AddObject(new BrBbVertex(*fVBig)); if (fVFastest->GetZ0() != 999) outNode->AddObject(new BrBbVertex(*fVFastest)); } if (!vtx) return 0; // set the right name and title here only vtx->SetName("BB Vertex"); vtx->SetTitle("BB Vertex"); outNode->AddObject(vtx); fAccEvt++; if (Verbose() > 25) vtx->Print("A"); return vtx; } //__________________________________________________________________ void BrBbVertexModule::Finish() { SetState(kFinish); // prints out some stats: Float_t evEff = Float_t(fAccEvt)/Float_t(fUsedEvt); Float_t smEff = Float_t(fSmallStat)/Float_t(fAccEvt); Float_t bgEff = Float_t(fBigStat)/Float_t(fAccEvt); Float_t fsEff = Float_t(fFastestStat)/Float_t(fAccEvt); if (Verbose() > 0){ cout << " ---------------------------------------------" << "n Beam-Beam Vertex statistics: " << "n Events used : " << setw(8) << fUsedEvt << "n Accepted events : " << setw(8) << fAccEvt << "n Efficiency : " << setw(8) << evEff << "n Big Vertices : " << setw(8) << fBigStat << " --> efficiency: " << setw(8) << bgEff << "n Small Vertices : " << setw(8) << fSmallStat << " --> efficiency: " << setw(8) << smEff << "n Fastest Vertices : " << setw(8) << fFastestStat << " --> efficiency: " << setw(8) << fsEff << endl; if(HistOn()) cout << " Small - Fastest Vertex Diff " << setw(8) << fDiffSF->GetMean() << " +-" << fDiffSF->GetRMS() << "n Small - Big Vertex Diff " << setw(8) << fDiffSB->GetMean() << " +-" << fDiffSB->GetRMS() << endl; cout << "n ---------------------------------------------" << endl; } } //____________________________________________________________________ void BrBbVertexModule::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: ouerdane $" << endl << " $Date: 2002/06/26 21:06:35 $" << endl << " $Revision: 1.12 $ " << endl << endl << "-------------------------------------------------" << endl; } //____________________________________________________________________ // // $Log: BrBbVertexModule.cxx,v $ // Revision 1.12 2002/06/26 21:06:35 ouerdane // corrected error in cal paramater array dimension in Init() // // Revision 1.11 2001/12/13 12:40:57 ouerdane // increased verbosity level from 15 to 30 in Event // // Revision 1.10 2001/11/26 22:11:42 videbaek // Fix typo in name - and change z0 to z (in name only so far). // // Revision 1.9 2001/11/19 15:06:23 ouerdane // added histogram vtx big - vtx fastest // // Revision 1.8 2001/11/12 18:52:36 ouerdane // some int were in fact float...fixed // // Revision 1.7 2001/11/09 14:02:05 ufstasze // corrected small bug in detector name in GetAccessMode method // // Revision 1.6 2001/11/05 07:12:57 ouerdane // changed method SetUseSqlDb to SetUSeSqlOffset // // Revision 1.5 2001/11/02 11:47:13 ouerdane // added the offset calibration and a setter method SetUseSqlDb to get the offsets // // Revision 1.4 2001/11/02 10:29:10 ouerdane // Added a method SetOffsetCalib to be used with the vertex calibration module // If set to kTRUE, all the different vertices will be saved in the outputnode. // Note that the usual BB Vertex is still there. The others have an extension // to the name (BB Vertex Big | Small | Fastest) // // Revision 1.3 2001/10/19 15:37:10 videbaek // Added another diagnostic histogram (for diff) // Output summary differences. // Fixed error in calculating best mean. // // Revision 1.2 2001/09/27 08:58:47 ouerdane // Changed bb cal hits datatable names to Bb[l,r]CalHits // // Revision 1.1 2001/09/23 01:45:01 videbaek // Added the vertex module for Bb. SOmewhat like the BbRdomdoule // - tahnks to DO.. // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|