{ TH1I *pha1_range0 = new TH1I("pha1_range0","Pha Max for CNO Events AcdRange=0",400,0,4096); TH1I *pha2 _range0= new TH1I("pha2_range0","Pha Max for non-CNO Events AcdRange=0",400,0,4096); TH1I *pha1_range1 = new TH1I("pha1_range1","Pha Max for CNO Events AcdRange=1",400,0,4096); TH1I *pha2 _range1= new TH1I("pha2_range1","Pha Max for non-CNO Events AcdRange=1",400,0,4096); TH1I *tiles_range0 = new TH1I("tiles_range0","Tile with max Pha in an Event Range0",436,0,435); TH1I *tiles_range1 = new TH1I("tiles_range1","Tile with max Pha in an Event Range1",436,0,435); TH1I *tiles = new TH1I("tiles","Tile with max Pha in an Event",436,0,435); TH1I *CNOhits = new TH1I("CNOhits","Tiles and Ribbons with max PHA for CNO event",604,0,603); int tword,max_range0,max_range1,hit_range0,hit_range1,hit,pha[604][2],range[604][2]; float sum; //Turn all branches off and then initialize necessary branches Output->SetBranchStatus("*", 0); Output->SetBranchStatus("GemConditionsWord", 1); Output->SetBranchStatus("AcdPha", 1); Output->SetBranchStatus("AcdRange", 1); Output->SetBranchStatus("GltGemSummary",1); //Assign pointers to branches Output->SetBranchAddress("GemConditionsWord",&tword); Output->SetBranchAddress("AcdPha",pha); Output->SetBranchAddress("AcdRange", range); Output->SetBranchAddress("GltGemSummary",&sum); //Use of this branch requires friending the merit tuple //To the svac tuple int n = Output->GetEntries(); for(int i=0;iGetEntry(i); if(sum&32){} //if the periodic trigger is set, do nothing else{ //cycle through all tiles and ribbons and both pmts checking for the max 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]; hit_range0=tile; } if(pha[tile][pmt]>max_range1&&range[tile][pmt]==1){ max_range1=pha[tile][pmt]; hit_range1=tile; } } } //For CNO events, first check if there are any AcdRange=1 hits, if so then don't fill AcdRange=0 histogram //if not then check to see if the max is in a tile and not a ribbon, if so fill //if there was an AcdRange=1 hit, then fill that histogram provided the max was in a tile and not a ribbon if(tword&16){ if(max_range1==0){ if(hit_range0<=430){ pha1_range0->Fill(max_range0); hit=hit_range0; } } else{ if(hit_range1<=430){ pha1_range1->Fill(max_range1); hit=hit_range1; } } } //same as above, but for non CNO events else{ if(max_range1==0){ if(hit_range0<=430){ pha2_range0->Fill(max_range0); hit=hit_range0; } } else{ if(hit_range1<=430){ pha2_range1->Fill(max_range1); hit=hit_range1; } } } //fill the tile histograms, don't discriminate between CNO and nonCNO, only range //ensure that tile histograms only fill if the max was in a tile not a ribbon if(max_range1==0&&max_range0>0&&hit_range0<=430){ tiles_range0->Fill(hit_range0); } if(max_range1>0&hit_range1<=430){ tiles_range1->Fill(hit_range1); } if(hit<=430){ tiles->Fill(hit); } } //this fills a histogram with all tiles and ribbons with max PHA in a CNO event if((tword&16)&&max_range1>0){ CNOhits->Fill(hit_range1); } } Output->SetBranchStatus("*", 1); //After running through all events, initialize all branches }