{ int n = Output->GetEntries(); //Create four histograms for each pmt, split the histograms up by range and CNO or nonCNO TH1I *pmt_0_range0_CNO = new TH1I("pmt_0_range0_CNO","PMT0 AcdRange=0 CNO",4097,0,4096); TH1I *pmt_0_range1_CNO = new TH1I("pmt_0_range1_CNO","PMT0 AcdRange=1 CNO",4097,0,4096); TH1I *pmt_1_range0_CNO = new TH1I("pmt_1_range0_CNO","PMT1 AcdRange=0 CNO",4097,0,4096); TH1I *pmt_1_range1_CNO= new TH1I("pmt_1_range1_CNO","PMT1 AcdRange=1 CNO",4097,0,4096); TH1I *pmt_0_range0 = new TH1I("pmt_0_range0","PMT0 AcdRange=0 nonCNO",4097,0,4096); TH1I *pmt_0_range1 = new TH1I("pmt_0_range1","PMT0 AcdRange=1 nonCNO",4097,0,4096); TH1I *pmt_1_range0 = new TH1I("pmt_1_range0","PMT1 AcdRange=0 nonCNO",4097,0,4096); TH1I *pmt_1_range1 = new TH1I("pmt_1_range1","PMT1 AcdRange=1 nonCNO",4097,0,4096); int zero,one,ZERO,ONE,interest,tword,max_range0,max_range1,pha[604][2],range[604][2]; float sum; int pmt0_range0,pmt0_range1,pmt1_range0,pmt1_range1; //Tell the macro which tile you want to look at cout << "Tile of Interest:"; cin >> interest; //Activate necessary branches Output->SetBranchStatus("*", 0); Output->SetBranchStatus("GemConditionsWord", 1); Output->SetBranchStatus("AcdPha", 1); Output->SetBranchStatus("AcdRange", 1); Output->SetBranchStatus("GltGemSummary",1); //The use of GltGemSummary requires adding the merittuple as a friend to output before running the macro //Assign pointers for each branch Output->SetBranchAddress("GemConditionsWord",&tword); Output->SetBranchAddress("AcdPha",pha); Output->SetBranchAddress("AcdRange", range); Output->SetBranchAddress("GltGemSummary",&sum); for(int i=0;iGetEntry(i); if(sum&32){} //If the periodic trigger is set, do nothing. else{ //Look through all tiles and ribbons for both pmts to get the max PHA value in both ranges for(int tile=0;tile<604;tile++){ for(int pmt=0;pmt<2;pmt++){ if(pha[tile][pmt]>max_range0&&range[tile][pmt]==0){ max_range0=pha[tile][pmt]; } if(pha[tile][pmt]>max_range1&&range[tile][pmt]==1){ max_range1=pha[tile][pmt]; } } } //Though this does cycle through the ribbons as well, since our tile of interest is not a ribbon //we won't pick out those events where the max PHA was in a ribbon. //Check if there are any tiles with AcdRange=1,i.e.max_range1=0, for pmt0. //If there are, don't even check the tile of interest for an AcdRange=0 max PHA. if(pha[interest][0]==max_range0&&range[interest][0]==0&&max_range1==0&&pha[interest][0]>0){ pmt0_range0=pha[interest][0]; zero=1; //This variable (along with variables one,ZERO,and ONE tell the macro which histograms to fill) } if(pha[interest][0]==max_range1&&range[interest][0]==1&&pha[interest][0]>0){ pmt0_range1=pha[interest][0]; one=1; } //same as above, but for pmt1 if(pha[interest][1]==max_range0&&range[interest][1]==0&&max_range1==0&&pha[interest][1]>0){ pmt1_range0=pha[interest][1]; ZERO=1; } if(pha[interest][1]==max_range1&&range[interest][1]==1&&pha[interest][1]>0){ pmt1_range1=pha[interest][1]; ONE=1; } } //check if no range 1 then fill histograms for pmt0 according to CNO or nonCNO if(zero==1&&pmt0_range0>0&&one==0){ if(tword&16){ pmt_0_range0_CNO->Fill(pmt0_range0); cout<<"PMT0, event #"<Fill(pmt0_range0);} } //fills histograms for pmt0 if there are tiles with AcdRange=1. if(one==1&&pmt0_range1>0){ if(tword&16){ pmt_0_range1_CNO->Fill(pmt0_range1);} else{ pmt_0_range1->Fill(pmt0_range1);} } //same as above, but for pmt1 if(ZERO==1&&pmt1_range0>0&&ONE==0){ if(tword&16){ pmt_1_range0_CNO->Fill(pmt1_range0); cout<<"PMT1, event #"<Fill(pmt1_range0);} } if(ONE==1&&pmt1_range1>0){ if(tword&16){ pmt_1_range1_CNO->Fill(pmt1_range1);} else{ pmt_1_range1->Fill(pmt1_range1);} } } Output->SetBranchStatus("*", 1); }