int main() { #ifdef LOG4CXX InitializePZLOG(); #endif /* int numcells = 1; REAL temperature = 98.; REAL pressure = 2.e6; REAL WellRadius = 0.13; REAL ReservoirRadius = 100.; REAL oilsaturation = 0.7; TPBrSteamMesh mesh(numcells,temperature,pressure,WellRadius,ReservoirRadius,oilsaturation); mesh.TimeStep(10.); return 0; */ REAL tinlet(100.); REAL deltatime = 1.; REAL timefinal(20.); // FluxEvolution(tinlet, deltatime, timefinal, "fluxdelt1.txt","energy1.txt"); // FluxEvolution(tinlet, deltatime/10., timefinal, "fluxdelt01.txt","energy01.txt"); REAL DADt(1.); ExpandingDomain(tinlet, DADt, deltatime, timefinal, "fluxdelt1.txt","energy1.txt"); ExpandingDomain(tinlet, DADt, deltatime/10., timefinal, "fluxdelt01.txt","energy01.txt"); REAL domainsize = 100.; int nelements = 50; REAL cp = 1.; REAL K = 1.; REAL density = 1.; REAL initialtemp = 100.; TPBRThermalDiscretization discrete(domainsize,nelements,cp,K,density,initialtemp); TPZFNMatrix<101,STATE> sol(nelements+1,1,initialtemp), nextsol(nelements+1,1,0.); discrete.SetTimeStep(1.); discrete.ComputeStiffness(); REAL flux1,flux2; REAL energy1, energy2; REAL dQdT = discrete.DQDT(); discrete.NextSolution(100., sol,nextsol,flux1); energy1 = discrete.Energy(nextsol); discrete.NextSolution(101., sol,nextsol,flux2); energy2 = discrete.Energy(nextsol); REAL residual = flux2-flux1-dQdT; std::cout << "flux2 " << flux2 << " flux1 " << flux1 << " dQdT " << dQdT << " residual " << residual << std::endl; std::cout << "energy1 " << energy1 << " energy2 " << energy2 << std::endl; nextsol.Print("Next Solution", std::cout); discrete.NextSolution(1., nextsol,nextsol,flux1); nextsol.Print("Next Solution", std::cout); return 0; // #warning "this should be resolved" }
//_________________________________________________________ void UserAnalysis() { // Debug a particular event. Int_t eventToDebug = -1; if (jsf->GetEventNumber() == eventToDebug) { gDEBUG = kTRUE; cerr << "------------------------------------------" << endl; cerr << "Event " << jsf->GetEventNumber(); cerr << endl; } else { gDEBUG = kFALSE; } Char_t msg[60]; // Analysis starts here. Float_t selid = -0.5; hStat->Fill(++selid); if ( Ngoods == 0 ) strcpy(&cutName[(Int_t)selid][0],"No cut"); // Get event buffer and make combined tracks accessible. JSFSIMDST *sds = (JSFSIMDST*)jsf->FindModule("JSFSIMDST"); JSFSIMDSTBuf *evt = (JSFSIMDSTBuf*)sds->EventBuf(); Int_t ntrks = evt->GetNLTKCLTracks(); // No. of tracks TObjArray *trks = evt->GetLTKCLTracks(); // combined tracks ANL4DVector qsum; TObjArray tracks(500); tracks.SetOwner(); // Select good tracks fNtracks = 0; for ( Int_t i = 0; i < ntrks; i++ ) { JSFLTKCLTrack *t = (JSFLTKCLTrack*)trks->UncheckedAt(i); if ( t->GetE() > xEtrack ) { ANL4DVector *qt = new ANL4DVector(t->GetPV()); tracks.Add(qt); // track 4-momentum qsum += *qt; // total 4-momentum fNtracks++; } // *qt stays. } // Cut on No. of tracks. hNtracks->Fill(fNtracks); if ( fNtracks < xNtracks ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"N_tracks > %g",xNtracks); strcpy(&cutName[(Int_t)selid][0],msg); } fEvis = qsum.E(); // E_vis fPt = qsum.GetPt(); // P_t fPl = qsum.Pz(); // P_l // Cut on Evis. hEvis->Fill(fEvis); if ( fEvis < xEvis ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"E_vis > %g",xEvis); strcpy(&cutName[(Int_t)selid][0],msg); } // Cut on Pt. hPt->Fill(fPt); if ( fPt < xPt ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"Pt > %g",xPt); strcpy(&cutName[(Int_t)selid][0],msg); } // Cut on Pl. if ( TMath::Abs(fPl) > xPl ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"|Pl| <= %g",xPl); strcpy(&cutName[(Int_t)selid][0],msg); } // Find jets. fYcut = xYcut; ANLJadeEJetFinder jclust(fYcut); jclust.Initialize(tracks); jclust.FindJets(); fYcut = jclust.GetYcut(); fNjets = jclust.GetNjets(); // Cut on No. of jets. hNjets->Fill(fNjets); if ( fNjets < xNjets ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"Njets >= %i for Ycut = %g",xNjets,xYcut); strcpy(&cutName[(Int_t)selid][0],msg); } // Now force the event to be xNjets. jclust.ForceNJets(xNjets); fNjets = jclust.GetNjets(); fYcut = jclust.GetYcut(); // Make sure that No. of jets is xNjets. if ( fNjets != xNjets ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"Njets = %i",xNjets); strcpy(&cutName[(Int_t)selid][0],msg); } // Loop over jets and decide Ejet_min and |cos(theta_j)|_max. TObjArray &jets = jclust.GetJets(); // jets is an array of ANLJet's TIter nextjet(&jets); // and nextjet is an iterator for it ANLJet *jetp; Double_t ejetmin = 999999.; Double_t cosjmax = 0.; while ((jetp = (ANLJet *)nextjet())) { ANLJet &jet = *jetp; if (gDEBUG && kFALSE) jet.DebugPrint(); Double_t ejet = jet().E(); if (ejet < ejetmin) ejetmin = ejet; hEjet->Fill(ejet); // Ejet Double_t cosj = jet.CosTheta(); if (TMath::Abs(cosj) > TMath::Abs(cosjmax)) cosjmax = cosj; hCosjet->Fill(cosj); // cos(theta_jet) } // Cut on Ejet_min. if ( ejetmin < xEjet ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"Ejet > %g",xEjet); strcpy(&cutName[(Int_t)selid][0],msg); } // Cut on |cos(theta_j)|_max. if ( TMath::Abs(cosjmax) > xCosjet ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"|cos(theta_j)| <= %g",xCosjet); strcpy(&cutName[(Int_t)selid][0],msg); } // Find W candidates in given mass windows. // Avoid using indices since there might be empty slots. TObjArray solutions(10); solutions.SetOwner(); ANLPairCombiner w1candidates(jets,jets); ANLPairCombiner *w2candidp = 0; if (gDEBUG) { cerr << "------------------------------------------" << endl; cerr << "- w1candidates:" << endl; w1candidates.DebugPrint(); } ANLPair *w1p, *w2p; while ((w1p = (ANLPair *)w1candidates())) { w2candidp = 0; ANLPair &w1 = *w1p; Double_t w1mass = w1().GetMass(); if (TMath::Abs(w1mass - kMassW) > xM2j) continue; // w1 candidate found w1.LockChildren(); // now lock w1 daughters w2candidp = new ANLPairCombiner(w1candidates); // w2 after w1 ANLPairCombiner &w2candidates = *w2candidp; while ((w2p = (ANLPair *)w2candidates())) { ANLPair &w2 = *w2p; if (w2.IsLocked()) continue; // skip if locked Double_t w2mass = w2().GetMass(); if (TMath::Abs(w2mass - kMassW) > xM2j) continue; // w2 candidate found Double_t chi2 = TMath::Power((w1mass - kMassW)/kSigmaMw,2.) + TMath::Power((w2mass - kMassW)/kSigmaMw,2.); solutions.Add(new ANLPair(w1p,w2p,chi2)); // hMw1Mw2->Fill(w1mass,w2mass,1.0); } if (w2candidp) delete w2candidp; w1.UnlockChildren(); } // Cut on No. of solutions. if ( !solutions.GetEntries() ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"|m_jj - m_W| <= %g",xM2j); strcpy(&cutName[(Int_t)selid][0],msg); } if (gDEBUG) { cerr << "------------------------------------------" << endl; cerr << "- w1candidates after 1:" << endl; w1candidates.DebugPrint(); } // Cut on cos(theta_W). TIter nextsol(&solutions); ANLPair *sol; while ((sol = (ANLPair *)nextsol())) { ANL4DVector &ww1 = *(ANL4DVector *)(*sol)[0]; ANL4DVector &ww2 = *(ANL4DVector *)(*sol)[1]; Double_t ew1 = ww1.E(); Double_t ew2 = ww2.E(); hEw1Ew2->Fill(ew1,ew2,1.0); Double_t cosw1 = ww1.CosTheta(); Double_t cosw2 = ww2.CosTheta(); hCosw1Cosw2->Fill(cosw1,cosw2,1.0); if (TMath::Abs(cosw1) > xCosw || TMath::Abs(cosw2) > xCosw) { solutions.Remove(sol); delete sol; } } if ( !solutions.GetEntries() ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"|cos(theta_w)| <= %g",xCosw); strcpy(&cutName[(Int_t)selid][0],msg); } if (gDEBUG) { cerr << "------------------------------------------" << endl; cerr << "- w1candidates after 2:" << endl; w1candidates.DebugPrint(); } // Cut on Acop. nextsol.Reset(); while ((sol = (ANLPair *)nextsol())) { ANL4DVector &www1 = *(ANL4DVector *)(*sol)[0]; ANL4DVector &www2 = *(ANL4DVector *)(*sol)[1]; Double_t acop = www1.Acop(www2); hAcop->Fill(acop); if (acop < xAcop) { solutions.Remove(sol); delete sol; } } if ( !solutions.GetEntries() ) return; hStat->Fill(++selid); if ( Ngoods == 0 ) { sprintf(msg,"Acop > %g",xAcop); strcpy(&cutName[(Int_t)selid][0],msg); } if (gDEBUG) { cerr << "------------------------------------------" << endl; cerr << "- w1candidates after 3:" << endl; w1candidates.DebugPrint(); } // ------------------------ // End of event selection // ------------------------ if ( Ngoods == 0 ) { selid++; sprintf(msg,"END"); strcpy(&cutName[(Int_t)selid][0],msg); } Ngoods++; cerr << "------------------------------------------" << endl << "Event " << jsf->GetEventNumber() << ": Number of solutions = " << solutions.GetEntries() << endl << "------------------------------------------" << endl; // Sort the solutions in the ascending order of chi2 vlues. solutions.Sort(); // Hists and plots for selected events. if (gDEBUG && kFALSE) { Int_t nj = 0; nextjet.Reset(); while ((jetp = (ANLJet *)nextjet())) { cerr << "------" << endl << "Jet " << ++nj << endl << "------" << endl; jetp->DebugPrint(); } } hNsols->Fill(solutions.GetEntries()); hEvisPl->Fill(fEvis,fPl,1.); nextsol.Reset(); Int_t nsols = 0; while ((sol = (ANLPair *)nextsol())) { if ( nsols++ ) break; // choose the best ANL4DVector &wwww1 = *(ANL4DVector *)(*sol)[0]; ANL4DVector &wwww2 = *(ANL4DVector *)(*sol)[1]; Double_t chi2 = sol->GetQuality(); Double_t w1mass = wwww1.GetMass(); Double_t w2mass = wwww2.GetMass(); hChi2->Fill(chi2); hMw1Mw2->Fill(w1mass,w2mass,1.0); } return; }