|
//____________________________________________________________________ // // Module to create vertex object for the Inel counters. // This is presently a combination of the calibrating module // and the one to calculate the vertex info. // a la BB with BbCalHits .. // Input: // Raw data from inel BbDig INL and BbDig INR // Output: // BrInelVertex // // Diagnostic histogram. // // Note: // The vertexoffsets can either be read from the Calibration DB or be set manually. // The vertex object should also have added some // of the halo information to check the quality of the Object, thus requiring both // a method (only one at present) as well as a staus/quality word.This is not done at present. // // A method SetOffsetCalib to be used with the vertex calibration module. // This is similar to how the BrBbVertexModule is used. Do also see // BrInelVertexCalModule. // //____________________________________________________________________ // // $Id: BrInelVertexModule.cxx,v 1.2 2002/08/30 17:04:29 hagel Exp $ // $Author: hagel $ // $Date: 2002/08/30 17:04:29 $ // $Copyright: (C) 2002 BRAHMS Collaboration <brahmlib@rhic.bnl.gov> // #if !defined BRAT_BrInelVertexModule #include "BrInelVertexModule.h" #endif #if !defined ROOT_TDirectory #include "TDirectory.h" #endif #if !defined ROOT_TNtuple #include "TNtuple.h" #endif #if !defined ROOT_TH1 #include "TH1.h" #endif #if !defined ROOT_TH2 #include "TH2.h" #endif #include <BrIostream.h> #if !defined BRAT_BrBbDig #include "BrBbDig.h" #endif #if !defined BRAT_BrEventNode #include "BrEventNode.h" #endif #if !defined BRAT_BrEvent #include "BrEvent.h" #endif #if !defined BRAT_BrEventNode #include "BrEventNode.h" #endif #if !defined BRAT_BrDataTable #include "BrDataTable.h" #endif #if !defined BRAT_BrBbVertex #include "BrBbVertex.h" #endif #if !defined BRAT_BrInelVertex #include "BrInelVertex.h" #endif #if !defined BRAT_BrBbRdo #include "BrBbRdo.h" #endif #if !defined BRAT_BrDetectorList #include "BrDetectorList.h" #endif #if !defined BRAT_BrPlane3D #include "BrPlane3D.h" #endif #if !defined BRAT_BrTrack #include "BrTrack.h" #endif #if !defined BRAT_BrGeometryDbManager #include "BrGeometryDbManager.h" #endif #if !defined BRAT_BrCoordinateSystem #include "BrCoordinateSystem.h" #endif #if !defined BRAT_BrBbCalibration #include "BrBbCalibration.h" #endif #if !defined BRAT_BrVertexCalibration #include "BrVertexCalibration.h" #endif #if !defined BRAT_BrCalibrationManager #include "BrCalibrationManager.h" #endif //____________________________________________________________________ ClassImp(BrInelVertexModule); //____________________________________________________________________ BrInelVertexModule::BrInelVertexModule() { // Default constructor. DO NOT USE SetState(kSetup); } //____________________________________________________________________ BrInelVertexModule::BrInelVertexModule(const Char_t* name, const Char_t* title) : BrModule(name, title) { // Named Constructor SetState(kSetup); fLeftLow = 40.; fLeftHigh = 50; fRightLow = 40; fRightHigh = 50; fCorrectTdc = kTRUE; fVertexOffset = 0.; fRange = 3.0; fNtuple = kFALSE; } //____________________________________________________________________ void BrInelVertexModule::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(GetName()); histDir->cd(); // Make histograms here hVertex = new TH1F("vertex","Inel vertex distribution",600, -600, 600); hVertexTrigger = new TH2F("vertexTrig","Inel vertex distribution for different triggers",600, -600, 600,9,1,8); htLR = new TH2F("tLR","Time left vs right", 500, fRightLow, fRightHigh, 500, fLeftLow, fLeftHigh); hInelTime = new TH2F("InelTimes","Aligned times vs tube",32,0.5,32.5,500, 0,100.); fhLeftDev = new TH1F("leftDev","Time dist around mean Left",100,-5.,5.); fhRightDev = new TH1F("rightDev","Time dist around mean Right",100,-5.,5.); if(fNtuple) fNtpInel = new TNtuple("inel", "Inel Trigger", "tl1:tl2:tl3:tl4:" "tr1:tr2:tr3:tr4:" "l11:l12:l13:l14:l21:l22:l23:l24:" "l31:l32:l33:l34:l41:l42:l43:l44:" "r11:r12:r13:r14:r21:r22:r23:r24:" "r31:r32:r33:r34:r41:r42:r43:r44:" "trig1:tl:tr:vert:nl:nr:lhalo:rhalo"); gDirectory = saveDir; } //____________________________________________________________________ void BrInelVertexModule::Init() { // Job-level initialisation SetState(kInit); BrGeometryDbManager* geomDb = BrGeometryDbManager::Instance(); // // register Calibration BrCalibrationManager *parMan = BrCalibrationManager::Instance(); if (!parMan) { Abort("Init", "Couldn't instantiate calibration manager"); return; } // get the calibration element (created in main) fLCalib = (BrBbCalibration*)parMan->Register("BrBbCalibration", "INL"); fRCalib = (BrBbCalibration*)parMan->Register("BrBbCalibration", "INR"); if (!fLCalib || !fRCalib) { Abort("Init", "Couldn't get INEL calibration parameters"); return; } if (!fLCalib->GetAccessMode("tdcGain")) fLCalib->Use("tdcGain", BrCalibration::kRead, 16); if (!fLCalib->GetAccessMode("deltaTdc")) fLCalib->Use("deltaTdc", BrCalibration::kRead, 16); if (!fRCalib->GetAccessMode("tdcGain")) fRCalib->Use("tdcGain", BrCalibration::kRead, 16); if (!fRCalib->GetAccessMode("deltaTdc")) fRCalib->Use("deltaTdc", BrCalibration::kRead, 16); // Offset calibration/ database // if (fOffsetCalib) { SetVertexOffset(0); } else if (fUseSqlOffset) { BrCalibrationManager* calman = BrCalibrationManager::Instance(); fCalibration = (BrVertexCalibration*)calman-> Register("BrVertexCalibration", "VERTEX"); BrCalibration::EAccessMode mode = BrCalibration::kRead; if (!fCalibration->GetAccessMode("Inel")) { if (DebugLevel() > 3) Warning("Init", "Inel Offsets will be read from DB"); fCalibration->Use("inelVertexOffset", mode, 2); } } } //____________________________________________________________________ void BrInelVertexModule::Begin() { // Run-level initialisation SetState(kBegin); if (!fLCalib->RevisionExists("*")) { Abort("Begin", "A revision is missing in Inel left"); return; } if (!fRCalib->RevisionExists("*")) { Abort("Begin", "A revision is missing in Inel right"); return; } if (Verbose() > 15) cout << " Found a revision for all INEL calibration parameters" << endl; // 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; } SetVertexOffset(fCalibration->GetInelOffset()); Info(3, "Init","Vertex Offset Used %f", fCalibration->GetInelOffset()); } } //____________________________________________________________________ void BrInelVertexModule::Event(BrEventNode* inNode, BrEventNode* outNode) { // Per event method SetState(kEvent); BrEvent *event = (BrEvent*) inNode; BrEventHeader* ehead = event->GetEventHeader(); Int_t trig1 = ehead->TriggerWord(1); int tleft[4]; int tright[4]; float lt[4][4]; float rt[4][4]; float l1[4],l2[4],l3[4],l4[4]; float r1[4],r2[4],r3[4],r4[4]; for(int j=0;j<4;j++) { tleft[j]=tright[j]=0; l1[j]=l2[j]=l3[j]=l4[j]=0; r1[j]=r2[j]=r3[j]=r4[j]=0; for(int k=0;k<4;k++) lt[k][j]=rt[k][j]=0; } int lefthalo=0; int righthalo=0; int leftHits=0; int rightHits=0; BrDataTable* tab = (BrDataTable*) inNode->GetObject("BbDig Inel"); if(tab){ for(int k=0;k<tab->GetEntries();k++){ BrBbDig* trig = (BrBbDig*) tab->At(k); int tdc = trig->GetTdc(); int tube = trig->GetTubeNo(); if(tdc>50 && tdc < 3800){ switch(tube) { case 1: tleft[3]=tdc; break; case 2: tleft[2]=tdc; break; case 3: tleft[1]=tdc; break; case 4: tleft[0]=tdc; break; case 5: tright[3]=tdc; break; case 6: tright[2]=tdc; break; case 7: tright[1]=tdc; break; case 8: tright[0]=tdc; break; } } } } // end tab for Ring counters. Float_t tl[16], tr[16]; // Right counters only // tab = (BrDataTable*) inNode->GetObject("BbDig INR"); if(tab){ for(int k=0;k<tab->GetEntries();k++){ BrBbDig* trig = (BrBbDig*) tab->At(k); int tdc = trig->GetTdc(); int tube = trig->GetTubeNo(); if(tube <1 || tube >16){ Warning("Bad decoding","Tube is %d",tube); return; } // check if calibration ok for this tube if (!fRCalib->ValidCalibration(tube)) continue; Float_t tdg = fRCalib->GetTdcGain(tube); Float_t del = fRCalib->GetDeltaTdc(tube); Int_t ring = (16-tube)/4+1; Int_t el = (tube-1)%4; Int_t delayIndex = (ring-1)*4+el; if(tdc>50 && tdc < 4000){ if(DebugLevel()>10) { cout << " tube " << setw(6) << tube << setw(6) << ring << setw(6) << el << endl; } Float_t t = tdc*tdg; if(fCorrectTdc){ t -=del; tr[rightHits] = t; } else tr[rightHits] = t - del; if(HistOn()) hInelTime->Fill(tube+16, tr[rightHits]); rightHits++; switch(ring) { case 1: rt[0][el]=t; r1[el]= t; break; case 2: rt[1][el]=t; r2[el]= t; break; case 3: rt[2][el]=t; r3[el]= t; break; case 4: rt[3][el]=t; r4[el]= t; break; } } } } // end tab for Individual Ring counters. // Left counters only // tab = (BrDataTable*) inNode->GetObject("BbDig INL"); if(tab){ for(int k=0;k<tab->GetEntries();k++){ BrBbDig* trig = (BrBbDig*) tab->At(k); int tdc = trig->GetTdc(); int tube = trig->GetTubeNo(); if(tube <1 || tube >16){ Warning("Bad decoding","Tube is %d",tube); return; } // check if calibration ok for this tube if (!fLCalib->ValidCalibration(tube)){ Warning("Event","No calibration for left tube %d", tube); continue; } Float_t tdg = fLCalib->GetTdcGain(tube); Float_t del = fLCalib->GetDeltaTdc(tube); Int_t ring = (16-tube)/4+1; Int_t el = (tube-1)%4; Int_t delayIndex = (ring-1)*4+el; if(tdc>50 && tdc < 4000){ if(DebugLevel()>10) { cout << " tube " << setw(6) << tube << setw(6) << ring << setw(6) << el << endl; } Float_t t = tdc*tdg; if(fCorrectTdc){ t -=del; tl[leftHits] = t; } else { tl[leftHits] = t - del; } if(HistOn()) hInelTime->Fill(tube, tl[leftHits]); leftHits++; switch(ring) { case 1: lt[0][el]=t; l1[el] = t; break; case 2: lt[1][el]=t; l2[el] = t; break; case 3: lt[2][el]=t; l3[el] = t; break; case 4: lt[3][el]=t; l4[el] = t; break; } } } } // end tab for Individual Ring counters. Int_t nghits=0; Float_t timel=0; if(leftHits>0){ for(int k=0;k<leftHits;k++) if(tl[k]>fLeftLow && tl[k]< fLeftHigh) { timel+=tl[k]; nghits++; } if(nghits) timel = timel/nghits; if(HistOn() && nghits){ for(int k=0;k<leftHits;k++) if(tl[k]>fLeftLow && tl[k]< fLeftHigh) fhLeftDev->Fill(timel-tl[k]); } } nghits=0; Float_t timer=0; if(rightHits>0){ for(int k=0;k<rightHits;k++) if(tr[k]>fRightLow && tr[k]< fRightHigh){ timer+=tr[k]; nghits++; } if(nghits) timer = timer/nghits; if(HistOn() && nghits){ for(int k=0;k<rightHits;k++) if(tr[k]>fRightLow && tr[k]< fRightHigh) fhRightDev->Fill(timer-tr[k]); } } Float_t vert = 9999; if(timel && timer) vert = (timel-timer)*15.0 - fVertexOffset; // // Performe an evaluation of the chance that the events is caused // by halo events in the ring counters. // // The idea is that the aligned time differences in the same side // must be centeres around zero (with a sgima of ~50 channels. // Data outside 0+-3 sigma is likely caused by or has contamination of halo // in the data. // The first attempt seem to indicate a cutdown factor of about 2 for // the 'background in the first inel sets. A larger halo cut value reduces // real vertex cont significantly. // for(int ring=0;ring<3;ring++) for(int r=ring+1;r<4;r++) for(int i=0;i<4;i++) for(int j=0;j<4;j++){ if(lt[ring][i]>0 && lt[r][j]>0 && (lt[ring][i]-lt[r][j]>fRange*48.)) lefthalo++; if(rt[ring][i]>0 && rt[r][j]>0 && rt[ring][i]-rt[r][j]>fRange*48.) righthalo++; } if(HistOn()){ htLR->Fill(timer,timel,1.0); hVertex->Fill(vert); //Now, fill the vertex distribution for different triggers for(Int_t itrig=0;itrig<8;itrig++) { if(trig1&(1<<(itrig+8))) hVertexTrigger->Fill(vert,itrig+1); } if(fNtuple) { int nsize = 8+32+1+2+3+2; Float_t ntVar[nsize]; for(int i=0;i<4;i++){ ntVar[i] = tleft[i]; ntVar[i+4] = tright[i]; ntVar[i+8] = l1[i]; ntVar[i+12] = l2[i]; ntVar[i+16] = l3[i]; ntVar[i+20] = l4[i]; ntVar[i+24] = r1[i]; ntVar[i+28] = r2[i]; ntVar[i+32] = r3[i]; ntVar[i+36] = r4[i]; }; ntVar[40] = trig1; ntVar[41] = timel; ntVar[42] = timer; ntVar[43] = vert; ntVar[44] = leftHits; ntVar[45] = rightHits; ntVar[46] = lefthalo; ntVar[47] = righthalo; fNtpInel->Fill(ntVar); } } // // Create a new vertex object if(vert < 9998){ BrInelVertex* inelVertex = new BrInelVertex("InelVertex","rdo"); inelVertex->SetZ(vert); inelVertex->SetLeftTime(timel); inelVertex->SetRightTime(timer); inelVertex->SetTime0((timel+timer)/2.); inelVertex->SetMethod(1); outNode->AddObject(inelVertex); } } //____________________________________________________________________ void BrInelVertexModule::End() { // Run-level finalisation SetState(kEnd); } //____________________________________________________________________ void BrInelVertexModule::Finish() { // Job-level finalisation SetState(kFinish); } //____________________________________________________________________ void BrInelVertexModule::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: Flemming Videbaek" << endl << " Last Modifications: " << endl << " $Author: hagel $" << endl << " $Date: 2002/08/30 17:04:29 $" << endl << " $Revision: 1.2 $ " << endl << endl << "-------------------------------------------------" << endl; } //____________________________________________________________________ // // $Log: BrInelVertexModule.cxx,v $ // Revision 1.2 2002/08/30 17:04:29 hagel // Add array of vertex distribution for different triggers // // Revision 1.1 2002/06/07 15:56:38 videbaek // Add the BrInelVertexModule to the depository. This is used for the // pp running (Jan 2002) analysis only. // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|