/////////////////////////////////////////////////////////////////////////////// // Dec 17 2000 P.Murat: simple ROOT-parsable description of CalTower // // Description of the inline functions: // -------------------------------------- // // - EmCOGPhi() : phi center of gravity by EM compartment // - EmPmt (i) : ADC counts in EM PMT channel 'i' // - Energy() : sum of EM and HAD energies // - HadPmt(i) : ADC counts in HAD PMT channel 'i' // - HadCOGPhi() : phi center of gravity by HAD compartment // // next 2 functions currently (Apr 15) are defined only for the central // calorimeter // // - HadTdc0() : CHA time for the central // - HadTdc1() : WHA time for the overlap between the central and the wall // // - Theta () : theta of the center of the tower // - Type () : returns type of the tower (1-9) // // Oct 13 2001: v2, pack all the floats into shorts, add ValidCode // // fCode: val_code&0xff + n0(TDC hits) << 8 + n1(TDC hits) << 12 /////////////////////////////////////////////////////////////////////////////// #include Int_t TCalTower::fgInitialized = 0; Double_t TCalTower::fgTheta[TOWER_NETA]; Double_t TCalTower::fgEta [TOWER_NETA+1]; Double_t TCalTower::fgThetaMP[2][84]; Double_t TCalTower::fgEtaMP [2][84]; Double_t TCalTower::fgPhiMP [2][84]; ClassImp(TCalTower) //______________________________________________________________________________ void TCalTower::ReadV1(TBuffer &R__b) { // read in version 1 of class TCalTower. // data members: 10 shorts, then 5 floats (40 bytes/tower + version) struct TCalTowerV1_t { Short_t fEtaPhi; // (ieta << 8)+iphi Short_t fHadTdc; // hadron TDC time Short_t fEmPmt [4]; // ADC counts in each EM channel Short_t fHadPmt[4]; // ADC counts in each HAD channel Float_t fHadEnergy; // hadron energy Float_t fEmEnergy; // EM energy Float_t fTheta; // half-sum of the boundaries (degrees) Float_t fHadCOGPhi; // hadron center-of-gravity phi Float_t fEmCOGPhi; // em center-of-gravity phi } tow; R__b.ReadFastArray(&tow.fEtaPhi,10); R__b.ReadFastArray(&tow.fHadEnergy,5); fCode = 0; fEtaPhi = tow.fEtaPhi; // timing was screwed in the previous // version anyway fHadTdc[0] = tow.fHadTdc; fHadTdc[1] = -100; memcpy(fEmPmt,tow.fEmPmt,8*sizeof(Short_t)); SetEmEnergy (tow.fEmEnergy ); SetHadEnergy(tow.fHadEnergy); SetEmCOGPhi (tow.fEmCOGPhi ); SetHadCOGPhi(tow.fHadCOGPhi); } //______________________________________________________________________________ void TCalTower::Streamer(TBuffer &R__b) { // Stream an object of class TCalTower. Starting from v2 it is 16 short words if (R__b.IsReading()) { Version_t R__v = R__b.ReadVersion(); if (R__v == 1) { ReadV1(R__b); } else if (R__v == 2) { R__b.ReadFastArray(&fCode,16); } } else { R__b.WriteVersion(TCalTower::IsA()); R__b.WriteFastArray(&fCode,16); } } //_____________________________________________________________________________ Int_t TCalTower::IEta(Float_t DetEta) { // return tower IEta for a given detector eta int ieta; for (ieta=0; ieta fgEta[ieta]) && (DetEta <= fgEta[ieta+1])) break; } if (ieta == TOWER_NETA) ieta = -1; return ieta; } //_____________________________________________________________________________ Float_t TCalTower::DEtaNorm(Float_t DetEta) { // return normalized distance to the center of the tower float deta; int i = TCalTower::IEta(DetEta); if (i >= 0) { deta = 2*(DetEta-(fgEta[i+1]+fgEta[i])/2)/(fgEta[i+1]-fgEta[i]); } else { deta = -100; } return deta; } //_____________________________________________________________________________ void TCalTower::InitStaticVariables() { float theta; for (int i=0; i 25) { int i1 = 51-i; fgTheta[i] = (TOWER_THETA[i1]+TOWER_THETA[i1+1])/2; theta = TMath::Pi()/180.*TOWER_THETA[i1+1]; fgEta [i] = -TMath::Log(fabs(TMath::Tan(theta/2.))); } } fgEta[TOWER_NETA] = -fgEta[0]; for (int is=0; is<2; is++) { for (int it=0; it<84; it++) { float mpx = MPA_XPositions[is][it]; float mpy = MPA_YPositions[is][it]; //--- theta and eta --- double rtow = sqrt(pow(mpx,2) + pow(mpy,2)); theta = atan(rtow/580.); // Z=580cm: MP front plane fgEtaMP [is][it] = -1.0*log(tan(0.5*theta)); fgThetaMP[is][it] = theta*180./TMath::Pi(); if (is==0) { theta = TMath::Pi() - theta; fgEtaMP [is][it] = -1.0*log(tan(0.5*theta)); fgThetaMP[is][it] = theta*180./TMath::Pi(); } //--- phi --- double dphi = atan(mpy/mpx); if (mpx<=0) dphi += TMath::Pi(); else if (mpx>0&&mpy<=0) dphi += 2*TMath::Pi(); fgPhiMP[is][it] = dphi; } } fgInitialized = 1; } //_____________________________________________________________________________ TCalTower::TCalTower() { fEtaPhi = 0xffff; if (! fgInitialized) TCalTower::InitStaticVariables(); } //_____________________________________________________________________________ TCalTower::~TCalTower() { } //_____________________________________________________________________________ void TCalTower::Clear(Option_t* opt) { } //_____________________________________________________________________________ void TCalTower::Print(Option_t* opt) const { if (strcmp(opt,"banner") == 0) { printf(" type ieta iphi Htdc0 Htdc1 "); printf(" Adc(em) --------- Adc(had) -------"); printf(" Ehad Eem Theta Et HadCogPhi EmCOgPhi\n"); } else { printf("%4i %4i %4i %4i %4i", Type(), IEta(),IPhi(), HadTdc(0), HadTdc(1)); // print ADC counts in the rest // chnnls, for the moment print just 2 int npmt, nem_pmt, nha_pmt; nem_pmt = NEmPmt (); nha_pmt = NHadPmt(); npmt = nem_pmt; if (npmt < nha_pmt) npmt = nha_pmt; for (int i=0; i<2; i++) { if (i=48) layer = 51-ieta; int phi = iphi; int tower = -1; if (layer == 3) { int wedge = phi / 5; int phiInWedge = phi % 5; tower = 9 + 14 * wedge + phiInWedge; } else if (layer == 2) { int wedge = phi / 4; int phiInWedge = phi % 4; tower = 5 + 14 * wedge + phiInWedge; } else if (layer == 1) { int wedge = phi / 3; int phiInWedge = phi % 3; tower = 2 + 14 * wedge + phiInWedge; } else if (layer == 0) { int wedge = phi / 2; int phiInWedge = phi % 2; tower = 14 * wedge + phiInWedge; } return tower; }