// This (very primitive) root macro decodes the information // in the L2 global branches of the root file output by d0trigsim. // It assumes the file name is root_L1L2L3global.root. Change it // below in the one obvious place if you have a different filename. // // It reads the information in the branches L2gblHead and L2gblEM, // and figures out which EMobjects from the list belong to which scripts. // The output is five histograms for each script(macro assumes 14 scripts). // The best thing to do is compile it and use the .so file from then on. // It is much faster that way. // To compile and run in one step: // .x l2gblEM_analyze.C++ // After that, you will see a file l2gblem_analyze.so in that directory. // To use it without recompiling, type: // .L l2gblEM_analyze.so // which loads it, and then: // l2gblEM_analyze() which executes it. // // #include #include #include #include #include #include using namespace std; #include void l2gblEM_analyze() { //open the file TFile *myfile = new TFile("root_L1L2L3global.root","READ"); //make the histograms for each script TH1F *hist0 = new TH1F("EM pt-script 0","EM pt-script 0",100,0,100); TH1F *hist0a = new TH1F("EM ieta-script 0","EM ieta-script 0",40,0,39); TH1F *hist0b = new TH1F("EM iphi-script 0","EM iphi-script 0",32,0,31); TH1F *hist0c = new TH1F("EM isolation-script 0","EM isolation-script 0",60,0,1.5); TH1F *hist0d = new TH1F("EM emFraction-script 0","EM emFraction-script 0",60,0,1.5); TH1F *hist1 = new TH1F("EM pt-script 1","EM pt-script 1",100,0,100); TH1F *hist1a = new TH1F("EM ieta-script 1","EM ieta-script 1",40,0,39); TH1F *hist1b = new TH1F("EM iphi-script 1","EM iphi-script 1",32,0,31); TH1F *hist1c = new TH1F("EM isolation-script 1","EM isolation-script 1",60,0,1.5); TH1F *hist1d = new TH1F("EM emFraction-script 1","EM emFraction-script 1",60,0,1.5); TH1F *hist2 = new TH1F("EM pt-script 2","EM pt-script 2",100,0,100); TH1F *hist2a = new TH1F("EM ieta-script 2","EM ieta-script 2",40,0,39); TH1F *hist2b = new TH1F("EM iphi-script 2","EM iphi-script 2",32,0,31); TH1F *hist2c = new TH1F("EM isolation-script 2","EM isolation-script 2",60,0,1.5); TH1F *hist2d = new TH1F("EM emFraction-script 2","EM emFraction-script 2",60,0,1.5); TH1F *hist3 = new TH1F("EM pt-script 3","EM pt-script 3",100,0,100); TH1F *hist3a = new TH1F("EM ieta-script 3","EM ieta-script 3",40,0,39); TH1F *hist3b = new TH1F("EM iphi-script 3","EM iphi-script 3",32,0,31); TH1F *hist3c = new TH1F("EM isolation-script 3","EM isolation-script 3",60,0,1.5); TH1F *hist3d = new TH1F("EM emFraction-script 3","EM emFraction-script 3",60,0,1.5); TH1F *hist4 = new TH1F("EM pt-script 4","EM pt-script 4",100,0,100); TH1F *hist4a = new TH1F("EM ieta-script 4","EM ieta-script 4",40,0,39); TH1F *hist4b = new TH1F("EM iphi-script 4","EM iphi-script 4",32,0,31); TH1F *hist4c = new TH1F("EM isolation-script 4","EM isolation-script 4",60,0,1.5); TH1F *hist4d = new TH1F("EM emFraction-script 4","EM emFraction-script 4",60,0,1.5); TH1F *hist5 = new TH1F("EM pt-script 5","EM pt-script 5",100,0,100); TH1F *hist5a = new TH1F("EM ieta-script 5","EM ieta-script 5",40,0,39); TH1F *hist5b = new TH1F("EM iphi-script 5","EM iphi-script 5",32,0,31); TH1F *hist5c = new TH1F("EM isolation-script 5","EM isolation-script 5",60,0,1.5); TH1F *hist5d = new TH1F("EM emFraction-script 5","EM emFraction-script 5",60,0,1.5); TH1F *hist6 = new TH1F("EM pt-script 6","EM pt-script 6",100,0,100); TH1F *hist6a = new TH1F("EM ieta-script 6","EM ieta-script 6",40,0,39); TH1F *hist6b = new TH1F("EM iphi-script 6","EM iphi-script 6",32,0,31); TH1F *hist6c = new TH1F("EM isolation-script 6","EM isolation-script 6",60,0,1.5); TH1F *hist6d = new TH1F("EM emFraction-script 6","EM emFraction-script 6",60,0,1.5); TH1F *hist7 = new TH1F("EM pt-script 7","EM pt-script 7",100,0,100); TH1F *hist7a = new TH1F("EM ieta-script 7","EM ieta-script 7",40,0,39); TH1F *hist7b = new TH1F("EM iphi-script 7","EM iphi-script 7",32,0,31); TH1F *hist7c = new TH1F("EM isolation-script 7","EM isolation-script 7",60,0,1.5); TH1F *hist7d = new TH1F("EM emFraction-script 7","EM emFraction-script 7",60,0,1.5); TH1F *hist8 = new TH1F("EM pt-script 8","EM pt-script 8",100,0,100); TH1F *hist8a = new TH1F("EM ieta-script 8","EM ieta-script 8",40,0,39); TH1F *hist8b = new TH1F("EM iphi-script 8","EM iphi-script 8",32,0,31); TH1F *hist8c = new TH1F("EM isolation-script 8","EM isolation-script 8",60,0,1.5); TH1F *hist8d = new TH1F("EM emFraction-script 8","EM emFraction-script 8",60,0,1.5); TH1F *hist9 = new TH1F("EM pt-script 9","EM pt-script 9",100,0,100); TH1F *hist9a = new TH1F("EM ieta-script 9","EM ieta-script 9",40,0,39); TH1F *hist9b = new TH1F("EM iphi-script 9","EM iphi-script 9",32,0,31); TH1F *hist9c = new TH1F("EM isolation-script 9","EM isolation-script 9",60,0,1.5); TH1F *hist9d = new TH1F("EM emFraction-script 9","EM emFraction-script 9",60,0,1.5); TH1F *hist10 = new TH1F("EM pt-script 10","EM pt-script 10",100,0,100); TH1F *hist10a = new TH1F("EM ieta-script 10","EM ieta-script 10",40,0,39); TH1F *hist10b = new TH1F("EM iphi-script 10","EM iphi-script 10",32,0,31); TH1F *hist10c = new TH1F("EM isolation-script 10","EM isolation-script 10",60,0,1.5); TH1F *hist10d = new TH1F("EM emFraction-script 10","EM emFraction-script 10",60,0,1.5); TH1F *hist11 = new TH1F("EM pt-script 11","EM pt-script 11",100,0,100); TH1F *hist11a = new TH1F("EM ieta-script 11","EM ieta-script 11",40,0,39); TH1F *hist11b = new TH1F("EM iphi-script 11","EM iphi-script 11",32,0,31); TH1F *hist11c = new TH1F("EM isolation-script 11","EM isolation-script 11",60,0,1.5); TH1F *hist11d = new TH1F("EM emFraction-script 11","EM emFraction-script 11",60,0,1.5); TH1F *hist12 = new TH1F("EM pt-script 12","EM pt-script 12",100,0,100); TH1F *hist12a = new TH1F("EM ieta-script 12","EM ieta-script 12",40,0,39); TH1F *hist12b = new TH1F("EM iphi-script 12","EM iphi-script 12",32,0,31); TH1F *hist12c = new TH1F("EM isolation-script 12","EM isolation-script 12",60,0,1.5); TH1F *hist12d = new TH1F("EM emFraction-script 12","EM emFraction-script 12",60,0,1.5); TH1F *hist13 = new TH1F("EM pt-script 13","EM pt-script 13",100,0,100); TH1F *hist13a = new TH1F("EM ieta-script 13","EM ieta-script 13",40,0,39); TH1F *hist13b = new TH1F("EM iphi-script 13","EM iphi-script 13",32,0,31); TH1F *hist13c = new TH1F("EM isolation-script 13","EM isolation-script 13",60,0,1.5); TH1F *hist13d = new TH1F("EM emFraction-script 13","EM emFraction-script 13",60,0,1.5); //leaf names char *objleaf; char *scrleaf; //hist names TH1F *h; TH1F *ha; TH1F *hb; TH1F *hc; TH1 *hd; //branch names TBranch *L2gblHead; TBranch *L2gblEM; //needed for compiling TTree *Global = (TTree *)myfile->Get("Global"); //how many entries? float NumEntries = Global->GetEntries(); cout<<"num entries = "<< NumEntries<GetEntry(i); //set branch names L2gblHead = Global->GetBranch("L2gblHead"); L2gblEM = Global->GetBranch("L2gblEM"); //loop over the 14 scripts //set leaf, hist names for (int iscr = 0;iscr<14;iscr++) { switch(iscr) { case 0: objleaf = "nObj0"; scrleaf = "ScriptObj0"; h = hist0; ha = hist0a; hb = hist0b; hc = hist0c; hd = hist0d; break; case 1: objleaf = "nObj1"; scrleaf = "ScriptObj1"; h = hist1; ha = hist1a; hb = hist1b; hc = hist1c; hd = hist1d; break; case 2: objleaf = "nObj2"; scrleaf = "ScriptObj2"; h = hist2; ha = hist2a; hb = hist2b; hc = hist2c; hd = hist2d; break; case 3: objleaf = "nObj3"; scrleaf = "ScriptObj3"; h = hist3; ha = hist3a; hb = hist3b; hc = hist3c; hd = hist3d; break; case 4: objleaf = "nObj4"; scrleaf = "ScriptObj4"; h = hist4; ha = hist4a; hb = hist4b; hc = hist4c; hd = hist4d; break; case 5: objleaf = "nObj5"; scrleaf = "ScriptObj5"; h = hist5; ha = hist5a; hb = hist5b; hc = hist5c; hd = hist5d; break; case 6: objleaf = "nObj6"; scrleaf = "ScriptObj6"; h = hist6; ha = hist6a; hb = hist6b; hc = hist6c; hd = hist6d; break; case 7: objleaf = "nObj7"; scrleaf = "ScriptObj7"; h = hist7; ha = hist7a; hb = hist7b; hc = hist7c; hd = hist7d; break; case 8: objleaf = "nObj8"; scrleaf = "ScriptObj8"; h = hist8; ha = hist8a; hb = hist8b; hc = hist8c; hd = hist8d; break; case 9: objleaf = "nObj9"; scrleaf = "ScriptObj9"; h = hist9; ha = hist9a; hb = hist9b; hc = hist9c; hd = hist9d; break; case 10: objleaf = "nObj10"; scrleaf = "ScriptObj10"; h = hist10; ha = hist10a; hb = hist10b; hc = hist10c; hd = hist10d; break; case 11: objleaf = "nObj11"; scrleaf = "ScriptObj11"; h = hist11; ha = hist11a; hb = hist11b; hc = hist11c; hd = hist11d; break; case 12: objleaf = "nObj12"; scrleaf = "ScriptObj12"; h = hist12; ha = hist12a; hb = hist12b; hc = hist12c; hd = hist12d; break; case 13: objleaf = "nObj13"; scrleaf = "ScriptObj13"; h = hist13; ha = hist13a; hb = hist13b; hc = hist13c; hd = hist13d; break; } int nemobj = (L2gblEM->GetLeaf("nEMObjects"))->GetValue(); // Loop over all emobjects in the event for(int iemobj=0; iemobj < nemobj; iemobj++) { int emObj = (L2gblEM->GetLeaf("objID"))->GetValue(iemobj); // Loop over object IDs in desired script, comparing to the // object ID for the iemobj EMOBJ. int nscrobj = (L2gblHead->GetLeaf(objleaf))->GetValue(); for(int iscrobj=0; iscrobj < nscrobj; iscrobj++) { // get scriptObj value int scrObj = (L2gblHead->GetLeaf(scrleaf))->GetValue(iscrobj); if( scrObj==emObj ) { // found matching object h->Fill((L2gblEM->GetLeaf("pt"))->GetValue(iemobj)); ha->Fill((L2gblEM->GetLeaf("ieta"))->GetValue(iemobj)); hb->Fill((L2gblEM->GetLeaf("iphi"))->GetValue(iemobj)); hc->Fill((L2gblEM->GetLeaf("isolation"))->GetValue(iemobj)); hd->Fill((L2gblEM->GetLeaf("emFraction"))->GetValue(iemobj)); } } } } } }//end l2gblEM_analyze()