Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

TkrNtupleAlg.cpp

Go to the documentation of this file.
00001 // Implements ntuple writing algorithm
00002 
00003 #include "TkrRecon/TkrNtupleAlg.h"
00004 #include "TkrRecon/SiClusters.h"
00005 
00006 #include <algorithm>
00007 inline static double sqr(double x) {return x*x;}
00008 using namespace std;
00009 
00010 static const AlgFactory<TkrNtupleAlg>  Factory;
00011 const IAlgFactory& TkrNtupleAlgFactory = Factory;
00012 
00013 
00014 //###############################
00015 TkrNtupleAlg::TkrNtupleAlg(const std::string& name, ISvcLocator* pSvcLocator) :
00016               Algorithm(name, pSvcLocator)
00017 //###############################
00018 {
00019     declareProperty("tupleName", m_tupleName="");
00020 }
00021 
00022 //###############################
00023 StatusCode TkrNtupleAlg::initialize() 
00024 //###############################
00025 {       
00026         StatusCode sc = StatusCode::SUCCESS;
00027 
00028     MsgStream log(msgSvc(), name());
00029     log << MSG::INFO << "initialize" << endreq;
00030 
00031     // Use the Job options service to set the Algorithm's parameters
00033     setProperties();
00034 
00035     // get a pointer to our ntupleWriterSvc
00036     sc = service("ntupleWriterSvc", ntupleWriteSvc);
00037 
00038     if( sc.isFailure() ) 
00039     {
00040         log << MSG::ERROR << "TkrNtupleAlg failed to get the ntupleWriterSvc" << endreq;
00041         return sc;
00042     }
00043 
00044         return sc;
00045 }
00046 //--------------------------------------------------------
00047 //     Execution Function fills the ntuple
00048 //--------------------------------------------------------
00049 //###############################
00050 StatusCode TkrNtupleAlg::execute() 
00051 //###############################
00052 {       
00054     StatusCode sc = StatusCode::SUCCESS;
00055 
00056     //Create the tuple class
00057     TkrTupleValues pTuple;
00058     
00059     SiRecObjs*  pSiRecObjs  = SmartDataPtr<SiRecObjs>(eventSvc(),"/Event/TkrRecon/SiRecObjs");
00060         SiClusters* pSiClusters = SmartDataPtr<SiClusters>(eventSvc(),"/Event/TkrRecon/SiClusters");
00061 
00062     if ((sc = pTuple.calcTupleValues(pSiClusters, pSiRecObjs)).isFailure()) return sc;
00063 
00064     return pTuple.fillTupleValues(ntupleWriteSvc, m_tupleName.c_str());
00065 }
00066 //###############################
00067 StatusCode TkrNtupleAlg::finalize() 
00068 //###############################
00069 {       
00070         StatusCode sc = StatusCode::SUCCESS;
00071 
00072     return sc;
00073 }
00074 
00075 
00076 
00077 //
00078 //Implementation of the TkrTupleValues class begins here
00079 //
00080 
00081 //################################
00082 TkrTupleValues::TkrTupleValues()
00083 //################################
00084 {
00085     int nLyrs = NPLANES;
00086 
00087     Tkr_HitsPerLyr.clear();
00088     while(nLyrs--) {Tkr_HitsPerLyr.push_back(0);}
00089 
00090     Tkr_Cnv_Lyr_Hits = 0;
00091     Tkr_Max_controller_hits = 0;
00092     Tkr_Fst_Cnv_Lyr = 0;
00093     Tkr_NCnv_Lyrs_Hit = 0;
00094 
00095     Tkr_No_X_Trks = 0;
00096     Tkr_No_Y_Trks = 0;
00097     Tkr_No_Tracks = 0;
00098     Tkr_Fit_Type = 0;
00099     Tkr_Fit_Topo = 0;
00100     Tkr_Chisq = 0;
00101     Tkr_Chisq_1st = 0;
00102     Tkr_qual_X = 0;
00103     Tkr_qual_Y = 0;
00104     Tkr_qual = 0;
00105     Tkr_No_Hits = 0;
00106     Tkr_No_Gaps = 0;
00107     Tkr_No_Gaps_1st = 0;
00108     Tkr_No_Noise = 0;
00109     Tkr_No_Noise_1st = 0;
00110     Tkr_Fit_XNhits = 0;
00111     Tkr_Fit_YNhits = 0;
00112     Tkr_Fit_XChisq = 0;
00113     Tkr_Fit_YChisq = 0;
00114     Tkr_Fit_XChisq_1st = 0;
00115     Tkr_Fit_YChisq_1st = 0;
00116     Tkr_Fit_XKalEne = 0;
00117     Tkr_Fit_YKalEne = 0;
00118     Tkr_Fit_XKalThetaMS = 0;
00119     Tkr_Fit_YKalThetaMS = 0;
00120     Tkr_Fit_xdir = 0;
00121     Tkr_Fit_ydir = 0;
00122     Tkr_Fit_zdir = 0;
00123     Tkr_Fit_x0 = 0;
00124     Tkr_Fit_y0 = 0;
00125     Tkr_Fit_z0 = 0;
00126     Tkr_Pair_xdir = 0;
00127     Tkr_Pair_ydir = 0;
00128     Tkr_Pair_zdir = 0;
00129     Tkr_Pair_x0 = 0;
00130     Tkr_Pair_y0 = 0;
00131     Tkr_Pair_z0 = 0;
00132     Tkr_Gamma_xdir = 0;
00133     Tkr_Gamma_ydir = 0;
00134     Tkr_Gamma_zdir = 0;
00135     Tkr_Gamma_x0 = 0;
00136     Tkr_Gamma_y0 = 0;
00137     Tkr_Gamma_z0 = 0;
00138     Tkr_Gamma_DLT = 0;
00139     Tkr_Pair_XNhits = 0;
00140     Tkr_XChisq = 0;
00141     Tkr_XChisq_1st = 0;
00142     Tkr_XKalEne = 0;
00143     Tkr_XKalThetaMS = 0;
00144     Tkr_Pair_YNhits = 0;
00145     Tkr_YChisq = 0;
00146     Tkr_YChisq_1st = 0;
00147     Tkr_YKalEne = 0;
00148     Tkr_YKalThetaMS = 0;
00149     Tkr_errSlopeX = 0;
00150     Tkr_errSlopeY = 0;
00151     Tkr_xeneXSlope = 0;
00152     Tkr_xeneYSlope = 0;
00153     Tkr_weightXSlope = 0;
00154     Tkr_weightYSlope = 0;
00155     Tkr_First_XHit = 1000.;
00156     Tkr_Zbottom = 1000.;
00157     Tkr_Diff_1st_Hit = 0;
00158     Tkr_Fit_Kink = 0;
00159     Tkr_Fit_KinkN = 0;
00160     Tkr_Pair_Kink = 0;
00161     Tkr_Pair_KinkN = 0;
00162 };
00163 
00164 //################################
00165 StatusCode TkrTupleValues::calcTupleValues(SiClusters* pClusters, SiRecObjs* pRecObjs)
00166 //################################
00167 {
00168         StatusCode sc = StatusCode::SUCCESS;
00169 
00170     //Make sure we have valid cluster data
00171     if (pClusters)
00172     {
00173         int planeIdx = NPLANES;
00174         while(planeIdx--)
00175         {
00176             int hitCount = pClusters->nHits(SiCluster::X, planeIdx) 
00177                          + pClusters->nHits(SiCluster::Y, planeIdx);
00178 
00179             if (hitCount > 0)
00180             {
00181                 Tkr_Fst_Cnv_Lyr    = planeIdx;
00182                 Tkr_NCnv_Lyrs_Hit += 1;
00183             }
00184 
00185             Tkr_HitsPerLyr[planeIdx] = hitCount;
00186         }
00187 
00188         Tkr_Cnv_Lyr_Hits = pClusters->nHits();
00189     }
00190 
00191     //Make sure we have valid reconstructed data
00192     if (pRecObjs)
00193     {
00194         unsigned int  ngammas = pRecObjs->numGammas();
00195 
00196         if (ngammas == 0)   return sc;
00197 
00198         //Count the number of tracks in the two gammas
00199         while(ngammas--)
00200         {
00201             GFgamma* pGam = pRecObjs->Gamma(ngammas);
00202 
00203             if (!pGam->empty())
00204             {
00205                 if (!pGam->getBest(SiCluster::X)->empty()) Tkr_No_X_Trks += 1;
00206                 if (!pGam->getBest(SiCluster::Y)->empty()) Tkr_No_Y_Trks += 1;
00207                 if (!pGam->getPair(SiCluster::X)->empty()) Tkr_No_X_Trks += 1;
00208                 if (!pGam->getPair(SiCluster::Y)->empty()) Tkr_No_Y_Trks += 1;
00209             }
00210         }
00211 
00212         // Count number of tracks in the particles
00213         int nParticles = pRecObjs->numParticles();
00214 
00215         while(nParticles--)
00216         {
00217             GFparticle* pPart = pRecObjs->Particle(nParticles);
00218 
00219             if (!pPart->empty())
00220             {
00221                 if (!pPart->getXGFtrack()->empty()) Tkr_No_X_Trks += 1;
00222                 if (!pPart->getYGFtrack()->empty()) Tkr_No_Y_Trks += 1;
00223             }
00224         }
00225 
00226         // Total number of tracks is just the sum
00227         Tkr_No_Tracks   = Tkr_No_X_Trks + Tkr_No_Y_Trks;
00228     
00229 
00230         // Right now we are assuming that the first gamma is the "right" gamma
00231         GFgamma* gamma  = pRecObjs->Gamma(0);
00232 
00233         // If the gamma has no tracks then no point in going on 
00234         if (gamma->empty()) return sc;
00235 
00236         GFtrack* _Xbest = gamma->getXpair()->getBest();
00237         GFtrack* _Ybest = gamma->getYpair()->getBest();
00238 
00239         int      nHitsX = _Xbest->numDataPoints();
00240         int      nHitsY = _Ybest->numDataPoints();
00241     
00242         // Gamma quality
00243         double type = 0;
00244         if (!gamma->empty()) type = 11;
00245         if (!gamma->getPair(SiCluster::X)->empty()) type += 1;
00246         if (!gamma->getPair(SiCluster::Y)->empty()) type += 10;
00247         Tkr_Fit_Type = type;
00248     
00249         double topo = 0;
00250         if (gamma->fix()) topo = 1.;
00251         if (gamma->conflictPattern()) topo *= -1.;
00252         Tkr_Fit_Topo = topo;
00253     
00254         Tkr_Chisq           = _Xbest->chiSquare() + _Ybest->chiSquare();
00255         Tkr_Chisq_1st       = _Xbest->chiSquareSegment() + _Ybest->chiSquareSegment();
00256         Tkr_qual_X          = _Xbest->Q();
00257         Tkr_qual_Y          = _Ybest->Q();
00258         Tkr_qual            = _Xbest->Q() + _Ybest->Q();
00259         Tkr_No_Hits         =  nHitsX + nHitsY;
00260         Tkr_No_Gaps         = _Xbest->numGaps()+_Ybest->numGaps();
00261         Tkr_No_Gaps_1st     = _Xbest->numFirstGaps()+_Ybest->numFirstGaps();
00262         Tkr_No_Noise        = _Xbest->numNoise()+_Ybest->numNoise();
00263         Tkr_No_Noise_1st    = _Xbest->numFirstNoise()+_Ybest->numFirstNoise();
00264 
00265         // Pair reconstruction
00266         Tkr_Fit_XNhits      = _Xbest->nhits();
00267         Tkr_Fit_YNhits      = _Ybest->nhits();
00268         Tkr_Fit_XChisq      = _Xbest->chiSquare();
00269         Tkr_Fit_YChisq      = _Ybest->chiSquare();
00270         Tkr_Fit_XChisq_1st  = _Xbest->chiSquareSegment();
00271         Tkr_Fit_YChisq_1st  = _Ybest->chiSquareSegment();
00272         Tkr_Fit_XKalEne     = _Xbest->RCenergy();
00273         Tkr_Fit_YKalEne     = _Ybest->RCenergy();
00274         Tkr_Fit_XKalThetaMS = _Xbest->KalThetaMS();
00275         Tkr_Fit_YKalThetaMS = _Ybest->KalThetaMS();
00276 
00277 
00278         //Calculate the vertices and directions for everyone...
00279         Point  x1 = GFdata::doVertex(gamma->getBest(SiCluster::X)->ray(),
00280                                      gamma->getBest(SiCluster::Y)->ray());
00281         Vector t1 = GFdata::doDirection(gamma->getBest(SiCluster::X)->direction(),
00282                                         gamma->getBest(SiCluster::Y)->direction());
00283     
00284         Point  x2 = x1;
00285         Vector t2 = t1;
00286         if (!gamma->getPair(SiCluster::X)->empty() && !gamma->getPair(SiCluster::Y)->empty()) 
00287         {
00288             x2 = GFdata::doVertex(gamma->getPair(SiCluster::X)->ray(),
00289                                   gamma->getPair(SiCluster::Y)->ray());
00290             t2 = GFdata::doDirection(gamma->getPair(SiCluster::X)->direction(),
00291                                      gamma->getPair(SiCluster::Y)->direction());
00292         }
00293         
00294         Point  x0 = gamma->vertex();
00295         Vector t0 = gamma->direction();
00296     
00297         Tkr_Fit_xdir        = t1.x();
00298         Tkr_Fit_ydir        = t1.y();
00299         Tkr_Fit_zdir        = t1.z();
00300         Tkr_Fit_x0          = x1.x();
00301         Tkr_Fit_y0          = x1.y();
00302         Tkr_Fit_z0          = x1.z();
00303     
00304         Tkr_Pair_xdir       = t2.x();
00305         Tkr_Pair_ydir       = t2.y();
00306         Tkr_Pair_zdir       = t2.z();
00307         Tkr_Pair_x0         = x2.x();
00308         Tkr_Pair_y0         = x2.y();
00309         Tkr_Pair_z0         = x2.z();
00310     
00311         Tkr_Gamma_xdir      = t0.x();
00312         Tkr_Gamma_ydir      = t0.y();
00313         Tkr_Gamma_zdir      = t0.z();
00314         Tkr_Gamma_x0        = x0.x();
00315         Tkr_Gamma_y0        = x0.y();
00316         Tkr_Gamma_z0        = x0.z();
00317         
00318         float sinDLT = sqrt(std::max(0.0,(1. - sqr(t0*t1))));
00319         Tkr_Gamma_DLT       = sinDLT;
00320     
00321         GFtrack* _Xpair = gamma->getXpair()->getPair();
00322         GFtrack* _Ypair = gamma->getYpair()->getPair();
00323 
00324         if (!_Xpair->empty()) 
00325         {
00326             Tkr_Pair_XNhits = _Xpair->nhits();
00327             Tkr_XChisq      = _Xpair->chiSquare();
00328             Tkr_XChisq_1st  = _Xpair->chiSquareSegment();
00329             Tkr_XKalEne     = _Xpair->RCenergy();
00330             Tkr_XKalThetaMS =_Xpair->KalThetaMS();
00331         }
00332         if (!_Ypair->empty()) 
00333         {
00334             Tkr_Pair_YNhits = _Ypair->nhits();
00335             Tkr_YChisq      = _Ypair->chiSquare();
00336             Tkr_YChisq_1st  = _Ypair->chiSquareSegment();
00337             Tkr_YKalEne     = _Ypair->RCenergy();
00338             Tkr_YKalThetaMS = _Ypair->KalThetaMS();
00339         }
00340 
00341         Tkr_errSlopeX       = gamma->getXpair()->errorSlope();
00342         Tkr_errSlopeY       = gamma->getYpair()->errorSlope();
00343         Tkr_xeneXSlope      = gamma->getXpair()->RCenergy();
00344         Tkr_xeneYSlope      = gamma->getYpair()->RCenergy();
00345         Tkr_weightXSlope    = gamma->getXpair()->weightSlope();
00346         Tkr_weightYSlope    = gamma->getYpair()->weightSlope();
00347     
00348         //      First Used Layer and previous Hits...
00349         int x_layer         = _Xbest->firstLayer();
00350         Tkr_First_XHit      =  x_layer;
00351         int y_layer         = _Ybest->firstLayer();
00352         int diffXY          =  x_layer - y_layer;
00353         Tkr_Diff_1st_Hit    =  diffXY;
00354 
00355         double lastHitX     = Tkr_First_XHit;
00356         double lastHitY     = Tkr_First_XHit;
00357 
00358         if (nHitsX > 0) lastHitX = _Xbest->kplanelist[nHitsX-1].getZPlane();
00359         if (nHitsY > 0) lastHitY = _Ybest->kplanelist[nHitsY-1].getZPlane();
00360 
00361         Tkr_Zbottom         = lastHitX < lastHitY ? lastHitX : lastHitY;
00362 
00363         // Calculate the fit kink quantities
00364         calcFitKink(gamma);
00365     }
00366     
00367     return sc;
00368 }
00369 
00370 //################################
00371 StatusCode TkrTupleValues::fillTupleValues(INTupleWriterSvc* pSvc, const char* pName)
00372 //################################
00373 {
00374         StatusCode sc = StatusCode::SUCCESS;
00375 
00376     if (pSvc)
00377     {
00378         if ((sc = pSvc->addItem(pName, "TKR_Cnv_Lyr_Hits",        Tkr_Cnv_Lyr_Hits       )).isFailure()) return sc;
00379         if ((sc = pSvc->addItem(pName, "TKR_Max_controller_hits", Tkr_Max_controller_hits)).isFailure()) return sc;
00380         if ((sc = pSvc->addItem(pName, "TKR_Fst_Cnv_Lyr",         Tkr_Fst_Cnv_Lyr        )).isFailure()) return sc;
00381         if ((sc = pSvc->addItem(pName, "TKR_NCnv_Lyrs_Hit",       Tkr_NCnv_Lyrs_Hit      )).isFailure()) return sc;
00382 
00383         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_0",       Tkr_HitsPerLyr[0]      )).isFailure()) return sc;
00384         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_1",       Tkr_HitsPerLyr[1]      )).isFailure()) return sc;
00385         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_2",       Tkr_HitsPerLyr[2]      )).isFailure()) return sc;
00386         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_3",       Tkr_HitsPerLyr[3]      )).isFailure()) return sc;
00387         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_4",       Tkr_HitsPerLyr[4]      )).isFailure()) return sc;
00388         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_5",       Tkr_HitsPerLyr[5]      )).isFailure()) return sc;
00389         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_6",       Tkr_HitsPerLyr[6]      )).isFailure()) return sc;
00390         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_7",       Tkr_HitsPerLyr[7]      )).isFailure()) return sc;
00391         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_8",       Tkr_HitsPerLyr[8]      )).isFailure()) return sc;
00392         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_9",       Tkr_HitsPerLyr[9]      )).isFailure()) return sc;
00393         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_10",      Tkr_HitsPerLyr[10]     )).isFailure()) return sc;
00394         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_11",      Tkr_HitsPerLyr[11]     )).isFailure()) return sc;
00395         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_12",      Tkr_HitsPerLyr[12]     )).isFailure()) return sc;
00396         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_13",      Tkr_HitsPerLyr[13]     )).isFailure()) return sc;
00397         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_14",      Tkr_HitsPerLyr[14]     )).isFailure()) return sc;
00398         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_15",      Tkr_HitsPerLyr[15]     )).isFailure()) return sc;
00399         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_16",      Tkr_HitsPerLyr[16]     )).isFailure()) return sc;
00400         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_17",      Tkr_HitsPerLyr[17]     )).isFailure()) return sc;
00401         if ((sc = pSvc->addItem(pName, "TKR_Hits_In_Lyr_18",      Tkr_HitsPerLyr[18]     )).isFailure()) return sc;
00402 
00403         //Reconstructed stuff starts here        
00404         if ((sc = pSvc->addItem(pName, "TKR_No_X_Trks",       Tkr_No_X_Trks      )).isFailure()) return sc;
00405         if ((sc = pSvc->addItem(pName, "TKR_No_Y_Trks",       Tkr_No_Y_Trks      )).isFailure()) return sc;
00406         if ((sc = pSvc->addItem(pName, "TKR_No_Tracks",       Tkr_No_Tracks      )).isFailure()) return sc;
00407         if ((sc = pSvc->addItem(pName, "TKR_Fit_Type",        Tkr_Fit_Type       )).isFailure()) return sc;
00408         if ((sc = pSvc->addItem(pName, "TKR_Fit_Topo",        Tkr_Fit_Topo       )).isFailure()) return sc;
00409         if ((sc = pSvc->addItem(pName, "TKR_Chisq",           Tkr_Chisq          )).isFailure()) return sc;
00410         if ((sc = pSvc->addItem(pName, "TKR_Chisq_1st",       Tkr_Chisq_1st      )).isFailure()) return sc;
00411         if ((sc = pSvc->addItem(pName, "TKR_qual_X",          Tkr_qual_X         )).isFailure()) return sc;
00412         if ((sc = pSvc->addItem(pName, "TKR_qual_Y",          Tkr_qual_Y         )).isFailure()) return sc;
00413         if ((sc = pSvc->addItem(pName, "TKR_qual",            Tkr_qual           )).isFailure()) return sc;
00414         if ((sc = pSvc->addItem(pName, "TKR_No_Hits",         Tkr_No_Hits        )).isFailure()) return sc;
00415         if ((sc = pSvc->addItem(pName, "TKR_Fit_Gaps",        Tkr_No_Gaps        )).isFailure()) return sc;
00416         if ((sc = pSvc->addItem(pName, "TKR_First_Fit_Gaps",  Tkr_No_Gaps_1st    )).isFailure()) return sc;
00417         if ((sc = pSvc->addItem(pName, "TKR_No_Noise",        Tkr_No_Noise       )).isFailure()) return sc;
00418         if ((sc = pSvc->addItem(pName, "TKR_No_Noise_1st",    Tkr_No_Noise_1st   )).isFailure()) return sc;
00419 
00420         // Pair reconstruction
00421         if ((sc = pSvc->addItem(pName, "TKR_Fit_XNhits",      Tkr_Fit_XNhits     )).isFailure()) return sc;
00422         if ((sc = pSvc->addItem(pName, "TKR_Fit_YNhits",      Tkr_Fit_YNhits     )).isFailure()) return sc;
00423         if ((sc = pSvc->addItem(pName, "TKR_Fit_XChisq",      Tkr_Fit_XChisq     )).isFailure()) return sc;
00424         if ((sc = pSvc->addItem(pName, "TKR_Fit_YChisq",      Tkr_Fit_YChisq     )).isFailure()) return sc;
00425         if ((sc = pSvc->addItem(pName, "TKR_Fit_XChisq_1st",  Tkr_Fit_XChisq_1st )).isFailure()) return sc;
00426         if ((sc = pSvc->addItem(pName, "TKR_Fit_YChisq_1st",  Tkr_Fit_YChisq_1st )).isFailure()) return sc;
00427         if ((sc = pSvc->addItem(pName, "TKR_Fit_XKalEne" ,    Tkr_XKalEne        )).isFailure()) return sc;
00428         if ((sc = pSvc->addItem(pName, "TKR_Fit_YKalEne" ,    Tkr_YKalEne        )).isFailure()) return sc;
00429         if ((sc = pSvc->addItem(pName, "TKR_Fit_XKalThetaMS", Tkr_Fit_XKalThetaMS)).isFailure()) return sc;
00430         if ((sc = pSvc->addItem(pName, "TKR_Fit_YKalThetaMS", Tkr_Fit_YKalThetaMS)).isFailure()) return sc;
00431 
00432   
00433         if ((sc = pSvc->addItem(pName, "TKR_Fit_xdir",        Tkr_Fit_xdir       )).isFailure()) return sc;
00434         if ((sc = pSvc->addItem(pName, "TKR_Fit_ydir",        Tkr_Fit_ydir       )).isFailure()) return sc;
00435         if ((sc = pSvc->addItem(pName, "TKR_Fit_zdir",        Tkr_Fit_zdir       )).isFailure()) return sc;
00436         if ((sc = pSvc->addItem(pName, "TKR_Fit_x0",          Tkr_Fit_x0         )).isFailure()) return sc;
00437         if ((sc = pSvc->addItem(pName, "TKR_Fit_y0",          Tkr_Fit_y0         )).isFailure()) return sc;
00438         if ((sc = pSvc->addItem(pName, "TKR_Fit_z0",          Tkr_Fit_z0         )).isFailure()) return sc;
00439     
00440         if ((sc = pSvc->addItem(pName, "TKR_Pair_xdir",       Tkr_Pair_xdir      )).isFailure()) return sc;
00441         if ((sc = pSvc->addItem(pName, "TKR_Pair_ydir",       Tkr_Pair_ydir      )).isFailure()) return sc;
00442         if ((sc = pSvc->addItem(pName, "TKR_Pair_zdir",       Tkr_Pair_zdir      )).isFailure()) return sc;
00443         if ((sc = pSvc->addItem(pName, "TKR_Pair_x0",         Tkr_Pair_x0        )).isFailure()) return sc;
00444         if ((sc = pSvc->addItem(pName, "TKR_Pair_y0",         Tkr_Pair_y0        )).isFailure()) return sc;
00445         if ((sc = pSvc->addItem(pName, "TKR_Pair_z0",         Tkr_Pair_z0        )).isFailure()) return sc;
00446     
00447         if ((sc = pSvc->addItem(pName, "TKR_Gamma_xdir",      Tkr_Gamma_xdir     )).isFailure()) return sc;
00448         if ((sc = pSvc->addItem(pName, "TKR_Gamma_ydir",      Tkr_Gamma_ydir     )).isFailure()) return sc;
00449         if ((sc = pSvc->addItem(pName, "TKR_Gamma_zdir",      Tkr_Gamma_zdir     )).isFailure()) return sc;
00450         if ((sc = pSvc->addItem(pName, "TKR_Gamma_x0",        Tkr_Gamma_x0       )).isFailure()) return sc;
00451         if ((sc = pSvc->addItem(pName, "TKR_Gamma_y0",        Tkr_Gamma_y0       )).isFailure()) return sc;
00452         if ((sc = pSvc->addItem(pName, "TKR_Gamma_z0",        Tkr_Gamma_z0       )).isFailure()) return sc;
00453         if ((sc = pSvc->addItem(pName, "TKR_t_angle",         Tkr_Gamma_DLT      )).isFailure()) return sc;
00454         
00455         if ((sc = pSvc->addItem(pName, "TKR_Pair_XNhits",     Tkr_Pair_XNhits    )).isFailure()) return sc;
00456         if ((sc = pSvc->addItem(pName, "TKR_XChisq",          Tkr_XChisq         )).isFailure()) return sc;
00457         if ((sc = pSvc->addItem(pName, "TKR_XChisq_1st",      Tkr_XChisq_1st     )).isFailure()) return sc;
00458         if ((sc = pSvc->addItem(pName, "TKR_XKalEne",         Tkr_XKalEne        )).isFailure()) return sc;
00459         if ((sc = pSvc->addItem(pName, "TKR_XKalThetaMS",     Tkr_XKalThetaMS    )).isFailure()) return sc;
00460 
00461         if ((sc = pSvc->addItem(pName, "TKR_Pair_YNhits",     Tkr_Pair_YNhits    )).isFailure()) return sc;
00462         if ((sc = pSvc->addItem(pName, "TKR_YChisq",          Tkr_YChisq         )).isFailure()) return sc;
00463         if ((sc = pSvc->addItem(pName, "TKR_YChisq_1st",      Tkr_YChisq_1st     )).isFailure()) return sc;
00464         if ((sc = pSvc->addItem(pName, "TKR_YKalEne",         Tkr_YKalEne        )).isFailure()) return sc;
00465         if ((sc = pSvc->addItem(pName, "TKR_YKalThetaMS",     Tkr_YKalThetaMS    )).isFailure()) return sc;
00466 
00467         if ((sc = pSvc->addItem(pName, "TKR_errSlopeX",       Tkr_errSlopeX      )).isFailure()) return sc;
00468         if ((sc = pSvc->addItem(pName, "TKR_errSlopeY",       Tkr_errSlopeY      )).isFailure()) return sc;
00469         if ((sc = pSvc->addItem(pName, "TKR_xeneXSlope",      Tkr_xeneXSlope     )).isFailure()) return sc;
00470         if ((sc = pSvc->addItem(pName, "TKR_xeneYSlope",      Tkr_xeneYSlope     )).isFailure()) return sc;
00471         if ((sc = pSvc->addItem(pName, "TKR_weightXSlope",    Tkr_weightXSlope   )).isFailure()) return sc;
00472         if ((sc = pSvc->addItem(pName, "TKR_weightYSlope",    Tkr_weightYSlope   )).isFailure()) return sc;
00473     
00474         //      First Used Layer and previous Hits...
00475         if ((sc = pSvc->addItem(pName, "TKR_First_XHit",      Tkr_First_XHit     )).isFailure()) return sc;
00476         if ((sc = pSvc->addItem(pName, "TKR_Diff_1st_Hit",    Tkr_Diff_1st_Hit   )).isFailure()) return sc;
00477         if ((sc = pSvc->addItem(pName, "TKR_Zbottom",         Tkr_Zbottom        )).isFailure()) return sc;
00478 
00479         // Might there be kinks in the tracks?
00480         if ((sc = pSvc->addItem(pName, "TKR_Fit_Kink",        Tkr_Fit_Kink       )).isFailure()) return sc;
00481         if ((sc = pSvc->addItem(pName, "TKR_Fit_KinkN",       Tkr_Fit_KinkN      )).isFailure()) return sc;
00482         if ((sc = pSvc->addItem(pName, "TKR_Pair_Kink",       Tkr_Pair_Kink      )).isFailure()) return sc;
00483         if ((sc = pSvc->addItem(pName, "TKR_Pair_KinkN",      Tkr_Fit_KinkN      )).isFailure()) return sc;
00484     }
00485     
00486     return sc;
00487 }
00488 
00489 //########################################################
00490 void TkrTupleValues::calcFitKink(GFgamma* pGamma)
00491 //########################################################
00492 {
00493     GFtrack* xtrk = pGamma->getBest(SiCluster::X);
00494     GFtrack* ytrk = pGamma->getBest(SiCluster::Y);
00495     
00496     if (xtrk->empty() || ytrk->empty()) return;
00497     
00498     double xkink = xtrk->kink(0);
00499     double ykink = ytrk->kink(0);
00500 
00501     Tkr_Fit_Kink = (fabs(ykink) > fabs(xkink)? ykink:xkink);
00502     
00503     double xkinkN = xtrk->kinkNorma(0);
00504     double ykinkN = ytrk->kinkNorma(0);
00505     Tkr_Fit_KinkN = (fabs(ykinkN) > fabs(xkinkN)? ykinkN:xkinkN);
00506     
00507     // Pair Track
00508     xtrk = pGamma->getPair(SiCluster::X);
00509     ytrk = pGamma->getPair(SiCluster::Y);
00510     
00511     if (xtrk->empty() || ytrk->empty()) return;
00512     
00513     xkink = xtrk->kink(0);
00514     ykink = ytrk->kink(0);
00515     Tkr_Pair_Kink = (fabs(ykink) > fabs(xkink)? ykink:xkink);
00516     
00517     xkinkN = xtrk->kinkNorma(0);
00518     ykinkN = ytrk->kinkNorma(0);
00519     Tkr_Pair_KinkN = (fabs(ykinkN) > fabs(xkinkN)? ykinkN:xkinkN);
00520     
00521     return;
00522 }
00523 
00524 

Generated at Wed Nov 21 12:21:21 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000