int main (void) { union { double result; unsigned long int_result; } u; double result; long t0, t1; int i; setStats(1); printf("Running %s...\n", __FILE__); for( int i = 0; i < 4; i++ ) { asm volatile("rdcycle %0":"=r"(t0)); asm volatile("fence"); edp_clear_cr(); edp_prepare_dp(&input_data1, &input_data2); edp_run_dp(DATA_SIZE); asm volatile("fence"); asm volatile("rdcycle %0":"=r"(t1)); u.int_result = edp_read_double(); printf("%s Run %d: Cycle Duration = %ld\n", __FILE__, i, (t1 - t0)); } setStats(0); if( u.int_result != verify_data ) { printf("Error on Test %s\n", __FILE__); printf("Expected result = 0x%lx\n", verify_data); printf("Results received = 0x%lx\n", u.int_result); } return 0; }
int main( int argc, char* argv[] ) { int results_data[DATA_SIZE]; // Output the input array #if HOST_DEBUG printArray( "input", DATA_SIZE, input_data ); printArray( "verify", DATA_SIZE, verify_data ); #endif // If needed we preallocate everything in the caches #if ( !HOST_DEBUG && PREALLOCATE ) //median_asm( DATA_SIZE, input_data, results_data ); median( DATA_SIZE, input_data, results_data ); #endif // Do the filter setStats(1); median( DATA_SIZE, input_data, results_data ); setStats(0); // Print out the results #if HOST_DEBUG printArray( "results", DATA_SIZE, results_data ); #endif // Check the results finishTest(verify( DATA_SIZE, results_data, verify_data )); }
int main( int argc, char* argv[] ) { int results_data[DATA_SIZE]; // Output the input array printArray( "input1", DATA_SIZE, input1_data ); printArray( "input2", DATA_SIZE, input2_data ); printArray( "verify", DATA_SIZE, verify_data ); #if PREALLOCATE // If needed we preallocate everything in the caches vvadd( DATA_SIZE, input1_data, input2_data, results_data ); #endif // Do the vvadd setStats(1); vvadd( DATA_SIZE, input1_data, input2_data, results_data ); setStats(0); // Print out the results printArray( "results", DATA_SIZE, results_data ); // Check the results return verify( DATA_SIZE, results_data, verify_data ); }
int main (void) { union { double result; unsigned long int_result; } u; u.int_result = verify_data; double c = 0.0; double sum = 0.0; setStats(1); int i; for (i = 0; i < DATA_SIZE; i++) { double prod = input_data1[i]*input_data2[i]; double y = prod - c; double t = sum + y; c = (t - sum) - y; sum = t; } setStats(0); double error = abs(sum - u.result); if( error < 1e-15 ) return 0; else return 1; }
int main (int argc, char * argv[]) { union { double result; unsigned long int_result; } u; u.int_result = verify_data; setStats(1); double result = 0; int i; for (i = 0; i < DATA_SIZE; i++) { input_data1[i] = input_data1[i]*input_data2[i]; } //Sort the products qsort(input_data1, DATA_SIZE, sizeof(input_data1[0]), abscomp); for (i = 0; i < DATA_SIZE; i++) { result += input_data1[i]; } setStats(0); double error = abs(result - u.result); if( error < 1e-15 ) return 0; else return 1; }
int main( int argc, char* argv[] ) { int i; int results_data[DATA_SIZE]; // Output the input arrays printArray( "input1", DATA_SIZE, input_data1 ); printArray( "input2", DATA_SIZE, input_data2 ); printArray( "verify", DATA_SIZE, verify_data ); #if PREALLOCATE for (i = 0; i < DATA_SIZE; i++) { results_data[i] = multiply( input_data1[i], input_data2[i] ); } #endif setStats(1); for (i = 0; i < DATA_SIZE; i++) { results_data[i] = multiply( input_data1[i], input_data2[i] ); } setStats(0); // Print out the results printArray( "results", DATA_SIZE, results_data ); // Check the results return verify( DATA_SIZE, results_data, verify_data ); }
int main( int argc, char* argv[] ) { // BENCHMARK #1: Try to maximize store-data forwarding. setStats(1); benchmark(); setStats(0); // Check the results return 0; // You'll probably want to call your verify function here. // Return 0 for success, anything else for failure. }
void Reset() { GC_Timer = 0; Heal_Timer = 0; Lesser_Healing_Timer = 0; Self_Lesser_Healing_Timer = 0; Flame_Shock_Timer = 20; Lightning_Bolt_Timer = 60; Earth_Shock_Timer = 150; Others_Heal_Timer = 0; Oom_timer = 0; Earth_Totem_Timer = 0; Fire_Totem_Timer = 0; Water_Totem_Timer = 0; Wind_Totem_Timer = 0; Potion_Timer = 0; Rez_Timer = 0; opponent = NULL; if (master) { setStats(CLASS_SHAMAN, m_creature->getRace(), master->getLevel()); } }
void Player::shapeShift(Forms newForm) { if (!(collisions[LEFT] || collisions[RIGHT]) && level > formLevels[newForm]) { form = newForm; setStats(newForm); } }
void Reset() { Pyroblast_cd = 0; FireBlast_cd = 0; DragonBreath_cd = 0; Living_Bomb_cd = 0; //Combustion_cd = 30000;//30 sec for reset Ice_Barrier_cd = 0; Iceblock_cd = 0; ConeofCold_cd = 0; Blizzard_cd = 10000; CounterSpell_cd = 0; Evocation_cd = 0; Blink_cd = 0; Bolt_cd = 0; Nova_cd = 0; polyCheckTimer = 0; fmCheckTimer = 0; Polymorph = false; clearcast = false; BOLT = 0; NOVA = 0; if (master) { setStats(CLASS_MAGE, me->getRace(), master->getLevel(), true); ApplyClassPassives(); ApplyPassives(CLASS_MAGE); } }
void Reset() { FirstAid_cd = 0; GC_Timer = 0; conflagarate_cd = 0; chaos_bolt_cd = 0; oom_spam = false; uint8 state = 1; next_state = 0; next_state_timer = 0; opponent = NULL; if (master) { setStats(CLASS_WARLOCK, m_creature->getRace(), master->getLevel()); if (!m_creature->HasAura(56235)) m_creature->AddAura(56235,m_creature); // Glyph of Conflagrate if (!m_creature->HasAura(63302)) m_creature->AddAura(63302,m_creature); // Glyph of Haunt if (!m_creature->HasAura(17834)) m_creature->AddAura(17834,m_creature); // Improved Immolation if (!m_creature->HasAura(17814)) m_creature->AddAura(17814,m_creature); // Improved Corruption } }
//Used for copy constructor void Projectile::operator=(Projectile& in) { spriteData = in.spriteData; textureManager = in.textureManager; setStats(in.damage, in.minRange, in.maxRange, in.muzzelVelocity); }
Player::Player(int x, int y) : Character(x, y, "data/spritesheets/player_human.png") { setStats(HUMAN); health = MaxHealth; maxStamina = stamina; printf("Player created at pos (%i,%i) with stats: \n\tHP: %i\n\tStamina: %i\n", x, y, MaxHealth, stamina); }
int main( int argc, char* argv[] ) { int i; int results_data[DATA_SIZE]; // Output the input arrays #if HOST_DEBUG printArray( "input1", DATA_SIZE, input_data1 ); printArray( "input2", DATA_SIZE, input_data2 ); printArray( "verify", DATA_SIZE, verify_data ); #endif #if ( !HOST_DEBUG && PREALLOCATE ) for (i = 0; i < DATA_SIZE; i++) { results_data[i] = multiply( input_data1[i], input_data2[i] ); } #endif #if HOST_DEBUG for (i = 0; i < DATA_SIZE; i++) { results_data[i] = multiply( input_data1[i], input_data2[i] ); } #else setStats(1); for (i = 0; i < DATA_SIZE; i++) { results_data[i] = multiply( input_data1[i], input_data2[i] ); } setStats(0); #endif // Print out the results #if HOST_DEBUG printArray( "results", DATA_SIZE, results_data ); #endif // Check the results finishTest(verify( DATA_SIZE, results_data, verify_data )); }
int main(int argc, char *argv[]){ // Instantiate tallied variables. int i, j, width, correct, hintCount, guesses, hints, trys; //Instantiate stats array int stats[5] = {0}; // Determine width of Matrix width = getWidth(argc, argv); // Generate matrix based on width complex** M = generateMatrix(width); // Create randmom number generator. srand((unsigned)time(NULL)); // Create string array for user input. char choice[20]; // Create array of type complex to store generated row column pairs complex uniques[width * width]; // Continue game until user quits. while(strncmp(choice, "Q", 1) != 0){ // Generate random row column pairs for ser to guess. i = rand() % width; j = rand() % width; // Reset counting variable for each generated row column pair. correct = hints = guesses = 0; while(correct == 0 && strncmp(choice, "Q", 1) != 0){ // Count number of hints used for this specific pair. hintCount = 0; // Display message to user displaying options. printf("M[0][0]=%p. M[i][j]=%p What's i and j?\n(Q to Quit or H or HH or HHH for hints.): ", &M[0][0], &M[i][j]); // Recieve and store user input. fgets(choice, 20, stdin); // Check if user requested hints hintCount += checkHints(choice, M, width); // If user did not want hints check is valid answer submitted if (hintCount == 0){ // Check answer correct = checkAnswer(choice, i, j); } // Accumulate hints used. hints += hintCount; // Accumulate guesses used. guesses++; } // If user has not quit calculate stats for pair. if (strncmp(choice, "Q", 1) != 0){ setUnique(uniques, i, j, stats); setStats(stats,hints, guesses); } } // Print stats of the game after user has quit. printStats(stats); // terminate matrix. killMatrix(M, width); }
void Reset() { Torment_cd = 0; if (master && m_creatureOwner) { setStats(master->getLevel(), PET_TYPE_VOIDWALKER, true); ApplyPassives(PET_TYPE_VOIDWALKER); ApplyClassPassives(); SetBaseArmor(162 * master->getLevel()); } }
Mob::Mob(){ setSTR(1); setDEF(1); setSPD(9); setINT(1); setStats(1,10,10,10, 1, 1); Name = "The Game"; TTF_Font* font; SDL_Color fgColor = {255,255,0}; SDL_Color fgColor1 = {255,255,255}; font = TTF_OpenFont("../Fonts/coolvetica.ttf",25); enemyText[0] = TTF_RenderText_Blended(font,getName().c_str(),fgColor); enemyText[1] = TTF_RenderText_Blended(font,getName().c_str(),fgColor1); }
void Reset() { ArcaneShot_cd = 0; ChimeraShot_Timer = 0; SilencingShot_Timer = 0; AimedShot_Timer = 0; Feign_Death_Timer = 0; if (master) { setStats(CLASS_HUNTER, me->getRace(), master->getLevel(), true); ApplyClassPassives(); ApplyPassives(CLASS_HUNTER); } }
int main( int argc, char* argv[] ) { // Output the input array printArray( "input", DATA_SIZE, input_data ); printArray( "verify", DATA_SIZE, verify_data ); #if PREALLOCATE // If needed we preallocate everything in the caches sort(DATA_SIZE, verify_data); if (verify(DATA_SIZE, input_data, input_data)) return 1; #endif // Do the sort setStats(1); sort( DATA_SIZE, input_data ); setStats(0); // Print out the results printArray( "test", DATA_SIZE, input_data ); // Check the results return verify( DATA_SIZE, input_data, verify_data ); }
void Reset() { Rain_of_fire_cd = 0; Haunt_cd = 0; conflagarate_cd = 0; chaos_bolt_cd = 0; fear_cd = 0; if (master) { setStats(CLASS_WARLOCK, me->getRace(), master->getLevel(), true); //TODO: passives ApplyClassPassives(); ApplyPassives(CLASS_WARLOCK); } }
void Reset() { oom_spam = false; opponent = NULL; GC_Timer = 0; ArcaneShot_cd = 0; ChimeraShot_Timer = 0; SilencingShot_Timer = 0; AimedShot_Timer = 0; if (master) { setStats(CLASS_HUNTER, m_creature->getRace(), master->getLevel()); } }
NPC::NPC(){ TTF_Init(); setStats(1,1,1,1,1,1); // need to be set because it is still a Entity instance, but these will never be used. npcName = "Default NPC"; //speach.push_back("I don't know what kinda of NPC I am. :("); // default image - should not be used. But just in case SDL_Surface* tempSurface = IMG_Load("../Images/npc/default.png"); npcImage = SDL_DisplayFormatAlpha(tempSurface); SDL_FreeSurface(tempSurface); setFrames(); // set the frames sentence = 0; font = TTF_OpenFont("../Fonts/coolvetica.ttf",25); fgColor.r = 255; fgColor.g = 255; fgColor.b = 255; surfaceTextRect.x = 40; surfaceTextRect.y = 500; }
int main() { Creature test(10, 10, 100, 5, 0, "Joe"); cout << "Displaying original stats..." << endl; displayStats(test); cin.get(); cout << "Changing the stats..." << endl; changeStats(test); cin.get(); cout << "Displaying stats after the changes..." << endl; displayStats(test); cin.get(); cout << "Setting the stats..." << endl; setStats(test); cin.get(); cout << "Displaying stats after setting..." << endl; displayStats(test); cin.get(); cout << "Using an item..." << endl; useAnItem(test); cin.get(); cout << "Displaying stats after using the item..." << endl; displayStats(test); cin.get(); return 0; }
// restore from serialization void ReadGroupStatsSet:: load( const char* filename) { clear(); assert(NULL != filename); std::ifstream ifs(filename); boost::archive::xml_iarchive ia(ifs); int numGroups; ia >> boost::serialization::make_nvp("numGroups", numGroups); ReadGroupStatsExporter se; for (int i=0; i<numGroups; i++) { ia >> boost::serialization::make_nvp("bogus", se); setStats(KeyType(se.bamFile.c_str(), se.readGroup.c_str()), se.groupStats); } }
void plotBuilding(TCanvas *canvas, TH1F **s, TH1F **r, int n,TText* te, char * option, double startingY, double startingX = .1,bool fit = false, unsigned int logx=0){ canvas->Divide(2,(n+1)/2); //this should work also for odd n for(int i=0; i<n;i++){ s[i]->SetMarkerStyle(20); r[i]->SetMarkerStyle(21); s[i]->SetMarkerColor(2); r[i]->SetMarkerColor(4); s[i]->SetMarkerSize(0.7); r[i]->SetMarkerSize(0.7); s[i]->SetLineColor(1); r[i]->SetLineColor(1); s[i]->SetLineWidth(1); r[i]->SetLineWidth(1); TPad *pad=canvas->cd(i+1); setStats(s[i],r[i], -1, 0, fit); if((logx>>i)&1)pad->SetLogx(); r[i]->Draw("lpf"); s[i]->Draw("sameslpf"); } }
runLooper_Iso_MinBias_skimdata_mc_EE( TString iso_opt = "ran_ecalIso03_mu", bool jura = false){ gStyle->SetHistLineWidth(2); gROOT->ForceStyle(); gStyle->SetOptStat(1101); //gStyle->SetOptStat(0); TCanvas *c1 = new TCanvas("can", "can"); TChain *MinBias_skimdata = new TChain("Events"); TChain *MinBias_mc = new TChain("Events"); MinBias_mc->Add("MC_skimmednTuple.root"); MinBias_skimdata->Add("Data_skimmednTuple.root"); TString draw_opt_MinBias_skimdata = Form("%s%s", iso_opt.Data(), ">> _MinBias_skimdata(50,-0.5,2)"); MinBias_skimdata->Draw(draw_opt_MinBias_skimdata.Data(), baseline_minbias_EE); TH1F* Iso03_MinBias_skimdata = (TH1F*)gDirectory->Get("_MinBias_skimdata"); Iso03_MinBias_skimdata->Sumw2(); Iso03_MinBias_skimdata->SetTitle(iso_opt.Data()); Iso03_MinBias_skimdata->SetLineColor(kRed); //Iso03_MinBias_skimdata->SetAxisRange(0,1,"Y"); Iso03_MinBias_skimdata->GetYaxis()->SetRangeUser(-1000, 1); // Iso03_MinBias_skimdata->SetLineWidth(3); int nbins_MinBias_skimdata = Iso03_MinBias_skimdata->GetNbinsX(); float n_MinBias_skimdata = Iso03_MinBias_skimdata->Integral(0, nbins_MinBias_skimdata+1); Iso03_MinBias_skimdata->Scale(1/n_MinBias_skimdata); Iso03_MinBias_skimdata->SetBinContent(nbins_MinBias_skimdata, Iso03_MinBias_skimdata->Integral(nbins_MinBias_skimdata, nbins_MinBias_skimdata+1)); Iso03_MinBias_skimdata->SetBinContent(nbins_MinBias_skimdata+1, 0); TString draw_opt_MinBias_mc = Form("%s%s", iso_opt.Data(), ">> _MinBias_mc(50,-0.5,2)"); MinBias_mc->Draw(draw_opt_MinBias_mc.Data(), baseline_minbias_EE, "sames"); TH1F* Iso03_MinBias_mc = (TH1F*)gDirectory->Get("_MinBias_mc"); Iso03_MinBias_mc->SetTitle(iso_opt.Data()); Iso03_MinBias_mc->GetYaxis()->SetTitle("Events"); Iso03_MinBias_mc->GetXaxis()->SetTitle("GeV"); //Iso03_MinBias_mc->SetAxisRange(0,1,"Y"); // Iso03_MinBias_mc->GetYaxis()->SetRangeUser(-0.5, 1.2); // Iso03_MinBias_mc->Sumw2(); Iso03_MinBias_mc->SetLineColor(kBlue); // Iso03_MinBias_mc->SetLineWidth(3); int nbins_MinBias_mc = Iso03_MinBias_mc->GetNbinsX(); float n_MinBias_mc = Iso03_MinBias_mc->Integral(0, nbins_MinBias_mc+1); Iso03_MinBias_mc->Scale(1/n_MinBias_mc); Iso03_MinBias_mc->SetBinContent(nbins_MinBias_mc, Iso03_MinBias_mc->Integral(nbins_MinBias_mc, nbins_MinBias_mc+1)); Iso03_MinBias_mc->SetBinContent(nbins_MinBias_mc+1,0); c1->SetLogy(1); Double_t xl1=.2, yl1=0.75, xl2=xl1+.2, yl2=yl1+.125; TLegend *leg = new TLegend(xl1,yl1,xl2,yl2); leg->SetFillStyle(0); leg->SetFillColor(0); //leg->SetLineStyle(0); // leg->SetLineColor(0); leg->AddEntry(Iso03_MinBias_skimdata,"MinBias_skimdata","L"); // h1 and h2 are histogram pointers leg->AddEntry(Iso03_MinBias_mc,"MinBias_mc","L"); // h1 and h2 are histogram pointers setStats(Iso03_MinBias_skimdata,Iso03_MinBias_mc, 0.6, 0.6, false); Iso03_MinBias_mc->Draw(""); Iso03_MinBias_skimdata->Draw("esames"); // // leg->Draw(); if(!jura){ TString save_opt1= Form("%s%s%s","../../../plots/900GeV/EE_skimdata_mc_",iso_opt.Data(),"_V03-00-23.gif" ); TString save_opt2= Form("%s%s%s","../../../plots/900GeV/EE_skimdata_mc_",iso_opt.Data(),"_V03-00-23.eps" ); } else{ TString save_opt1= Form("%s%s%s","../../../plots/900GeV/EE_skimdata_mc_",iso_opt.Data(),"_V03-00-23_jura.gif" ); TString save_opt2= Form("%s%s%s","../../../plots/900GeV/EE_skimdata_mc_",iso_opt.Data(),"__V03-00-23_jura.eps" ); } c1->SaveAs(save_opt1.Data()); c1->SaveAs(save_opt2.Data()); // can->Range(-0.5142857,-3.438716,6.0,0.4504303); }
void decovspeak(bool printgif = false){ //load macros and set style----------------------------------- //gROOT->SetStyle("Plain"); gStyle->SetPalette(1); //gStyle->SetOptStat("mr"); //gStyle->SetOptFit(0); gStyle->SetOptStat(0); int colors[] = {2,4,6,1}; vector<char*> filenames; vector<char*> types; //filenames.push_back("crabjobs/lpc/Commissioning10-GOODCOLL-v8_mintrkmom1_ALLPEAK/merged.root"); filenames.push_back("Commissioning10-GOODCOLL-v8_ALLPEAK/res/merged.root"); //filenames.push_back("crabjobs/lpc/Commissioning10-GOODCOLL-v8_mintrkmom1_copy/merged_2.root"); filenames.push_back("Commissioning10-GOODCOLL-v8/res/merged.root"); filenames.push_back("Commissioning10-GOODCOLL-v8_toblatebp06/res/merged.root"); //filenames.push_back("crabjobs/lpc/Spring10-START3X_V26A_356ReReco-v1_standard_geom_mintrkmom1/merged.root"); //filenames.push_back("crabjobs/lpc/Spring10-START3X_V26A_356ReReco-v1_standard_geom/merged.root"); //filenames.push_back("crabjobs/lpc/Commissioning10-GOODCOLL-v8_mintrkmom1_toblatebp063/merged.root"); types.push_back("peak"); types.push_back("deco"); types.push_back("deco (BP)"); //types.push_back("MC"); vector<char*> cantitles; //cantitles.push_back("du_dw"); //delta u, delta w TH1s //cantitles.push_back("duvsdth"); //v+/- split du vs. delta tan(theta) TH2s cantitles.push_back("duvsdth_tgraph"); //v+/- split du vs. delta tan(theta) TGraphs const unsigned int nfiles = filenames.size(); const unsigned int ncan = cantitles.size(); TCanvas *can[ncan]; int idx = 0; TFile* file[nfiles]; TH1F* hdu[nfiles]; TH1F* hdw[nfiles]; TH2F* hduthp[nfiles]; TH2F* hduthm[nfiles]; //dummy legend TLegend *leg1=new TLegend(0.15,0.65,0.35,0.85); for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ TH1F *hdummy=new TH1F(Form("hdummy_%i",ifile),Form("hdummy_%i",ifile),1,0,1); hdummy->SetLineColor(colors[ifile]); hdummy->SetMarkerColor(colors[ifile]); leg1->AddEntry(hdummy,types.at(ifile)); } leg1->SetBorderSize(1); leg1->SetFillColor(0); cout << "Getting histos... " << endl; for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ cout << "Opening " << types.at(ifile) <<" file " << filenames.at(ifile) << endl; file[ifile] = TFile::Open(filenames.at(ifile)); hdu[ifile] = (TH1F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/du_TOB"); hdw[ifile] = (TH1F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/dw_TOB"); // if( strcmp(types.at(ifile),"deco (BP)") == 0){ hduthp[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vp_wp_all"); TH2F* htp = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vp_wm_all"); hduthp[ifile] -> Add(htp); hduthm[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vm_wp_all"); TH2F* htm = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vm_wm_all"); hduthm[ifile] -> Add(htm); // }else{ // hduthp[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vp_wp"); // TH2F* htp = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vp_wm"); // hduthp[ifile] -> Add(htp); // hduthm[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vm_wp"); // TH2F* htm = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vm_wm"); // hduthm[ifile] -> Add(htm); // } } cout << "Plotting du, dw histos... " << endl; if(draw("du_dw",cantitles)){ can[idx]=new TCanvas(Form("can_%i",idx),"du_dw",1200,450); can[idx]->Divide(2,1); can[idx]->cd(1); setStats(hdu,nfiles,0.8,0.65,0.15); plotHists(hdu,nfiles,"TOB","#Delta u [#mum]",-1000,1000,10,3); leg1->Draw(); can[idx]->cd(2); setStats(hdw,nfiles,0.8,0.65,0.15); plotHists(hdw,nfiles,"TOB","#Delta w [#mum]",-2000,2000,10,3); leg1->Draw(); idx++; } cout << "Plotting du vs. delta tan theta split v+/v- histos... " << endl; //du vs. delta tan(theta) split v+/v- histos----------------------------------- if(draw("duvsdth",cantitles)){ can[idx]=new TCanvas(cantitles.at(idx),cantitles.at(idx),1200,450*nfiles); can[idx]->Divide(nfiles,2); for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ plotHistsTH2(hduthp[ifile], Form("TOB %s (v+)",types.at(ifile)),"tan(#theta_{trk})-tan(#theta_{L})", "#Delta u [#mum]",-0.3,0.5,-200,200,0,can[idx],ifile+1); plotHistsTH2(hduthm[ifile], Form("TOB %s (v-)",types.at(ifile)),"tan(#theta_{trk})-tan(#theta_{L})", "#Delta u [#mum]",-0.5,0.3,-200,200,0,can[idx],ifile+2); } idx++; } cout << "Plotting du vs. delta tan theta split v+/v- TGraphs... " << endl; //TGraph du vs. delta tan theta---------------------------------------- if(draw("duvsdth_tgraph",cantitles)){ can[idx]=new TCanvas(cantitles.at(idx),cantitles.at(idx),1200,450); can[idx]->Divide(2,1); vector<float> thetabinsp; vector<float> thetabinsm; for(int ibin=14;ibin<=30;ibin++) thetabinsp.push_back(ibin*0.05-1); for(int ibin=10;ibin<=26;ibin++) thetabinsm.push_back(ibin*0.05-1); TLatex *t=new TLatex(); t->SetNDC(); TGraphErrors *gduthp[nfiles]; TGraphErrors *gduthm[nfiles]; TF1 *fduthp[nfiles]; TF1 *fduthm[nfiles]; stringstream sduthp1[nfiles]; stringstream sduthp2[nfiles]; stringstream sduthm1[nfiles]; stringstream sduthm2[nfiles]; bool fit = false; for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++ ){ can[idx]->cd(1); hduthp[ifile]->SetName(Form("hduthp_%i",ifile)); gduthp[ifile] = getTGraphFromTH2(hduthp[ifile],thetabinsp, colors[ifile] ); fduthp[ifile]=new TF1(Form("fduthp_%i",ifile),"pol1"); fduthp[ifile]->SetLineColor( colors[ifile] ); if(fit) gduthp[ifile]->Fit(fduthp[ifile]); float dwp = fduthp[ifile]->GetParameter(1); float dwperr = fduthp[ifile]->GetParError(1); float bp = fduthp[ifile]->GetParameter(0); float bperr = fduthp[ifile]->GetParError(0); sduthp1[ifile] << "#DeltaW = " << fround(dwp,3) << " #pm " << fround(dwperr,3) << " #mum" << endl; sduthp2[ifile] << "#Deltatan(LA) = " << fround(bp/(235.-dwp),3) << " #pm " << fround(bperr/(235.-dwp),4) << endl; gduthp[ifile]->SetTitle("TOB (V+)"); gduthp[ifile]->Draw("AP"); gduthp[ifile]->GetXaxis()->SetTitle("<tan(#theta_{trk})-tan(#theta_{LA})>"); gduthp[ifile]->GetYaxis()->SetTitle("<#Deltau> [#mum]"); //gduthp[ifile]->GetXaxis()->SetLimits(-1,1); gduthp[ifile]->SetMinimum(-25); gduthp[ifile]->SetMaximum(20); can[idx]->cd(2); hduthm[ifile]->SetName(Form("hduthm_%i",ifile)); gduthm[ifile] = getTGraphFromTH2(hduthm[ifile],thetabinsm, colors[ifile] ); fduthm[ifile]=new TF1(Form("fduthm_%i",ifile),"pol1"); fduthm[ifile]->SetLineColor( colors[ifile] ); if(fit) gduthm[ifile]->Fit(fduthm[ifile]); float dwm = fduthm[ifile]->GetParameter(1); float dwmerr = fduthm[ifile]->GetParError(1); float bm = fduthm[ifile]->GetParameter(0); float bmerr = fduthm[ifile]->GetParError(0); sduthm1[ifile] << "#DeltaW = " << fround(dwm,3) << " #pm " << fround(dwmerr,3) << " #mum" << endl; sduthm2[ifile] << "#Deltatan(LA) = " << fround(bm/(235.-dwm),3) << " #pm " << fround(bmerr/(235.-dwm),4) << endl; gduthm[ifile]->SetTitle("TOB (V-)"); gduthm[ifile]->Draw("AP"); gduthm[ifile]->GetXaxis()->SetTitle("<tan(#theta_{trk})-tan(#theta_{LA})>"); gduthm[ifile]->GetYaxis()->SetTitle("<#Deltau> [#mum]"); //gduthm[ifile]->GetXaxis()->SetLimits(-1,1); gduthm[ifile]->SetMinimum(-35); gduthm[ifile]->SetMaximum(15); //leg1->Draw(); } for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++ ){ can[idx]->cd(1); if( ifile == 0 ) gduthp[ifile]->Draw("AP"); else gduthp[ifile]->Draw("sameP"); leg1->Draw(); if(fit){ t->SetTextColor( colors[ifile] ); t->DrawLatex(0.15,0.85-ifile*0.2,sduthp1[ifile].str().c_str()); t->DrawLatex(0.15,0.75-ifile*0.2,sduthp2[ifile].str().c_str()); } can[idx]->cd(2); if( ifile == 0 ) gduthm[ifile]->Draw("AP"); else gduthm[ifile]->Draw("sameP"); //leg1->Draw(); if(fit){ t->SetTextColor( colors[ifile] ); t->DrawLatex(0.15,0.85-ifile*0.2,sduthm1[ifile].str().c_str()); t->DrawLatex(0.15,0.75-ifile*0.2,sduthm2[ifile].str().c_str()); } } TCanvas *cdiff = new TCanvas("cdiff","duvsdtanthetadiff",1200,450); cdiff->Divide(2,1); cdiff->cd(1); TGraphErrors *gduthpdiff = diffTGraph(gduthp[0],gduthp[2],"TOB DECO - PEAK (v+)","<tan(#theta_{trk})-tan(#theta_{LA})>","<#Deltau> (#mum)"); TF1* fduthpdiff=new TF1("fduthpdiff","pol1",-0.5,0.5); gduthpdiff->Fit(fduthpdiff,"R"); gduthpdiff->Draw("AP"); float dwp = fduthpdiff->GetParameter(1); float dwperr = fduthpdiff->GetParError(1); float bp = fduthpdiff->GetParameter(0); float bperr = fduthpdiff->GetParError(0); stringstream sduthp1diff; stringstream sduthp2diff; sduthp1diff << "#DeltaW = " << fround(dwp,3) << " #pm " << fround(dwperr,3) << " #mum" << endl; sduthp2diff << "#Deltatan(LA) = " << fround(bp/(235.-dwp),3) << " #pm " << fround(bperr/(235.-dwp),4) << endl; t->SetTextColor(1); t->DrawLatex(0.15,0.85,sduthp1diff.str().c_str()); t->DrawLatex(0.15,0.75,sduthp2diff.str().c_str()); cdiff->cd(2); TGraphErrors *gduthmdiff = diffTGraph(gduthm[0],gduthm[2],"TOB DECO - PEAK (v-)","<tan(#theta_{trk})-tan(#theta_{LA})>","<#Deltau> (#mum)"); TF1* fduthmdiff=new TF1("fduthmdiff","pol1",-0.5,0.5); gduthmdiff->Fit(fduthmdiff,"R"); gduthmdiff->Draw("AP"); float dwm = fduthmdiff->GetParameter(1); float dwmerr = fduthmdiff->GetParError(1); float bm = fduthmdiff->GetParameter(0); float bmerr = fduthmdiff->GetParError(0); stringstream sduthm1diff; stringstream sduthm2diff; sduthm1diff << "#DeltaW = " << fround(dwm,3) << " #pm " << fround(dwmerr,3) << " #mum" << endl; sduthm2diff << "#Deltatan(LA) = " << fround(bm/(235.-dwm),3) << " #pm " << fround(bmerr/(235.-dwm),4) << endl; t->DrawLatex(0.15,0.85,sduthm1diff.str().c_str()); t->DrawLatex(0.15,0.75,sduthm2diff.str().c_str()); idx++; } for(unsigned int ican=0;ican<ncan;ican++){ can[ican]->Modified(); can[ican]->Update(); if(printgif) can[ican]->Print(Form("plots/%s_TOB.gif",cantitles.at(ican))); } }
void plot6histos(TCanvas *canvas, TH1F *s1,TH1F *r1, TH1F *s2,TH1F *r2, TH1F *s3,TH1F *r3, TH1F *s4,TH1F *r4, TH1F *s5,TH1F *r5, TH1F *s6,TH1F *r6, TText* te, char * option, double startingY, double startingX = .1,bool fit = false){ canvas->Divide(2,3); s1->SetMarkerStyle(20); r1->SetMarkerStyle(21); s1->SetMarkerColor(2); r1->SetMarkerColor(4); s1->SetMarkerSize(0.7); r1->SetMarkerSize(0.7); s1->SetLineColor(2); r1->SetLineColor(4); s1->SetLineWidth(2); r1->SetLineWidth(2); s2->SetMarkerStyle(20); r2->SetMarkerStyle(21); s2->SetMarkerColor(2); r2->SetMarkerColor(4); s2->SetMarkerSize(0.1); r2->SetMarkerSize(0.1); s2->SetLineColor(2); r2->SetLineColor(4); s2->SetLineWidth(2); r2->SetLineWidth(2); s3->SetMarkerStyle(20); r3->SetMarkerStyle(21); s3->SetMarkerColor(2); r3->SetMarkerColor(4); s3->SetMarkerSize(0.7); r3->SetMarkerSize(0.7); s3->SetLineColor(2); r3->SetLineColor(4); r3->SetLineWidth(2); s3->SetLineWidth(2); s4->SetMarkerStyle(20); r4->SetMarkerStyle(21); s4->SetMarkerColor(2); r4->SetMarkerColor(4); s4->SetMarkerSize(0.7); r4->SetMarkerSize(0.7); s4->SetLineColor(2); r4->SetLineColor(4); r4->SetLineWidth(2); s4->SetLineWidth(2); s5->SetMarkerStyle(20); r5->SetMarkerStyle(21); s5->SetMarkerColor(2); r5->SetMarkerColor(4); s5->SetMarkerSize(0.7); r5->SetMarkerSize(0.7); s5->SetLineColor(2); r5->SetLineColor(4); r5->SetLineWidth(2); s5->SetLineWidth(2); s6->SetMarkerStyle(20); r6->SetMarkerStyle(21); s6->SetMarkerColor(2); r6->SetMarkerColor(4); s6->SetMarkerSize(0.7); r6->SetMarkerSize(0.7); s6->SetLineColor(2); r6->SetLineColor(4); r6->SetLineWidth(2); s6->SetLineWidth(2); //setStats(r1,s1, startingY, startingX, fit); canvas->cd(1); setStats(s1,r1, -1, 0, false); r1->Draw(); s1->Draw("sames"); double kstest = mykolmo(s1,r1); TPad *c1_1 = canvas->GetPad(1); if(kstest<0.7){ c1_1->SetFillColor(kYellow);} canvas->cd(2); gPad->SetLogy(); setStats(s2,r2, -1, 0, false); s2->Draw(); r2->Draw("sames"); double kstest = mykolmo(s2,r2); TPad *c2_2 = canvas->GetPad(2); if(kstest<0.7){ c2_2->SetFillColor(kYellow);} canvas->cd(3); setStats(s3,r3, -1, 0, false); r3->Draw(); s3->Draw("sames"); double kstest = mykolmo(s3,r3); TPad *c3_3 = canvas->GetPad(3); if(kstest<0.7){ c3_3->SetFillColor(kYellow);} canvas->cd(4); gPad->SetLogy(); setStats(s4,r4, -1, 0, false); s4->Draw(); r4->Draw("sames"); double kstest = mykolmo(s4,r4); TPad *c4_4 = canvas->GetPad(4); if(kstest<0.7){ c4_4->SetFillColor(kYellow);} canvas->cd(5); setStats(s5,r5, -1, 0, false); r5->Draw(); s5->Draw("sames"); double kstest = mykolmo(s5,r5); TPad *c5_5 = canvas->GetPad(5); if(kstest<0.7){ c5_5->SetFillColor(kYellow);} canvas->cd(6); gPad->SetLogy(); setStats(s6,r6, -1, 0, false); r6->Draw(); s6->Draw("sames"); double kstest = mykolmo(s6,r6); TPad *c6_6 = canvas->GetPad(6); if(kstest<0.7){ c6_6->SetFillColor(kYellow);} }
void createPlot(TCanvas *canvas, TFile *file, TString type, TString name, int nbins, double xMin, double xMax, bool runSecTrackColl, TText* te, char * option, double startingY, double startingX = .1, bool fit = false, bool logx=false, bool logy=false, int normScale){ TTree *tree; tree = file->GetObject("tree",tree); TH1F *h1; // for ctf trk h1 = new TH1F("h1", "h1", nbins, xMin, xMax); TH1F *h2; // for sectrk h2 = new TH1F("h2","h2",nbins,xMin,xMax); TString x_title = ""; TString y_title = "Number of Tracks"; // If the histogram is filled per track, cut on the event and track. // Otherwise, cut only on the event level TString basecut="isTechBit40&&!isBeamHalo&&hasGoodPvtx==1"; TString evtcutstring=basecut; evtcutstring.Append("&&EVTSELECTION"); TString trkcutstring=basecut; trkcutstring.Append("&&EVTSELECTION&&TRKSELECTION"); TString ctf_name = "ctf_"; if( name.Contains("cluster_charge",TString::kExact) ) { ctf_name = "ctf"; ctf_name.Append(name); tree->Project("h1",ctf_name, evtcutstring); } else if (name == "recz_pxlpvtx") { tree->Project("h1",name, evtcutstring); y_title="Number of pixelVertices"; } else if( name.Contains("pvtx")) { if(name.Contains("rec")) { y_title="Number of Real PrimaryVertices"; TString vtxcutstring=evtcutstring; tree->Project("h1",name, vtxcutstring.Append("&&isFake_pvtx==0")); } else { y_title="Number of Valid PrimaryVertices"; tree->Project("h1",name, evtcutstring); } } else if ( name.Contains("nVertices",TString::kExact) || name.Contains("hasGoodPvtx",TString::kExact) || name.Contains("nPixelVertices",TString::kExact) || name.Contains("isTechBit40",TString::kExact) || name.Contains("isBSC",TString::kExact) || name.Contains("bsX0",TString::kExact) || name.Contains("bsY0",TString::kExact) || name.Contains("bsZ0",TString::kExact) || name.Contains("glob_ls",TString::kExact) || name.Contains("glob_bx",TString::kExact) ) { tree->Project("h1",name, evtcutstring); y_title = "Number of Events"; } else { ctf_name.Append(name); tree->Project("h1",ctf_name, trkcutstring); } if(runSecTrackColl && ctf_name.Contains("ctf")) { TString sectrk_name = ctf_name.ReplaceAll("ctf","sectrk"); tree->Project("h2",sectrk_name,evtcutstring); } // Set the x_tile if( name == "n" ) { x_title = "Tracks per Event" ; y_title = "Number of Events"; } // All Clusters if( name.Contains("clusterCharge_all",TString::kExact) ) x_title = "All Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TIB",TString::kExact) ) x_title = "All TIB Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TID",TString::kExact) ) x_title = "All TID Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TOB",TString::kExact) ) x_title = "All TOB Cluster Charge (ADC Counts)"; if( name.Contains("clusterCharge_TEC",TString::kExact) ) x_title = "All TEC Cluster Charge (ADC Counts)"; if( name.Contains("cluster_charge",TString::kExact) ) { x_title = " Strip Cluster Charge (ADC Counts)"; y_title = "Number of Clusters"; } // Histograms filled per Track if( name.Contains("nHit",TString::kExact) ) x_title = "Number of Valid Hits per Track" ; if( name.Contains("nLostHit",TString::kExact) ) x_title = "Number of Lost Hits per Track" ; if( name.Contains("nPXBhit",TString::kExact) ) x_title = "Number of PixelBarrel Hits per Track" ; if( name.Contains("nPXFhit",TString::kExact) ) x_title = "Number of PixEndcap Hits per Track" ; if( name.Contains("nTIBhit",TString::kExact) ) x_title = "Number of TIB Hits per Track" ; if( name.Contains("nTOBhit",TString::kExact) ) x_title = "Number of TOB Hits per Track" ; if( name.Contains("nTIDhit",TString::kExact) ) x_title = "Number of TID Hits per Track" ; if( name.Contains("nTEChit",TString::kExact) ) x_title = "Number of TEC Hits per Track" ; if( name.Contains("nPixelHit",TString::kExact) ) x_title = "Number of Pixel Hits per Track" ; if( name.Contains("nLayers",TString::kExact) ) x_title = "Number of Layers per Track" ; if( name.Contains("nLayers3D",TString::kExact) ) x_title = "Number of 3D Layers per Track" ; if( name.Contains("nPXBLayers",TString::kExact) ) x_title = "Number of PixelBarrel Layers per Track" ; if( name.Contains("nPXFLayers",TString::kExact) ) x_title = "Number of PixEndcap Layers per Track" ; if( name.Contains("eta",TString::kExact) ) x_title = "Track Pseudorapidity" ; if( name.Contains("pt",TString::kExact) ) x_title = "p_{T} (GeV)" ; if( name.Contains("phi",TString::kExact) ) x_title = "Track Azimuthal Angle" ; if( name.Contains("dxy",TString::kExact) ) x_title = "Track dxy wrt (0,0,0) (cm)" ; if( name.Contains("dz",TString::kExact) ) x_title = "Track dz wrt (0,0,0) (cm)" ; if( name.Contains("dxyCorr",TString::kExact) ) x_title = "Track dxy wrt BS (cm)" ; if( name.Contains("dzCorr",TString::kExact) ) x_title = "Track dz wrt BS (cm)" ; if( name.Contains("xPCA",TString::kExact) ) x_title = "x PCA (cm)" ; if( name.Contains("yPCA",TString::kExact) ) x_title = "y PCA (cm)" ; if( name.Contains("zPCA",TString::kExact) ) x_title = "z PCA (cm)" ; if( name.Contains("chi2ndof",TString::kExact) ) x_title = "#chi^{2}/ndf" ; if( name.Contains("algo",TString::kExact) ) x_title = "Track Algorithm" ; if( name.Contains("isHighPurity",TString::kExact) ) x_title = "isHighPurity" ; // pvtx stuff if( name.Contains("recx_pvtx",TString::kExact) ) x_title = "PrimaryVertex Position X (cm)" ; if( name.Contains("recy_pvtx",TString::kExact) ) x_title = "PrimaryVertex Position Y (cm)" ; if( name.Contains("recz_pvtx",TString::kExact) ) x_title = "PrimaryVertex Position Z (cm)" ; if( name.Contains("isFake_pvtx",TString::kExact) ) x_title = "PrimaryVertex isFake()"; if( name.Contains("recz_pxlpvtx",TString::kExact) ) x_title = "pixelVertices Position Z (cm)" ; //beamspot if( name.Contains("bsX0",TString::kExact) ) x_title = "BeamSpot X (cm)" ; if( name.Contains("bsY0",TString::kExact) ) x_title = "BeamSpot Y (cm)" ; if( name.Contains("bsZ0",TString::kExact) ) x_title = "BeamSpot Z (cm)" ; if( name.Contains("nVertices",TString::kExact) ) x_title = "Number of PrimaryVertices"; if( name.Contains("nPixelVertices",TString::kExact) ) x_title = "Number of pixelVertices"; if( name.Contains("hasGoodPvtx",TString::kExact) ) x_title = "hasRealPrimaryVertex"; if( name.Contains("isTechBit40",TString::kExact) ) x_title = "isTechBit40"; if( name.Contains("isBSC",TString::kExact) ) x_title = "isBSC"; if( name.Contains("glob_bx",TString::kExact) ) x_title = "bunchCrossing"; if(logx) gPad->SetLogx(); else gPad->SetLogx(0); if(logy) gPad->SetLogy(); else gPad->SetLogy(0); h1->SetLineColor(4); h1->SetMarkerColor(4); h1->SetMarkerStyle(21); h1->SetMarkerSize(0.7); //h1->StatOverflows(kTRUE); h1->SetLineWidth(3); h1->GetXaxis()->SetTitle(x_title); h1->GetYaxis()->SetTitle(y_title); if(runSecTrackColl) { h2->SetLineColor(2); h2->SetMarkerColor(2); h2->SetMarkerStyle(21); h2->SetMarkerSize(0.7); //h2->StatOverflows(kTRUE); h2->SetLineWidth(3); h2->GetXaxis()->SetTitle(x_title); h2->GetYaxis()->SetTitle(y_title); } if(runSecTrackColl) { setStats(h1, h2, startingY, startingX, fit); NormalizeHistograms(h1, h2, normScale); if(!logy && !logx) fixRangeY(h1,h2); //I don't know why, with logy or logx, this line creates trouble in overlaying two plots if there is an Y=0 bin } else { setStats(h1, startingY, startingX, fit); } gPad->Update(); h1->Draw(); if(runSecTrackColl) h2->Draw("sames"); canvas->Update(); TLegend *leg = new TLegend(0.16,0.93,0.60,0.995); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillColor(0); leg->SetBorderSize(1); leg->AddEntry(h1, "TRACKCOLLECTION" , "L" ); if(runSecTrackColl) leg->AddEntry(h2, "SECTRKCOLLECTION" , "L" ); if(type == "perTrk" || name == "n" || name == "cluster_charge") leg->Draw("SAME"); TString pngdirname ="PNGDIR/SAMPLE/CUTSTRING/"; TString pngfilename = pngdirname; pngfilename.Append(name); pngfilename.Append(".png"); canvas->Print(pngfilename); TString epsdirname ="EPSDIR/SAMPLE/CUTSTRING/"; TString epsfilename = epsdirname; epsfilename.Append(name); epsfilename.Append(".eps"); canvas->Print(epsfilename); delete h1; delete h2; }
void decovspeak(bool printgif = false){ //load macros and set style----------------------------------- //gROOT->SetStyle("Plain"); gStyle->SetPalette(1); //gStyle->SetOptStat("mr"); //gStyle->SetOptFit(0); gStyle->SetOptStat(0); int colors[] = {2,4,6,1}; vector<string> filenames; vector<string> types; //-----------files--------------------- filenames.push_back("MinimumBias_Commissioning10-GOODCOLL-Jun9thSkim_v1_PEAK/res/merged.root"); filenames.push_back("MinimumBias_Commissioning10-GOODCOLL-Jun9thSkim_v1/res/merged.root"); types.push_back("peak"); types.push_back("deco"); //----------variables to plot---------- vector<string> cantitles; //cantitles.push_back("du_dw"); //delta u, delta w TH1s //cantitles.push_back("duvsdth"); //v+/- split du vs. delta tan(theta) TH2s //cantitles.push_back("duvsdth_tgraph"); //v+/- split du vs. delta tan(theta) TGraphs cantitles.push_back("dwTEC"); //dw histos for TEC ring/zside/petalside const unsigned int nfiles = filenames.size(); const unsigned int ncan = cantitles.size(); TCanvas *can[ncan]; int idx = 0; TFile* file[nfiles]; TH1F* hdu[nfiles]; TH1F* hdw[nfiles]; TH2F* hduthp[nfiles]; TH2F* hduthm[nfiles]; //dummy legend TLegend *leg1=new TLegend(0.15,0.65,0.35,0.85); for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ TH1F *hdummy=new TH1F(Form("hdummy_%i",ifile),Form("hdummy_%i",ifile),1,0,1); hdummy->SetLineColor(colors[ifile]); hdummy->SetMarkerColor(colors[ifile]); leg1->AddEntry(hdummy,types.at(ifile).c_str()); } leg1->SetBorderSize(1); leg1->SetFillColor(0); cout << "Getting histos... " << endl; for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ cout << "Opening " << types.at(ifile) <<" file " << filenames.at(ifile) << endl; file[ifile] = TFile::Open(filenames.at(ifile).c_str()); hdu[ifile] = (TH1F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/du_TOB"); hdw[ifile] = (TH1F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/dw_TOB"); hduthp[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vp_wp_all"); TH2F* htp = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vp_wm_all"); hduthp[ifile] -> Add(htp); hduthm[ifile] = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vm_wp_all"); TH2F* htm = (TH2F*) file[ifile]->Get("PeakDecoResiduals/PeakDecoResiduals/duvsdtantheta_TOB_vm_wm_all"); hduthm[ifile] -> Add(htm); } if(draw("dwTEC",cantitles)){ gStyle->SetOptFit(11); TCanvas *dwTEC_can[2][2]; TH1F* hdw_TEC[2][2][7]; TF1* hgaus[2][2][7]; float mean[2][2][7]; float meanerr[2][2][7]; TGraphErrors *g00[nfiles]; TGraphErrors *g01[nfiles]; TGraphErrors *g10[nfiles]; TGraphErrors *g11[nfiles]; can[idx]=new TCanvas(Form("can_%i",idx),"du_dw",1200,600); can[idx]->Divide(2,1); for( unsigned int ifile = 0 ; ifile < nfiles ; ++ifile ){ for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ dwTEC_can[i][j] = new TCanvas(Form("dwTEC_can_%i_%i",i,j),"",1200,600); dwTEC_can[i][j]->Divide(4,2); for(int k=0;k<7;k++){ dwTEC_can[i][j]->cd(k+1); hdw_TEC[i][j][k] = (TH1F*) file[ifile]->Get(Form("PeakDecoResiduals/PeakDecoResiduals/hdw_TEC_z%i_petal%i_ring%i_stereo0",i,j,k+1)); hgaus[i][j][k] = new TF1(Form("gaus_%i_%i_%i",i,j,k+1),"gaus",-500,500); hgaus[i][j][k] -> SetLineColor(2); hdw_TEC[i][j][k]->Rebin(10); hdw_TEC[i][j][k]->Draw(); hdw_TEC[i][j][k]->Fit( hgaus[i][j][k] ,"R"); mean[i][j][k] = hgaus[i][j][k]->GetParameter(1); meanerr[i][j][k] = hgaus[i][j][k]->GetParError(1); } } } can[idx]->cd(ifile+1); float ring[7]; float ringerr[7]; float mean00[7]; float mean01[7]; float mean10[7]; float mean11[7]; float meanerr00[7]; float meanerr01[7]; float meanerr10[7]; float meanerr11[7]; for(int k=0;k<7;k++){ ring[k] = k + 1; mean00[k] = mean[0][0][k]; mean01[k] = mean[0][1][k]; mean10[k] = mean[1][0][k]; mean11[k] = mean[1][1][k]; ringerr[k] = 0; meanerr00[k] = meanerr[0][0][k]; meanerr01[k] = meanerr[0][1][k]; meanerr10[k] = meanerr[1][0][k]; meanerr11[k] = meanerr[1][1][k]; } g00[ifile] = new TGraphErrors(7,ring,mean00,ringerr,meanerr00); g00[ifile]->SetMarkerStyle(20); g00[ifile]->GetXaxis()->SetTitle("Ring"); g00[ifile]->GetYaxis()->SetTitle("<#Deltaw> (#mum)"); g00[ifile]->SetTitle(Form("MinBias data (%s)",types.at(ifile).c_str())); g00[ifile]->SetMinimum(-50); g00[ifile]->SetMaximum(50); g00[ifile]->Draw("AP"); g01[ifile] = new TGraphErrors(7,ring,mean01,ringerr,meanerr01); g01[ifile]->SetMarkerStyle(20); g01[ifile]->SetMarkerColor(2); g01[ifile]->SetLineColor(2); g01[ifile]->Draw("sameP"); g10[ifile] = new TGraphErrors(7,ring,mean10,ringerr,meanerr10); g10[ifile]->SetMarkerStyle(20); g10[ifile]->SetMarkerColor(4); g10[ifile]->SetLineColor(4); g10[ifile]->Draw("sameP"); g11[ifile] = new TGraphErrors(7,ring,mean11,ringerr,meanerr11); g11[ifile]->SetMarkerStyle(20); g11[ifile]->SetMarkerColor(6); g11[ifile]->SetLineColor(6); g11[ifile]->Draw("sameP"); TLegend *leg=new TLegend(0.15,0.7,0.35,0.9); leg->AddEntry(g00[ifile],"Z- back-petal","p"); leg->AddEntry(g01[ifile],"Z- front-petal","p"); leg->AddEntry(g10[ifile],"Z+ back-petal","p"); leg->AddEntry(g11[ifile],"Z+ front-petal","p"); leg->SetBorderSize(1); leg->SetFillColor(0); leg->Draw(); } if( nfiles > 1 ){ TCanvas *dwdiff = new TCanvas("dwdiff","dwdiff",600,600); dwdiff->cd(); TGraphErrors *gdiff00 = diffTGraph(g00[0],g00[1],"MinBias data deco-peak", "Ring", "<#Deltaw> (#mum)"); gdiff00->SetMarkerStyle(20); gdiff00->SetMinimum(-25); gdiff00->SetMaximum(25); gdiff00->Draw("AP"); TGraphErrors *gdiff01 = diffTGraph(g01[0],g01[1],"MinBias data deco-peak", "Ring", "<#Deltaw> (#mum)"); gdiff01->SetMarkerStyle(20); gdiff01->SetMarkerColor(2); gdiff01->SetLineColor(2); gdiff01->Draw("sameP"); TGraphErrors *gdiff10 = diffTGraph(g10[0],g10[1],"MinBias data deco-peak", "Ring", "<#Deltaw> (#mum)"); gdiff10->SetMarkerStyle(20); gdiff10->SetMarkerColor(4); gdiff10->SetLineColor(4); gdiff10->Draw("sameP"); TGraphErrors *gdiff11 = diffTGraph(g11[0],g11[1],"MinBias data deco-peak", "Ring", "<#Deltaw> (#mum)"); gdiff11->SetMarkerStyle(20); gdiff11->SetMarkerColor(6); gdiff11->SetLineColor(6); gdiff11->Draw("sameP"); } } if(draw("du_dw",cantitles)){ cout << "Plotting du, dw histos... " << endl; can[idx]=new TCanvas(Form("can_%i",idx),"du_dw",1200,450); can[idx]->Divide(2,1); can[idx]->cd(1); setStats(hdu,nfiles,0.8,0.65,0.15); plotHists(hdu,nfiles,"TOB","#Delta u [#mum]",-1000,1000,10,3); leg1->Draw(); can[idx]->cd(2); setStats(hdw,nfiles,0.8,0.65,0.15); plotHists(hdw,nfiles,"TOB","#Delta w [#mum]",-2000,2000,10,3); leg1->Draw(); idx++; } //du vs. delta tan(theta) split v+/v- histos----------------------------------- if(draw("duvsdth",cantitles)){ cout << "Plotting du vs. delta tan theta split v+/v- histos... " << endl; can[idx]=new TCanvas(cantitles.at(idx).c_str(),cantitles.at(idx).c_str(),1200,450*nfiles); can[idx]->Divide(nfiles,2); for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++){ plotHistsTH2(hduthp[ifile], Form("TOB %s (v+)",types.at(ifile).c_str()),"tan(#theta_{trk})-tan(#theta_{L})", "#Delta u [#mum]",-0.3,0.5,-200,200,0,can[idx],ifile+1); plotHistsTH2(hduthm[ifile], Form("TOB %s (v-)",types.at(ifile).c_str()),"tan(#theta_{trk})-tan(#theta_{L})", "#Delta u [#mum]",-0.5,0.3,-200,200,0,can[idx],ifile+2); } idx++; } //TGraph du vs. delta tan theta---------------------------------------- if(draw("duvsdth_tgraph",cantitles)){ cout << "Plotting du vs. delta tan theta split v+/v- TGraphs... " << endl; can[idx]=new TCanvas(cantitles.at(idx).c_str(),cantitles.at(idx).c_str(),1200,450); can[idx]->Divide(2,1); vector<float> thetabinsp; vector<float> thetabinsm; for(int ibin=14;ibin<=30;ibin++) thetabinsp.push_back(ibin*0.05-1); for(int ibin=10;ibin<=26;ibin++) thetabinsm.push_back(ibin*0.05-1); TLatex *t=new TLatex(); t->SetNDC(); TGraphErrors *gduthp[nfiles]; TGraphErrors *gduthm[nfiles]; TF1 *fduthp[nfiles]; TF1 *fduthm[nfiles]; stringstream sduthp1[nfiles]; stringstream sduthp2[nfiles]; stringstream sduthm1[nfiles]; stringstream sduthm2[nfiles]; bool fit = false; for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++ ){ can[idx]->cd(1); hduthp[ifile]->SetName(Form("hduthp_%i",ifile)); gduthp[ifile] = getTGraphFromTH2(hduthp[ifile],thetabinsp, colors[ifile] ); fduthp[ifile]=new TF1(Form("fduthp_%i",ifile),"pol1"); fduthp[ifile]->SetLineColor( colors[ifile] ); if(fit) gduthp[ifile]->Fit(fduthp[ifile]); float dwp = fduthp[ifile]->GetParameter(1); float dwperr = fduthp[ifile]->GetParError(1); float bp = fduthp[ifile]->GetParameter(0); float bperr = fduthp[ifile]->GetParError(0); sduthp1[ifile] << "#DeltaW = " << fround(dwp,3) << " #pm " << fround(dwperr,3) << " #mum" << endl; sduthp2[ifile] << "#Deltatan(LA) = " << fround(bp/(235.-dwp),3) << " #pm " << fround(bperr/(235.-dwp),4) << endl; gduthp[ifile]->SetTitle("TOB (V+)"); gduthp[ifile]->Draw("AP"); gduthp[ifile]->GetXaxis()->SetTitle("<tan(#theta_{trk})-tan(#theta_{LA})>"); gduthp[ifile]->GetYaxis()->SetTitle("<#Deltau> [#mum]"); //gduthp[ifile]->GetXaxis()->SetLimits(-1,1); gduthp[ifile]->SetMinimum(-25); gduthp[ifile]->SetMaximum(20); can[idx]->cd(2); hduthm[ifile]->SetName(Form("hduthm_%i",ifile)); gduthm[ifile] = getTGraphFromTH2(hduthm[ifile],thetabinsm, colors[ifile] ); fduthm[ifile]=new TF1(Form("fduthm_%i",ifile),"pol1"); fduthm[ifile]->SetLineColor( colors[ifile] ); if(fit) gduthm[ifile]->Fit(fduthm[ifile]); float dwm = fduthm[ifile]->GetParameter(1); float dwmerr = fduthm[ifile]->GetParError(1); float bm = fduthm[ifile]->GetParameter(0); float bmerr = fduthm[ifile]->GetParError(0); sduthm1[ifile] << "#DeltaW = " << fround(dwm,3) << " #pm " << fround(dwmerr,3) << " #mum" << endl; sduthm2[ifile] << "#Deltatan(LA) = " << fround(bm/(235.-dwm),3) << " #pm " << fround(bmerr/(235.-dwm),4) << endl; gduthm[ifile]->SetTitle("TOB (V-)"); gduthm[ifile]->Draw("AP"); gduthm[ifile]->GetXaxis()->SetTitle("<tan(#theta_{trk})-tan(#theta_{LA})>"); gduthm[ifile]->GetYaxis()->SetTitle("<#Deltau> [#mum]"); //gduthm[ifile]->GetXaxis()->SetLimits(-1,1); gduthm[ifile]->SetMinimum(-35); gduthm[ifile]->SetMaximum(15); //leg1->Draw(); } for(unsigned int ifile = 0 ; ifile < nfiles ; ifile++ ){ can[idx]->cd(1); if( ifile == 0 ) gduthp[ifile]->Draw("AP"); else gduthp[ifile]->Draw("sameP"); leg1->Draw(); if(fit){ t->SetTextColor( colors[ifile] ); t->DrawLatex(0.15,0.85-ifile*0.2,sduthp1[ifile].str().c_str()); t->DrawLatex(0.15,0.75-ifile*0.2,sduthp2[ifile].str().c_str()); } can[idx]->cd(2); if( ifile == 0 ) gduthm[ifile]->Draw("AP"); else gduthm[ifile]->Draw("sameP"); //leg1->Draw(); if(fit){ t->SetTextColor( colors[ifile] ); t->DrawLatex(0.15,0.85-ifile*0.2,sduthm1[ifile].str().c_str()); t->DrawLatex(0.15,0.75-ifile*0.2,sduthm2[ifile].str().c_str()); } } if( filenames.size() > 1 ){ TCanvas *cdiff = new TCanvas("cdiff","duvsdtanthetadiff",1200,450); cdiff->Divide(2,1); cdiff->cd(1); TGraphErrors *gduthpdiff = diffTGraph(gduthp[0],gduthp[1],"TOB DECO - PEAK (v+)","<tan(#theta_{trk})-tan(#theta_{LA})>","<#Deltau> (#mum)"); TF1* fduthpdiff=new TF1("fduthpdiff","pol1",-0.5,0.5); gduthpdiff->Fit(fduthpdiff,"R"); gduthpdiff->Draw("AP"); float dwp = fduthpdiff->GetParameter(1); float dwperr = fduthpdiff->GetParError(1); float bp = fduthpdiff->GetParameter(0); float bperr = fduthpdiff->GetParError(0); stringstream sduthp1diff; stringstream sduthp2diff; sduthp1diff << "#DeltaW = " << fround(dwp,3) << " #pm " << fround(dwperr,3) << " #mum" << endl; sduthp2diff << "#Deltatan(LA) = " << fround(bp/(235.-dwp),3) << " #pm " << fround(bperr/(235.-dwp),4) << endl; t->SetTextColor(1); t->DrawLatex(0.15,0.85,sduthp1diff.str().c_str()); t->DrawLatex(0.15,0.75,sduthp2diff.str().c_str()); cdiff->cd(2); TGraphErrors *gduthmdiff = diffTGraph(gduthm[0],gduthm[1],"TOB DECO - PEAK (v-)","<tan(#theta_{trk})-tan(#theta_{LA})>","<#Deltau> (#mum)"); TF1* fduthmdiff=new TF1("fduthmdiff","pol1",-0.5,0.5); gduthmdiff->Fit(fduthmdiff,"R"); gduthmdiff->Draw("AP"); float dwm = fduthmdiff->GetParameter(1); float dwmerr = fduthmdiff->GetParError(1); float bm = fduthmdiff->GetParameter(0); float bmerr = fduthmdiff->GetParError(0); stringstream sduthm1diff; stringstream sduthm2diff; sduthm1diff << "#DeltaW = " << fround(dwm,3) << " #pm " << fround(dwmerr,3) << " #mum" << endl; sduthm2diff << "#Deltatan(LA) = " << fround(bm/(235.-dwm),3) << " #pm " << fround(bmerr/(235.-dwm),4) << endl; t->DrawLatex(0.15,0.85,sduthm1diff.str().c_str()); t->DrawLatex(0.15,0.75,sduthm2diff.str().c_str()); idx++; } } for(unsigned int ican=0;ican<ncan;ican++){ can[ican]->Modified(); can[ican]->Update(); if(printgif) can[ican]->Print(Form("plots/%s_TOB.gif",cantitles.at(ican).c_str())); } }