/////////////////////////////////////////////////////////////////////////////// // P.Murat // A.Safonov - fill some missing variables and make correct cluster // ordering for the most up-to-date CesMatchModule -9/10/03 /////////////////////////////////////////////////////////////////////////////// #include "TROOT.h" #include "TFolder.h" #include #include #include #include #include "Calor/CalorPredicates.hh" #include "Calor/PhysicsTowerDataMaker.hh" #include "Calor/calor_alg.hh" #include "Calor/calorMakeView.hh" #include "CalorGeometry/CalParameters.hh" #include "CalorObjects/PhysicsTowerView.hh" #include #include #include #include #include #include "Tau/algorithms/TauClusterRenewCache.hh" #include #include #include #include #include #include #include #include //_____________________________________________________________________________ Int_t StntupleInitPi0(TStnPi0* Pi0, const Pi0Candidate* Anton) { // init TStnPi0 from CdfPi0 (Run II only) Pi0->fPi0Candidate = (Pi0Candidate*) Anton; //----------------------------------------------------------------------------- // for the time being the best momentum is the one measured by the calorimeter //----------------------------------------------------------------------------- HepLorentzVector why_it_is_returned_by_value; HepLorentzVector* mom = &why_it_is_returned_by_value; // *** to be fixed Pi0->fZ0 = 0.; why_it_is_returned_by_value = Anton->fourMomentum(Pi0->fZ0); Pi0->fMomentum.SetX(mom->x()); Pi0->fMomentum.SetY(mom->y()); Pi0->fMomentum.SetZ(mom->z()); Pi0->fMomentum.SetT(mom->e()); int ieta = Anton->tower().iEta(); int iphi = Anton->tower().iPhi(); Pi0->SetEtaPhi(ieta,iphi); const CesMatch* match = Anton->cesMatch(); //----------------------------------------------------------------------------- // store global Z(CES), it is less obvious what is returned by CesMatch::locX() //----------------------------------------------------------------------------- Pi0->fXCes = match->locX(); Pi0->fZCes = Anton->detectorZ(); int match_type = match->matchType(); int split_flag = match->isSplit(); Pi0->SetMatchType(match_type); Pi0->SetSplitFlag(split_flag); const std::vector< ValueVectorLink >& clist = match->matchedClusters(); Pi0->fClusterChi2 [0] = TStnDataBlock::kUndefined; Pi0->fClusterChi2 [1] = TStnDataBlock::kUndefined; Pi0->fClusterCoord [0] = TStnDataBlock::kUndefined; Pi0->fClusterCoord [1] = TStnDataBlock::kUndefined; Pi0->fClusterSigma [0] = TStnDataBlock::kUndefined; Pi0->fClusterSigma [1] = TStnDataBlock::kUndefined; Pi0->fClusterEnergy[0] = TStnDataBlock::kUndefined; Pi0->fClusterEnergy[1] = TStnDataBlock::kUndefined; if (match_type == CesMatch::T1W1S) { //----------------------------------------------------------------------------- // 2 clusters: 1 wire, 1 strip, Anton stores wire cluster first //----------------------------------------------------------------------------- Pi0->fNClusters[0] = 1; Pi0->fNClusters[1] = 1; ValueVectorLink wc; ValueVectorLink sc; if (clist[0]->view() == CesCluster::WIRE) { wc = clist[0]; sc = clist[1]; } else{ wc = clist[1]; sc = clist[0]; } Pi0->fClusterEnergy[0] = sc->raw_energy(); Pi0->fClusterEnergy[1] = wc->raw_energy(); Pi0->fClusterCoord [0] = sc->fitted_position(); Pi0->fClusterCoord [1] = wc->fitted_position(); Pi0->fClusterSigma [0] = sc->width(); Pi0->fClusterSigma [1] = wc->width(); Pi0->fClusterChi2 [0] = sc->chi2(); Pi0->fClusterChi2 [1] = wc->chi2(); } else if (match_type == CesMatch::T1W2S_UNSPLIT) { //----------------------------------------------------------------------------- // 3 clusters, 1 wire, 2 strip, Anton stores wire cluster first //----------------------------------------------------------------------------- Pi0->fNClusters[0] = 2; Pi0->fNClusters[1] = 1; ValueVectorLink wc; ValueVectorLink sc1; ValueVectorLink sc2; if (clist[0]->view() == CesCluster::WIRE) { wc = clist[0]; sc1 = clist[1]; sc2 = clist[2]; } else{ wc = clist[2]; sc1 = clist[0]; sc2 = clist[1]; } double e1 = sc1->raw_energy(); double e2 = sc2->raw_energy(); Pi0->fClusterEnergy[0] = e1+e2; Pi0->fClusterEnergy[1] = wc->raw_energy(); Pi0->fClusterCoord [0] = (sc1->fitted_position()*e1 +sc2->fitted_position()*e2)/(e1+e2); Pi0->fClusterCoord [1] = wc->fitted_position(); Pi0->fClusterSigma [0] = TStnDataBlock::kUndefined; Pi0->fClusterSigma [1] = wc->width(); Pi0->fClusterChi2 [0] = TStnDataBlock::kUndefined; Pi0->fClusterChi2 [1] = wc->chi2(); } else if (match_type == CesMatch::T2W1S_UNSPLIT) { //----------------------------------------------------------------------------- // 3 clusters, 1 wire, 2 strip, to simplify everything Anton now stores strip // cluster first //----------------------------------------------------------------------------- Pi0->fNClusters[0] = 1; Pi0->fNClusters[1] = 2; ValueVectorLink wc1; ValueVectorLink wc2; ValueVectorLink sc; if (clist[0]->view() == CesCluster::WIRE) { wc1 = clist[0]; wc2 = clist[1]; sc = clist[2]; } else{ wc1 = clist[1]; wc2 = clist[2]; sc = clist[0]; } double e1 = wc1->raw_energy(); double e2 = wc2->raw_energy(); Pi0->fClusterEnergy[0] = sc->raw_energy(); Pi0->fClusterEnergy[1] = e1+e2; Pi0->fClusterCoord [0] = sc->fitted_position(); Pi0->fClusterCoord [1] = (wc1->fitted_position()*e1 +wc2->fitted_position()*e2)/(e1+e2); Pi0->fClusterSigma [0] = sc->width(); Pi0->fClusterSigma [1] = TStnDataBlock::kUndefined; Pi0->fClusterChi2 [0] = sc->chi2(); Pi0->fClusterChi2 [1] = TStnDataBlock::kUndefined; } else if (match_type == CesMatch::T0W1S) { //----------------------------------------------------------------------------- // 1 strip cluster //----------------------------------------------------------------------------- Pi0->fNClusters[0] = 1; Pi0->fNClusters[1] = 0; ValueVectorLink sc = clist[0]; Pi0->fClusterEnergy[0] = sc->raw_energy(); Pi0->fClusterEnergy[1] = 0; Pi0->fClusterCoord [0] = sc->fitted_position(); Pi0->fClusterCoord [1] = TStnDataBlock::kUndefined; Pi0->fClusterSigma [0] = sc->width(); Pi0->fClusterSigma [1] = TStnDataBlock::kUndefined; Pi0->fClusterChi2 [0] = sc->chi2(); Pi0->fClusterChi2 [1] = TStnDataBlock::kUndefined; } else if (match_type == CesMatch::T1W0S) { //----------------------------------------------------------------------------- // 1 wire cluster //----------------------------------------------------------------------------- Pi0->fNClusters[0] = 0; Pi0->fNClusters[1] = 1; ValueVectorLink wc = clist[0]; Pi0->fClusterEnergy[0] = 0; Pi0->fClusterEnergy[1] = wc->raw_energy(); Pi0->fClusterCoord [0] = TStnDataBlock::kUndefined; Pi0->fClusterCoord [1] = wc->fitted_position(); Pi0->fClusterSigma [0] = TStnDataBlock::kUndefined; Pi0->fClusterSigma [1] = wc->width(); Pi0->fClusterChi2 [0] = TStnDataBlock::kUndefined; Pi0->fClusterChi2 [1] = wc->chi2(); } else if (match_type == CesMatch::T1W2S_SPLIT) { Pi0->fNClusters[0] = 1; Pi0->fNClusters[1] = 1; ValueVectorLink wc; ValueVectorLink sc; if (clist[0]->view() == CesCluster::WIRE) { wc = clist[0]; sc = clist[1]; } else{ wc = clist[1]; sc = clist[0]; } Pi0->fClusterEnergy[0] = sc->raw_energy(); Pi0->fClusterEnergy[1] = wc->raw_energy(); Pi0->fClusterCoord [0] = sc->fitted_position(); Pi0->fClusterCoord [1] = wc->fitted_position(); Pi0->fClusterSigma [0] = sc->width(); Pi0->fClusterSigma [1] = wc->width(); Pi0->fClusterChi2 [0] = sc->chi2(); Pi0->fClusterChi2 [1] = wc->chi2(); } else if (match_type == CesMatch::T2W1S_SPLIT) { Pi0->fNClusters[0] = 1; Pi0->fNClusters[1] = 1; ValueVectorLink wc; ValueVectorLink sc; if (clist[0]->view() == CesCluster::WIRE) { wc = clist[0]; sc = clist[1]; } else{ wc = clist[1]; sc = clist[0]; } Pi0->fClusterEnergy[0] = sc->raw_energy(); Pi0->fClusterEnergy[1] = wc->raw_energy(); Pi0->fClusterCoord [0] = sc->fitted_position(); Pi0->fClusterCoord [1] = wc->fitted_position(); Pi0->fClusterSigma [0] = sc->width(); Pi0->fClusterSigma [1] = wc->width(); Pi0->fClusterChi2 [0] = sc->chi2(); Pi0->fClusterChi2 [1] = wc->chi2(); } // some coding needs to be done here Pi0->fWeight = 1.; return 0; } //_____________________________________________________________________________ Int_t StntupleInitPi0Block(TStnDataBlock* block, AbsEvent* event, int mode) { // initialize pi0 data block with the `event' data // return -1, if bank doesn't exist, 0, if everything is OK // in hope that number of pi0 candidates is // always less than 10000 int inum[10000]; int ev_number, rn_number; char process[100], description[100]; //----------------------------------------------------------------------------- // save time: don't do initialization twice for the same event //----------------------------------------------------------------------------- ev_number = AbsEnv::instance()->trigNumber(); rn_number = AbsEnv::instance()->runNumber(); if (block->Initialized(ev_number,rn_number)) return 0; TStnPi0Block* data = (TStnPi0Block*) block; data->Clear(); StntupleGetProcessName(data->CollName()->Data(),process,description); ConstHandle handle(StntupleGetIterator(event, "Pi0CandidateCollection", process, description)); if (handle.is_null()) return -1; const Pi0CandidateCollection::CollType& pi0_list = handle->contents(); int npi0 = pi0_list.size(); if (npi0 == 0) return 0; const Pi0Candidate *anton, *pi01, *pi02; TStnPi0* pi0; //----------------------------------------------------------------------------- // order pi0 in energy //----------------------------------------------------------------------------- for (int i=0; ienergy() < pi02->energy()) { // swap pi0's int itmp = inum[i1]; inum[i1] = inum[i2]; inum[i2] = itmp; pi01 = pi02; } } } for (int i=0; iNewPi0(); StntupleInitPi0(pi0,anton); } //----------------------------------------------------------------------------- // on return mark block as initialized for given event/run //----------------------------------------------------------------------------- data->f_RunNumber = rn_number; data->f_EventNumber = ev_number; return 0; } //_____________________________________________________________________________ Int_t StntuplePi0BlockLinks(TStnDataBlock* block, AbsEvent* event, int mode) { // current version of this routine does nothing // static TFolder* fol = NULL; // static TStnErrorLogger* logger = NULL; // set links between the pi0's and the objects in the other blocks // return 0 if everything is OK int ev_number, rn_number; //----------------------------------------------------------------------------- // make sure the block is initialized, do not initialize links twice //----------------------------------------------------------------------------- ev_number = AbsEnv::instance()->trigNumber(); rn_number = AbsEnv::instance()->runNumber(); if (! block->Initialized(ev_number,rn_number)) return -1; if ( block->LinksInitialized() ) return 0; // if (! fol) { //----------------------------------------------------------------------------- // initialize local static variables //----------------------------------------------------------------------------- // fol = (TFolder*) gROOT->GetRootFolder()->FindObject("StntupleFolder"); // logger = (TStnErrorLogger*) fol->FindObject("StntupleErrorLogger"); // } // TStnPi0Block* pi0_block = (TStnPi0Block*) block; //----------------------------------------------------------------------------- // mark links as initialized //----------------------------------------------------------------------------- block->SetLinksInitialized(); return 0; }