//////////////////////////////////////////////////////////// /// \brief Loads all the textures listed in the JSON file /// "AssetPaths.json" /// /// \param debug (optional) Prints how many textures are in /// the map before and after load to console /// //////////////////////////////////////////////////////////// void goo::TextureManager::loadTextures(bool debug) { if (debug) { std::cout << "Textures before load : " << m_textureMap.size() << std::endl; } //Store json file in JSONValue m_root readJSONFile("AssetPaths.json"); //check how many elements are under the 'Textures' heading int elements = m_root["Assets"]["Textures"].size(); //Allocate space on the heap for 2 string arrays of size 'elements' m_firstValue = new std::string[elements]; m_secondValue = new std::string[elements]; //Loop through elements to store their values for (int i = 0; i < elements; i++) { m_firstValue[i] = m_root["Assets"]["Textures"][i]["ID"].asString().c_str(); m_secondValue[i] = m_root["Assets"]["Textures"][i]["Path"].asString().c_str(); load(m_firstValue[i], m_secondValue[i]); } if (debug) { std::cout << "Textures before load : " << m_textureMap.size() << std::endl; } }
int main(int argc, char** argv) { //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> readJSONFile::usage: " << argv[0] << " inFileName" << std::endl ; return 1; } std::string inFileName = argv[1]; std::map<int, std::vector<std::pair<int, int> > > jsonMap = readJSONFile(inFileName); for(std::map<int, std::vector<std::pair<int, int> > >::const_iterator mapIt = jsonMap.begin(); mapIt != jsonMap.end(); ++mapIt) { std::cout << "run: " << mapIt -> first; for(std::vector<std::pair<int, int> >::const_iterator vecIt = (mapIt->second).begin(); vecIt != (mapIt->second).end(); ++vecIt) { std::cout << "[" << vecIt -> first << "," << vecIt->second << "] "; } std::cout << std::endl; } return 0; }
///////////////////////////// // LOOP OVER THE TREE LIST // ///////////////////////////// int looplist(TString nameChain, TString nameChain_To, vector<TString> treeList, vector<TString> listTrees_To, int n1, int n2, int nEntries, int nEntriesTo, TString dirIn, TString dirOut, TString usr_hlt, ofstream& outcheck, int iJson, bool GetTrigOnly, bool debug, bool b_mapcheck) { if(debug) cout << "- define JSON" << endl; // 1- JSON FILE READER // // 2010B : -> 2010B // May10 : 160404-163869 -> May10 // PRV4 : 165071-168437 -> Prompt // Aug05 (PRV5) : 170053-172619 -> Aug05 // Oct03 (PRV6) : 172620-175770 -> Prompt // 2011B-PRV1 : 175832-180296 -> Prompt // string jsonDir = "/data_CMS/cms/ndaci/ndaci_2011A/JSON/" ; const int nJson = 5; string jsonFile[nJson]; // 2010B, May10, Aug05, Prompt MAPJson jsonMap[nJson] ; // jsonFile[0] = jsonDir + "goodrunlist_json.txt" ; jsonFile[1] = jsonDir + "Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt" ; jsonFile[2] = jsonDir + "Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON_v3.txt" ; jsonFile[3] = jsonDir + "Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt" ; jsonFile[4] = jsonDir + "Cert_160404-180252_7TeV_ReRecoNov08_Collisions11_JSON.txt" ; // for(int i=0 ; i<nJson ; i++) jsonMap[i] = readJSONFile(jsonFile[i]); // // 2- INPUT TrigOnly TREE // if(debug) cout << "- get TrigOnly trees --> chain" << endl; TChain * trigOnlyChain = new TChain(nameChain_To); MAPTrigOnly mapTo; if( GetTrigOnly ) { for(u_int iTo=0 ; iTo<listTrees_To.size() ; iTo++) trigOnlyChain->Add(listTrees_To[iTo]); if(debug) cout << "--> map TrigOnly entries --> MAPTrigOnly" << endl; mapTo = MapTrigOnlyEntries(trigOnlyChain, nEntriesTo, outcheck, jsonMap, iJson, debug, b_mapcheck); } // Loop over data trees if(debug) cout << "- loop over trees [" << n1 << ";" << n2 << "]" << endl; for(int iFile = n1 ; iFile < n2 ; iFile++) { if(debug) cout << "--> tree #" << iFile << endl; process(trigOnlyChain, jsonMap, mapTo, nameChain, treeList[iFile], iFile, nEntries, dirIn, dirOut, usr_hlt, iJson, GetTrigOnly, debug); } /* int process(TChain *trigOnlyChain, MAPJson *jsonMap, MAPTrigOnly mapTo, TString nameChain, TString file, int iFile, int nEntries, TString dirIn, TString dirOut, TString usr_vbtf, double cut_et, bool dojson, TString RunPhase, bool debug) */ return 1; }
int main(int argc, char** argv) { //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> WZAnalysis::usage: " << argv[0] << " configFileName" << std::endl ; return 1; } std::string fileName(argv[1]); boost::shared_ptr<edm::ParameterSet> parameterSet = edm::readConfig(fileName); // "Input" edm::ParameterSet Input = parameterSet -> getParameter<edm::ParameterSet>("Input"); std::string inputFileList = Input.getParameter<std::string>("inputFileList"); std::string jsonFileName = Input.getParameter<std::string>("jsonFileName"); // "Output" edm::ParameterSet Output = parameterSet -> getParameter<edm::ParameterSet>("Output"); std::string outputRootFilePath = Output.getParameter<std::string>("outputRootFilePath"); std::string outputRootFileName = Output.getParameter<std::string>("outputRootFileName"); std::string outputRootFullFileName = outputRootFilePath + "/" + outputRootFileName + ".root"; // "Options" edm::ParameterSet Options = parameterSet -> getParameter<edm::ParameterSet>("Options"); int entryMIN = Options.getParameter<int>("entryMIN"); int entryMAX = Options.getParameter<int>("entryMAX"); int entryMODULO = Options.getParameter<int>("entryMODULO"); int jsonFlag = Options.getParameter<int>("jsonFlag"); int verbosity = Options.getParameter<int>("verbosity"); // Get total number of events std::cout << ">>> WZAnalysis::Get number of events" << std::endl; std::map<int, int> beginEvents = GetTotalEvents("AllPassFilterBegin/passedEvents", inputFileList.c_str()); std::map<int, int> goodVertexEvents = GetTotalEvents("AllPassFilterGoodVertexFilter/passedEvents", inputFileList.c_str()); std::map<int, int> noScrapingEvents = GetTotalEvents("AllPassFilterNoScrapingFilter/passedEvents", inputFileList.c_str()); std::map<int, int> HBHENoiseEvents = GetTotalEvents("AllPassFilterHBHENoiseFilter/passedEvents", inputFileList.c_str()); std::map<int, int> electronEvents = GetTotalEvents("AllPassFilterElectronFilter/passedEvents", inputFileList.c_str()); // Get run/LS map from JSON file std::cout << ">>> WZPreselection::Get run/LS map from JSON file" << std::endl; std::map<int, std::vector<std::pair<int, int> > > jsonMap; jsonMap = readJSONFile(jsonFileName); // define HLT paths std::vector<std::pair<std::string,std::pair<int,int> > > WHLTPathNames; std::pair<int,int> WRunRanges1(160404,161176); std::pair<std::string,std::pair<int,int> > WHLTPathName1("HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v1",WRunRanges1); std::pair<int,int> WRunRanges2(161216,163261); std::pair<std::string,std::pair<int,int> > WHLTPathName2("HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v2",WRunRanges2); std::pair<int,int> WRunRanges3(163269,163869); std::pair<std::string,std::pair<int,int> > WHLTPathName3("HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v3",WRunRanges3); std::pair<int,int> WRunRanges4(165088,165633); std::pair<std::string,std::pair<int,int> > WHLTPathName4("HLT_Ele32_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v3",WRunRanges4); std::pair<int,int> WRunRanges5(165970,166967); std::pair<std::string,std::pair<int,int> > WHLTPathName5("HLT_Ele25_WP80_PFMT40_v1",WRunRanges5); std::pair<int,int> WRunRanges6(167039,167913); std::pair<std::string,std::pair<int,int> > WHLTPathName6("HLT_Ele27_WP80_PFMT50_v1",WRunRanges6); std::pair<int,int> WRunRanges7(170249,173198); std::pair<std::string,std::pair<int,int> > WHLTPathName7("HLT_Ele32_WP70_PFMT50_v3",WRunRanges7); std::pair<int,int> WRunRanges8(173236,999999); std::pair<std::string,std::pair<int,int> > WHLTPathName8("HLT_Ele32_WP70_PFMT50_v4",WRunRanges8); WHLTPathNames.push_back(WHLTPathName1); WHLTPathNames.push_back(WHLTPathName2); WHLTPathNames.push_back(WHLTPathName3); WHLTPathNames.push_back(WHLTPathName4); WHLTPathNames.push_back(WHLTPathName5); WHLTPathNames.push_back(WHLTPathName6); WHLTPathNames.push_back(WHLTPathName7); WHLTPathNames.push_back(WHLTPathName8); std::vector<std::pair<std::string,std::pair<int,int> > > ZHLTPathNames; std::pair<int,int> ZRunRanges1(160404,161176); std::pair<std::string,std::pair<int,int> > ZHLTPathName1("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v1",ZRunRanges1); std::pair<int,int> ZRunRanges2(161216,163261); std::pair<std::string,std::pair<int,int> > ZHLTPathName2("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v2",ZRunRanges2); std::pair<int,int> ZRunRanges3(163269,163869); std::pair<std::string,std::pair<int,int> > ZHLTPathName3("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v3",ZRunRanges3); std::pair<int,int> ZRunRanges4(165088,165633); std::pair<std::string,std::pair<int,int> > ZHLTPathName4("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v4",ZRunRanges4); std::pair<int,int> ZRunRanges5(165970,166967); std::pair<std::string,std::pair<int,int> > ZHLTPathName5("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v5",ZRunRanges5); std::pair<int,int> ZRunRanges6(167039,167913); std::pair<std::string,std::pair<int,int> > ZHLTPathName6("HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v6",ZRunRanges6); std::pair<int,int> ZRunRanges7(170249,170759); std::pair<std::string,std::pair<int,int> > ZHLTPathName7("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v6",ZRunRanges7); std::pair<int,int> ZRunRanges8(170826,173198); std::pair<std::string,std::pair<int,int> > ZHLTPathName8("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v7",ZRunRanges8); std::pair<int,int> ZRunRanges9(173236,999999); std::pair<std::string,std::pair<int,int> > ZHLTPathName9("HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_v8",ZRunRanges9); ZHLTPathNames.push_back(ZHLTPathName1); ZHLTPathNames.push_back(ZHLTPathName2); ZHLTPathNames.push_back(ZHLTPathName3); ZHLTPathNames.push_back(ZHLTPathName4); ZHLTPathNames.push_back(ZHLTPathName5); ZHLTPathNames.push_back(ZHLTPathName6); ZHLTPathNames.push_back(ZHLTPathName7); ZHLTPathNames.push_back(ZHLTPathName8); ZHLTPathNames.push_back(ZHLTPathName9); // Open tree std::cout << ">>> WZAnalysis::Open old tree" << std::endl; std::string treeName = "simpleNtuple/SimpleNtuple"; TChain* chain = new TChain(treeName.c_str()); if(!FillChain(*chain, inputFileList.c_str())) return 1; treeReader reader((TTree*)(chain), false); // Open output root file outputRootFileName += ".root"; // define histograms std::cout << ">>> WZAnalysis::Define histograms" << std::endl; int nStep = 10; TH1F* events = new TH1F("events", "events", nStep, 0., 1.*nStep); std::map<int, int> stepEvents; std::map<int, std::string> stepNames; // define the reduced ntuple WZAnalysisVariablesSingleXtal vars; InitializeWZAnalysisTree(vars,outputRootFullFileName); //********************** // STEP 1 - Begin events int step = 1; SetStepNames(stepNames, "All events", step, verbosity); stepEvents[step] = beginEvents[1]; //**************************** // STEP 2 - Good Vertex events step = 2; SetStepNames(stepNames, "Good vertex", step, verbosity); stepEvents[step] = goodVertexEvents[1]; //********************* // STEP 3 - No Scraping step = 3; SetStepNames(stepNames, "No scraping", step, verbosity); stepEvents[step] = noScrapingEvents[1]; //********************* // STEP 4 - HBHE Noise step = 4; SetStepNames(stepNames, "HBHE Noise", step, verbosity); stepEvents[step] = HBHENoiseEvents[1]; //****************** // STEP 5 - Electron step = 5; SetStepNames(stepNames, "Electron", step, verbosity); stepEvents[step] = electronEvents[1]; //********************* // LOOP OVER THE EVENTS std::cout << ">>>>> WZAnalysis::Read " << chain -> GetEntries() << " entries" << std::endl; for(int entry = entryMIN ; entry < chain -> GetEntries() ; ++entry) { reader.GetEntry(entry); if((entry%entryMODULO) == 0) std::cout << ">>>>> WZAnalysis::GetEntry " << entry << std::endl; if(entry == entryMAX) break; // clear variables ClearWZAnalysisVariables(vars); // event variables vars.runId = reader.GetInt("runId")->at(0); vars.lumiId = reader.GetInt("lumiId")->at(0); //************************** // STEP 6 - run/LS selection step = 6; SetStepNames(stepNames, "run/LS", step, verbosity); bool skipEvent = false; if(AcceptEventByRunAndLumiSection(vars.runId,vars.lumiId,jsonMap) == false) skipEvent = true; if( (jsonFlag == 1) && (skipEvent == true) ) continue; stepEvents[step] += 1; //*********************** // STEP 7 - HLT selection step += 1; SetStepNames(stepNames, "HLT", step, verbosity); skipEvent = true; bool isWHLT = false; bool isZHLT = false; if( verbosity == 1 ) { std::vector<std::string> HLT_names = *(reader.GetString("HLT_Names")); for(unsigned int HLTIt = 0; HLTIt < HLT_names.size(); ++HLTIt) std::cout << "HLT bit " << HLTIt << ": " << HLT_names.at(HLTIt) << std::endl; } // W triggers for(unsigned int HLTIt = 0; HLTIt < WHLTPathNames.size(); ++HLTIt) { if( AcceptHLTPath(reader, WHLTPathNames.at(HLTIt)) == true ) skipEvent = false; isWHLT = true; } // Z triggers for(unsigned int HLTIt = 0; HLTIt < ZHLTPathNames.size(); ++HLTIt) { if( AcceptHLTPath(reader, ZHLTPathNames.at(HLTIt)) == true ) skipEvent = false; isZHLT = true; } if( skipEvent == true ) continue; stepEvents[step] += 1; //************************** // STEP 8 - cut on electrons step += 1; SetStepNames(stepNames, "1/2 ele", step, verbosity); int nTightEle = 0; int nMediumEle = 0; int nLooseEle = 0; std::map<float,int> eleIts; // loop on electrons for(unsigned int eleIt = 0; eleIt < (reader.Get4V("electrons")->size()); ++eleIt) { ROOT::Math::XYZTVector ele = reader.Get4V("electrons")->at(eleIt); float pt = ele.pt(); float eta = ele.eta(); float tkIso = reader.GetFloat("electrons_tkIso03")->at(eleIt); float emIso = reader.GetFloat("electrons_emIso03")->at(eleIt); float hadIso = reader.GetFloat("electrons_hadIso03_1")->at(eleIt) + reader.GetFloat("electrons_hadIso03_2")->at(eleIt); float combIso = tkIso + emIso + hadIso; int isEB = reader.GetInt("electrons_isEB")->at(eleIt); float sigmaIetaIeta = reader.GetFloat("electrons_sigmaIetaIeta")->at(eleIt); float DetaIn = reader.GetFloat("electrons_deltaEtaIn")->at(eleIt); float DphiIn = reader.GetFloat("electrons_deltaPhiIn")->at(eleIt); float HOverE = reader.GetFloat("electrons_hOverE")->at(eleIt); int mishits = reader.GetInt("electrons_mishits")->at(eleIt); int nAmbiguousGsfTracks = reader.GetInt("electrons_nAmbiguousGsfTracks")->at(eleIt); float dist = reader.GetFloat("electrons_dist")->at(eleIt); float dcot = reader.GetFloat("electrons_dcot")->at(eleIt); // tight electrons bool isTightElectron = false; if( (pt > 20.) && (fabs(eta) < 2.5) && // EleID WP80 - 2010 ( ( (isEB == 1) && (combIso/pt < 0.070) ) || ( (isEB == 0) && (combIso/pt < 0.060) ) ) && ( ( (isEB == 1) && (sigmaIetaIeta < 0.010) ) || ( (isEB == 0) && (sigmaIetaIeta < 0.030) ) ) && ( ( (isEB == 1) && (fabs(DphiIn) < 0.060) ) || ( (isEB == 0) && (fabs(DphiIn) < 0.030) ) ) && ( ( (isEB == 1) && (fabs(DetaIn) < 0.004) ) || ( (isEB == 0) && (fabs(DetaIn) < 0.007) ) ) && //( ( (isEB == 1) && (HOverE < 0.040) ) || ( (isEB == 0) && (HOverE < 0.025) ) ) && ( mishits == 0 ) && ( nAmbiguousGsfTracks == 0 ) && ( ( fabs(dist) > 0.02 ) || ( fabs(dcot) > 0.02 ) ) ) { isTightElectron = true; ++nTightEle; eleIts[1./pt] = eleIt; } // semi-tight electrons if( isTightElectron == true ) continue; // bool isMediumElectron = false; if( (pt > 12.) && (fabs(eta) < 2.5) && // EleID WP80 - 2010 ( ( (isEB == 1) && (combIso/pt < 0.070) ) || ( (isEB == 0) && (combIso/pt < 0.060) ) ) && ( ( (isEB == 1) && (sigmaIetaIeta < 0.010) ) || ( (isEB == 0) && (sigmaIetaIeta < 0.030) ) ) && ( ( (isEB == 1) && (fabs(DphiIn) < 0.060) ) || ( (isEB == 0) && (fabs(DphiIn) < 0.030) ) ) && ( ( (isEB == 1) && (fabs(DetaIn) < 0.004) ) || ( (isEB == 0) && (fabs(DetaIn) < 0.007) ) ) && //( ( (isEB == 1) && (HOverE < 0.040) ) || ( (isEB == 0) && (HOverE < 0.025) ) ) && ( mishits == 0 ) && ( nAmbiguousGsfTracks == 0 ) && ( ( fabs(dist) > 0.02 ) || ( fabs(dcot) > 0.02 ) ) ) { // isMediumElectron = true; ++nMediumEle; eleIts[1./pt] = eleIt; } // loose electrons if( isTightElectron == true ) continue; if( (pt > 10.) && (fabs(eta) < 2.5) && // EleID WP95 - 2010 ( ( (isEB == 1) && (combIso/pt < 0.150) ) || ( (isEB == 0) && (combIso/pt < 0.100) ) ) && ( ( (isEB == 1) && (sigmaIetaIeta < 0.010) ) || ( (isEB == 0) && (sigmaIetaIeta < 0.030) ) ) && ( ( (isEB == 1) && (fabs(DphiIn) < 0.800) ) || ( (isEB == 0) && (fabs(DphiIn) < 0.700) ) ) && ( ( (isEB == 1) && (fabs(DetaIn) < 0.007) ) || ( (isEB == 0) && (fabs(DetaIn) < 0.010) ) ) && ( ( (isEB == 1) && (HOverE < 0.150) ) || ( (isEB == 0) && (HOverE < 0.070) ) ) ) { ++nLooseEle; } } // loop on electrons int nLooseMu = 0; // loop on muons for(unsigned int muIt = 0; muIt < (reader.Get4V("muons")->size()); ++muIt) { ROOT::Math::XYZTVector mu = reader.Get4V("muons")->at(muIt); float pt = mu.pt(); float eta = mu.eta(); float tkIso = reader.GetFloat("muons_tkIso03")->at(muIt); float emIso = reader.GetFloat("muons_emIso03")->at(muIt); float hadIso = reader.GetFloat("muons_hadIso03")->at(muIt); float combIso = tkIso + emIso + hadIso; int global = reader.GetInt("muons_global")->at(muIt); if( (pt > 10.) && (fabs(eta) < 2.5) && (combIso/pt < 0.20) && (global == 1) ) { ++nLooseMu; } } // cuts if( verbosity == 1 ) std::cout << " nTightEle = " << nTightEle << " nMediumEle = " << nMediumEle << " nLooseEle = " << nLooseEle << " nLooseMu = " << nLooseMu << std::endl; if( nTightEle < 1 ) continue; if( nTightEle > 2 ) continue; if( nMediumEle > 1 ) continue; if( nLooseEle > 0 ) continue; if( nLooseMu > 0 ) continue; stepEvents[step] += 1; // set electron variables std::map<float,int>::const_iterator mapIt = eleIts.begin(); //PhotonFix::initialise("4_2"); if( (nTightEle == 1) && (nMediumEle == 0) ) { SetElectron1Variables(vars,reader,mapIt->second); //PhotonFix Correction1 (vars.ele1_scE,vars.ele1_scEta,vars.ele1_scPhi,vars.ele1_e3x3/vars.ele1_scE); //vars.ele1_scLocalContCorr_DK = Correction1.fixedEnergy()/vars.ele1_scE; } mapIt = eleIts.begin(); if( (nTightEle == 2) || (nTightEle == 1 && nMediumEle == 1) ) { SetElectron1Variables(vars,reader,mapIt->second); //PhotonFix Correction1 (vars.ele1_scE,vars.ele1_scEta,vars.ele1_scPhi,vars.ele1_e3x3/vars.ele1_scE); //vars.ele1_scLocalContCorr_DK = Correction1.fixedEnergy()/vars.ele1_scE; ++mapIt; SetElectron2Variables(vars,reader,mapIt->second); //PhotonFix Correction2 (vars.ele2_scE,vars.ele2_scEta,vars.ele2_scPhi,vars.ele2_e3x3/vars.ele2_scE); //vars.ele2_scLocalContCorr_DK = Correction2.fixedEnergy()/vars.ele2_scE; } // set met variables SetMetVariables(vars,reader); // set di-electron variables if( (nTightEle == 2) || (nTightEle == 1 && nMediumEle == 1) ) { SetDiElectronVariables(vars,reader); } //*********************** // STEP 9 - W selection step += 1; SetStepNames(stepNames, "W selection", step, verbosity); if( (nTightEle == 1) && (nMediumEle == 0) ) { if( isWHLT == false ) continue; if( vars.ele1_pt < 30. ) continue; // EleID WP70 - 2010 if( ( vars.ele1_isEB == 1 ) && ( (vars.ele1_tkIso+vars.ele1_emIso+vars.ele1_hadIso)/vars.ele1_pt > 0.04 ) ) continue; if( ( vars.ele1_isEB == 1 ) && ( fabs(vars.ele1_DphiIn) > 0.030 ) ) continue; if( ( vars.ele1_isEB == 1 ) && ( fabs(vars.ele1_DetaIn) > 0.004 ) ) continue; if( ( vars.ele1_isEB == 1 ) && ( vars.ele1_HOverE > 0.025 ) ) continue; if( ( vars.ele1_isEB == 0 ) && ( (vars.ele1_tkIso+vars.ele1_emIso+vars.ele1_hadIso)/vars.ele1_pt > 0.03 ) ) continue; if( ( vars.ele1_isEB == 0 ) && ( fabs(vars.ele1_DphiIn) > 0.020 ) ) continue; if( ( vars.ele1_isEB == 0 ) && ( fabs(vars.ele1_DetaIn) > 0.005 ) ) continue; if( ( vars.ele1_isEB == 0 ) && ( vars.ele1_HOverE > 0.025 ) ) continue; if( vars.met_et < 25.00 ) continue; if( vars.ele1Met_mt < 50.00 ) continue; if( vars.ele1Met_Dphi < 1.57 ) continue; stepEvents[step] += 1; vars.isW = 1; vars.isZ = 0; // fill the reduced tree FillWZAnalysisTree(vars); } //*********************** // STEP 10 - Z selection step += 1; SetStepNames(stepNames, "Z selection", step, verbosity); if( (nTightEle == 2) || (nTightEle == 1 && nMediumEle == 1) ) { if( isZHLT == false ) continue; if( vars.met_et > 40. ) continue; if( vars.ele1ele2_m < 70. ) continue; if( vars.ele1ele2_m > 110. ) continue; if( (vars.ele1_charge * vars.ele2_charge) != -1. ) continue; stepEvents[step] += 1; vars.isW = 0; vars.isZ = 1; // fill the reduced tree FillWZAnalysisTree(vars); } } // loop over the events // save the reduced tree DeleteWZAnalysisVariables(vars); // save the histograms TFile* outputRootFile = new TFile((outputRootFullFileName).c_str(), "UPDATE"); outputRootFile -> cd(); for(step = 1; step <= nStep; ++step) { events -> SetBinContent(step, stepEvents[step]); events -> GetXaxis() -> SetBinLabel(step, stepNames[step].c_str()); } events -> Write(); outputRootFile -> Close(); return 0; }
int main (int argc, char ** argv) { ///Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> FastCalibrator::usage: " << argv[0] << " configFileName" << std::endl ; return 1; } std::string configFileName = argv[1]; boost::shared_ptr<edm::ParameterSet> parameterSet = edm::readConfig(configFileName); edm::ParameterSet Options = parameterSet -> getParameter<edm::ParameterSet>("Options"); parameterSet.reset(); std::string inputList = "NULL"; if(Options.existsAs<std::string>("inputList")) inputList = Options.getParameter<std::string>("inputList"); else { std::cout << " Exit from code, no input list found" << std::endl; std::exit(EXIT_FAILURE); } std::string inputFileDeadXtal = "NULL"; if(Options.existsAs<std::string>("inputFileDeadXtal")) inputFileDeadXtal = Options.getParameter<std::string>("inputFileDeadXtal"); else { std::cout << " No input File Dead Xtal found! " << std::endl; } std::string inputTree = "NULL"; if(Options.existsAs<std::string>("inputTree")) inputTree = Options.getParameter<std::string>("inputTree"); else { std::cout << " Exit from code, no input tree found" << std::endl; std::exit(EXIT_FAILURE); } std::string jsonFileName = "NULL"; if(Options.existsAs<std::string>("jsonFileName")) jsonFileName = Options.getParameter<std::string>("jsonFileName"); else { std::cout << " Exit from code, no jsonFile found" << std::endl; std::exit(EXIT_FAILURE); } std::map<int, std::vector<std::pair<int, int> > > jsonMap; jsonMap = readJSONFile(jsonFileName); std::string miscalibMap = "NULL"; if(Options.existsAs<std::string>("miscalibMap")) miscalibMap = Options.getParameter<std::string>("miscalibMap"); else { std::cout << " no miscalib map found" << std::endl; } bool isMiscalib = false; if(Options.existsAs<bool>("isMiscalib")) isMiscalib = Options.getParameter<bool>("isMiscalib"); bool isSaveEPDistribution = false; if(Options.existsAs<bool>("isSaveEPDistribution")) isSaveEPDistribution = Options.getParameter<bool>("isSaveEPDistribution"); bool isMCTruth = false; if(Options.existsAs<bool>("isMCTruth")) isMCTruth = Options.getParameter<bool>("isMCTruth"); bool isEPselection = false; if(Options.existsAs<bool>("isEPselection")) isEPselection = Options.getParameter<bool>("isEPselection"); bool isPtCut = false; if(Options.existsAs<bool>("isPtCut")) isPtCut = Options.getParameter<bool>("isPtCut"); double PtMin = 0.; if(Options.existsAs<double>("PtMin")) PtMin = Options.getParameter<double>("PtMin"); bool isfbrem = false; if(Options.existsAs<bool>("isfbrem")) isfbrem = Options.getParameter<bool>("isfbrem"); double fbremMax = 100.; if(Options.existsAs<double>("fbremMax")) fbremMax = Options.getParameter<double>("fbremMax"); bool isR9selection = false; if(Options.existsAs<bool>("isR9selection")) isR9selection = Options.getParameter<bool>("isR9selection"); double R9Min = -1.; if(Options.existsAs<double>("R9Min")) R9Min = Options.getParameter<double>("R9Min"); int miscalibMethod = 1; if(Options.existsAs<double>("miscalibMethod")) miscalibMethod = Options.getParameter<double>("miscalibMethod"); std::string inputMomentumScale = "NULL"; if(Options.existsAs<std::string>("inputMomentumScale")) inputMomentumScale = Options.getParameter<std::string>("inputMomentumScale"); std::string typeEB = "NULL"; if(Options.existsAs<std::string>("typeEB")) typeEB = Options.getParameter<std::string>("typeEB"); std::string typeEE = "NULL"; if(Options.existsAs<std::string>("typeEE")) typeEE = Options.getParameter<std::string>("typeEE"); int nRegionsEE = GetNRegionsEE(typeEE); std::string outputPath = "output/Oct22_Run2012ABC_Cal_Dic2012/"; if(Options.existsAs<std::string>("outputPath")) outputPath = Options.getParameter<std::string>("outputPath"); system(("mkdir -p " + outputPath).c_str()); std::string outputFile = "FastCalibrator_Oct22_Run2012ABC_Cal_Dic2012"; if(Options.existsAs<std::string>("outputFile")) outputFile = Options.getParameter<std::string>("outputFile"); int numberOfEvents = -1; if(Options.existsAs<int>("numberOfEvents")) numberOfEvents = Options.getParameter<int>("numberOfEvents"); int useZ = 1; if(Options.existsAs<int>("useZ")) useZ = Options.getParameter<int>("useZ"); int useW = 1; if(Options.existsAs<int>("useW")) useW = Options.getParameter<int>("useW"); int splitStat = 0; if(Options.existsAs<int>("splitStat")) splitStat = Options.getParameter<int>("splitStat"); int nLoops = 20; if(Options.existsAs<int>("nLoops")) nLoops = Options.getParameter<int>("nLoops"); bool isDeadTriggerTower = false; if(Options.existsAs<bool>("isDeadTriggerTower")) isDeadTriggerTower = Options.getParameter<bool>("isDeadTriggerTower"); /// Acquistion input ntuples TChain * tree = new TChain (inputTree.c_str()); FillChain(*tree, inputList); /// open calibration momentum graph TFile* f4 = new TFile((inputMomentumScale + "_" + typeEB + "_" + typeEE + ".root").c_str()); std::vector<TGraphErrors*> g_EoC_EE; for(int i = 0; i < nRegionsEE; ++i) { TString Name = Form("g_EoC_EE_%d", i); g_EoC_EE.push_back( (TGraphErrors*)(f4->Get(Name)) ); } ///Use the whole sample statistics if numberOfEvents < 0 if ( numberOfEvents < 0 ) numberOfEvents = tree->GetEntries(); /// run in normal mode: full statistics if ( splitStat == 0 ) { TString name ; TString name_tmp; if(isMiscalib == true && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_WZ_R9_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 1 && isR9selection == false && isEPselection == false && isfbrem == true && isPtCut == false ) name_tmp = Form ("%s_WZ_Fbrem_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == true ) name_tmp = Form ("%s_WZ_PT_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 1 && isR9selection == true && isEPselection == true && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_WZ_EP_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 1 && isEPselection == false && isR9selection == false && isPtCut == false && isfbrem == false ) name_tmp = Form ("%s_WZ_noEP_miscalib_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_WZ_R9_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 1 && isR9selection == false && isEPselection == false && isfbrem == true && isPtCut == false ) name_tmp = Form ("%s_WZ_Fbrem_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == true ) name_tmp = Form ("%s_WZ_PT_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 1 && isR9selection == true && isEPselection == true && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_WZ_EP_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 1 && isEPselection == false && isR9selection == false && isPtCut == false && isfbrem == false ) name_tmp = Form ("%s_WZ_noEP_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_W_R9_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 0 && isR9selection == false && isEPselection == false && isfbrem == true && isPtCut == false ) name_tmp = Form ("%s_W_Fbrem_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == true ) name_tmp = Form ("%s_W_PT_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 0 && isR9selection == true && isEPselection == true && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_W_EP_miscalib_EE", outputFile.c_str()); else if(isMiscalib == true && useZ == 0 && isEPselection == false && isR9selection == false && isPtCut == false && isfbrem == false ) name_tmp = Form ("%s_W_noEP_miscalib_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_WZ_R9_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 0 && isR9selection == false && isEPselection == false && isfbrem == true && isPtCut == false ) name_tmp = Form ("%s_W_Fbrem_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == true ) name_tmp = Form ("%s_W_PT_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 0 && isR9selection == true && isEPselection == true && isfbrem == false && isPtCut == false ) name_tmp = Form ("%s_W_EP_EE", outputFile.c_str()); else if(isMiscalib == false && useZ == 0 && isEPselection == false && isR9selection == false && isPtCut == false && isfbrem == false ) name_tmp = Form ("%s_W_noEP_EE", outputFile.c_str()); else { std::cout << " Option not considered --> exit " << std::endl; return -1 ; } name = Form("%s%s.root", outputPath.c_str(), name_tmp.Data()); TFile *f1 = new TFile(name, "RECREATE"); TString outEPDistribution = "Weight_" + name; TString DeadXtal = Form("%s", inputFileDeadXtal.c_str()); if(isSaveEPDistribution == true) { FastCalibratorEE analyzer(tree, g_EoC_EE, typeEE, outEPDistribution); analyzer.bookHistos(nLoops); analyzer.AcquireDeadXtal(DeadXtal, isDeadTriggerTower); analyzer.Loop(numberOfEvents, useZ, useW, splitStat, nLoops, isMiscalib, isSaveEPDistribution, isEPselection, isR9selection, R9Min, isfbrem, fbremMax, isPtCut, PtMin, isMCTruth, jsonMap, miscalibMethod, miscalibMap); analyzer.saveHistos(f1); } else { FastCalibratorEE analyzer(tree, g_EoC_EE, typeEE); analyzer.bookHistos(nLoops); analyzer.AcquireDeadXtal(DeadXtal, isDeadTriggerTower); analyzer.Loop(numberOfEvents, useZ, useW, splitStat, nLoops, isMiscalib, isSaveEPDistribution, isEPselection, isR9selection, R9Min, isfbrem, fbremMax, isPtCut, PtMin, isMCTruth, jsonMap, miscalibMethod, miscalibMap); analyzer.saveHistos(f1); } } /// run in even-odd mode: half statistics else if ( splitStat == 1 ) { /// Prepare the outputs TString name; TString name2; if(isMiscalib == true && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_WZ_R9_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_R9_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 1 && isR9selection == false && isEPselection == true && isfbrem == false && isPtCut == false) { name = Form ("%s_WZ_EP_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_EP_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == true && isPtCut == false) { name = Form ("%s_WZ_Fbrem_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_Fbrem_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == true) { name = Form ("%s_WZ_PT_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_PT_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 1 && isR9selection == false && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_WZ_noEP_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_noEP_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 1 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_WZ_R9_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_R9_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 1 && isR9selection == false && isEPselection == true && isfbrem == false && isPtCut == false) { name = Form ("%s_WZ_EP_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_EP_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 1 && isR9selection == false && isEPselection == false && isfbrem == true && isPtCut == false) { name = Form ("%s_WZ_Fbrem_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_Fbrem_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 1 && isR9selection == false && isEPselection == false && isfbrem == false && isPtCut == true) { name = Form ("%s_WZ_PT_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_PT_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 1 && isR9selection == false && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_WZ_noEP_EE_even.root", outputFile.c_str()); name2 = Form ("%s_WZ_noEP_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_W_R9_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_W_R9_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 0 && isR9selection == false && isEPselection == true && isfbrem == false && isPtCut == false) { name = Form ("%s_W_EP_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_W_EP_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 0 && isR9selection == false && isEPselection == false && isfbrem == true && isPtCut == false) { name = Form ("%s_W_Fbrem_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_W_Fbrem_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 0 && isR9selection == false && isEPselection == false && isfbrem == false && isPtCut == true) { name = Form ("%s_W_PT_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_W_PT_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == true && useZ == 0 && isR9selection == false && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_W_noEP_miscalib_EE_even.root", outputFile.c_str()); name2 = Form ("%s_W_noEP_miscalib_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_W_R9_EE_even.root", outputFile.c_str()); name2 = Form ("%s_W_R9_EE_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_W_EP_EB_even.root", outputFile.c_str()); name2 = Form ("%s_W_EP_EB_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 0 && isR9selection == false && isEPselection == true && isfbrem == false && isPtCut == false) { name = Form ("%s_W_EP_EB_even.root", outputFile.c_str()); name2 = Form ("%s_W_EP_EB_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 0 && isR9selection == false && isEPselection == false && isfbrem == true && isPtCut == false) { name = Form ("%s_W_Fbrem_EB_even.root", outputFile.c_str()); name2 = Form ("%s_W_Fbrem_EB_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 0 && isR9selection == false && isEPselection == false && isfbrem == false && isPtCut == true) { name = Form ("%s_W_PT_EB_even.root", outputFile.c_str()); name2 = Form ("%s_W_PT_EB_odd.root", outputFile.c_str()); } else if(isMiscalib == false && useZ == 0 && isR9selection == true && isEPselection == false && isfbrem == false && isPtCut == false) { name = Form ("%s_W_noEP_EB_even.root", outputFile.c_str()); name2 = Form ("%s_W_noEP_EB_odd.root", outputFile.c_str()); } else { std::cout << " Option not considered --> exit " << std::endl; return -1 ; } TFile *outputName1 = new TFile(outputPath + name, "RECREATE"); TFile *outputName2 = new TFile(outputPath + name2, "RECREATE"); TString DeadXtal = Form("%s", inputFileDeadXtal.c_str()); /// Run on odd FastCalibratorEE analyzer_even(tree, g_EoC_EE, typeEE); analyzer_even.bookHistos(nLoops); analyzer_even.AcquireDeadXtal(DeadXtal, isDeadTriggerTower); analyzer_even.Loop(numberOfEvents, useZ, useW, splitStat, nLoops, isMiscalib, isSaveEPDistribution, isEPselection, isR9selection, R9Min, isfbrem, fbremMax, isPtCut, PtMin, isMCTruth, jsonMap, miscalibMethod, miscalibMap); analyzer_even.saveHistos(outputName1); /// Run on even FastCalibratorEE analyzer_odd(tree, g_EoC_EE, typeEE); analyzer_odd.bookHistos(nLoops); analyzer_odd.AcquireDeadXtal(DeadXtal, isDeadTriggerTower); analyzer_odd.Loop(numberOfEvents, useZ, useW, splitStat * (-1), nLoops, isMiscalib, isSaveEPDistribution, isEPselection, isR9selection, R9Min, isfbrem, fbremMax, isPtCut, PtMin, isMCTruth, jsonMap, miscalibMethod, miscalibMap); analyzer_odd.saveHistos(outputName2); } delete tree; return 0; }
int main(int argc, char** argv) { //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> analysis.cpp::usage: " << argv[0] << " configFileName" << std::endl ; return 1; } // Parse the config file parseConfigFile (argv[1]) ; std::string treeName = gConfigParser -> readStringOption("Input::treeName"); std::string inputFile = gConfigParser -> readStringOption("Input::inputFile"); double inputXSection = gConfigParser -> readDoubleOption("Input::inputXSection"); int entryMAX = gConfigParser -> readIntOption("Input::entryMAX"); int entryMIN = gConfigParser -> readIntOption("Input::entryMIN"); int entryMOD = gConfigParser -> readIntOption("Input::entryMOD"); std::cout << ">>>>> input::entryMIN " << entryMIN << std::endl; std::cout << ">>>>> input::entryMAX " << entryMAX << std::endl; std::cout << ">>>>> input::entryMOD " << entryMOD << std::endl; int dataFlag = 0; if (inputXSection == -1) dataFlag = 1; //==== it's a data sample!!! std::cerr << ">>>>> input:: --- dataFlag " << dataFlag << std::endl; // define map with events std::map<std::pair<int,std::pair<int,int> >,int> eventsMap; int nStepToDo = 1000; try { nStepToDo = gConfigParser -> readIntOption("Input::nStepToDo"); } catch (char const* exceptionString){ std::cerr << " exception = " << exceptionString << std::endl; nStepToDo = 1000; } std::cout << ">>>>> input::nStepToDo " << nStepToDo << std::endl; // Open ntple TChain* chain = new TChain(treeName.c_str()); chain->Add(inputFile.c_str()); treeReader reader((TTree*)(chain)); bool debug = false; try { debug = gConfigParser -> readBoolOption("Input::debug"); } catch (char const* exceptionString){ std::cerr << " exception = " << exceptionString << std::endl; } std::cout << ">>>>> input::debug " << debug << std::endl; ///****************** ///**** Triggers **** std::vector<std::string> HLTVector; try { HLTVector = gConfigParser -> readStringListOption("Options::HLTVector"); } catch (char const* exceptionString){ std::cerr << " exception = " << exceptionString << std::endl; } std::cout << ">>>>> Options::HLTVector size = " << HLTVector.size() << std::endl; std::cout << ">>>>> >>>>> "; for (int iHLT = 0; iHLT < HLTVector.size(); iHLT++){ std::cout << " " << HLTVector.at(iHLT) << ", "; } std::cout << std::endl; ///**************************** ///**** DATA JSON file **** std::string inFileNameJSON; try { inFileNameJSON = gConfigParser -> readStringOption("Input::inFileNameJSON"); } catch (char const* exceptionString){ std::cerr << " exception = " << exceptionString << std::endl; } std::cout << ">>>>> Input::inFileNameJSON " << inFileNameJSON << std::endl; std::map<int, std::vector<std::pair<int, int> > > jsonMap; if( dataFlag == 1 ) { jsonMap = readJSONFile(inFileNameJSON); } ///---- Efficiency preselections ---- std::string histoNameEvents = gConfigParser -> readStringOption("Input::histoNameEvents"); std::cout << ">>>>> Input::inputFile " << inputFile << std::endl; std::cout << ">>>>> Input::inputXSection " << inputXSection << std::endl; std::cout << ">>>>> Input::histoNameEvents " << histoNameEvents << std::endl; // Open ntples TFile File(inputFile.c_str()) ; TH1F* histoEvents = (TH1F*) File.Get(TString(histoNameEvents.c_str())); ///---------------------- ///---- Preselection ---- ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ///==== only retrocompatibility ==== ///================================= double lepton_efficiency = 1; double jet_efficiency = 1; double eff_Channel_Filter = 1; double preselection_efficiency = 1.; ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ///------------------- ///---- selection ---- std::string outFileName = gConfigParser -> readStringOption("Output::outFileName"); std::cout << ">>>>> Output::outFileName " << outFileName << std::endl; int nStep = 10; ///==== number of steps in the analysis int numEntriesBefore; // define variable container Variables vars; InitializeTree(vars, outFileName); InitializeTreeTrigger(vars, HLTVector, reader); vars.XSection = inputXSection; vars.dataFlag = dataFlag; ///~~~~ 0 = MC 1 = DATA if (entryMAX == -1) entryMAX = reader.GetEntries(); else if (reader.GetEntries() < entryMAX) entryMAX = reader.GetEntries(); numEntriesBefore = entryMAX - entryMIN; if (histoEvents) preselection_efficiency = numEntriesBefore / (1. * histoEvents->GetBinContent(1)); else preselection_efficiency = 1; vars.numEntriesBefore = numEntriesBefore; vars.preselection_efficiency = preselection_efficiency; FillEfficiencyTree(vars); ///************************************* ///**** definition of electron ID **** ///**** https://twiki.cern.ch/twiki/bin/viewauth/CMS/SimpleCutBasedEleID ///**** https://twiki.cern.ch/twiki/bin/viewauth/CMS/SimpleCutBasedEleID2011 std::vector<double> BarrelSelections; std::vector<double> EndcapSelections; double eleCombinedIsoBarrel = gConfigParser -> readDoubleOption("Selection::eleCombinedIsoBarrel"); double elesigmaIetaIetaBarrel = gConfigParser -> readDoubleOption("Selection::elesigmaIetaIetaBarrel"); double eledPhiBarrel = gConfigParser -> readDoubleOption("Selection::eledPhiBarrel"); double eledEtaBarrel = gConfigParser -> readDoubleOption("Selection::eledEtaBarrel"); double eleCombinedIsoEndcap = gConfigParser -> readDoubleOption("Selection::eleCombinedIsoEndcap"); double elesigmaIetaIetaEndcap = gConfigParser -> readDoubleOption("Selection::elesigmaIetaIetaEndcap"); double eledPhiEndcap = gConfigParser -> readDoubleOption("Selection::eledPhiEndcap"); double eledEtaEndcap = gConfigParser -> readDoubleOption("Selection::eledEtaEndcap"); double elemishits = gConfigParser -> readDoubleOption("Selection::elemishits"); double eledist = gConfigParser -> readDoubleOption("Selection::eledist"); double eledcot = gConfigParser -> readDoubleOption("Selection::eledcot"); double eledzPV = gConfigParser -> readDoubleOption("Selection::eledzPV"); double eledxyPV = gConfigParser -> readDoubleOption("Selection::eledxyPV"); BarrelSelections.push_back(eleCombinedIsoBarrel); BarrelSelections.push_back(elesigmaIetaIetaBarrel); BarrelSelections.push_back(eledPhiBarrel); BarrelSelections.push_back(eledEtaBarrel); BarrelSelections.push_back(elemishits); BarrelSelections.push_back(eledist); BarrelSelections.push_back(eledcot); BarrelSelections.push_back(eledzPV); BarrelSelections.push_back(eledxyPV); EndcapSelections.push_back(eleCombinedIsoEndcap); EndcapSelections.push_back(elesigmaIetaIetaEndcap); EndcapSelections.push_back(eledPhiEndcap); EndcapSelections.push_back(eledEtaEndcap); EndcapSelections.push_back(elemishits); EndcapSelections.push_back(eledist); EndcapSelections.push_back(eledcot); EndcapSelections.push_back(eledzPV); EndcapSelections.push_back(eledxyPV); ///**** https://twiki.cern.ch/twiki/bin/viewauth/CMS/SimpleCutBasedEleID --> 2010 Data ///**** 95% **** /* BarrelSelections.push_back(0.15); ///==== iso Tk BarrelSelections.push_back(2.00); ///==== iso em BarrelSelections.push_back(0.12); ///==== iso had BarrelSelections.push_back(0.15); ///==== iso combined BarrelSelections.push_back(0.015); ///==== hOe BarrelSelections.push_back(0.01); ///==== sigmaIetaIeta BarrelSelections.push_back(0.8); ///==== dPhi BarrelSelections.push_back(0.007); ///==== dEta EndCapSelections.push_back(0.08); ///==== iso Tk EndCapSelections.push_back(0.06); ///==== iso em EndCapSelections.push_back(0.05); ///==== iso had EndCapSelections.push_back(0.10); ///==== iso combined EndCapSelections.push_back(0.07); ///==== hOe EndCapSelections.push_back(0.03); ///==== sigmaIetaIeta EndCapSelections.push_back(0.7); ///==== dPhi EndCapSelections.push_back(0.01); ///==== dEta */ ///**** 90% **** /* BarrelSelections.push_back(0.12); ///==== iso Tk BarrelSelections.push_back(0.09); ///==== iso em BarrelSelections.push_back(0.10); ///==== iso had BarrelSelections.push_back(0.10); ///==== iso combined BarrelSelections.push_back(0.12); ///==== hOe BarrelSelections.push_back(0.01); ///==== sigmaIetaIeta BarrelSelections.push_back(0.8); ///==== dPhi BarrelSelections.push_back(0.007); ///==== dEta EndCapSelections.push_back(0.05); ///==== iso Tk EndCapSelections.push_back(0.06); ///==== iso em EndCapSelections.push_back(0.03); ///==== iso had EndCapSelections.push_back(0.07); ///==== iso combined EndCapSelections.push_back(0.05); ///==== hOe EndCapSelections.push_back(0.03); ///==== sigmaIetaIeta EndCapSelections.push_back(0.7); ///==== dPhi EndCapSelections.push_back(0.007); ///==== dEta */ ///**** 80% **** /* BarrelSelections.push_back(0.09); ///==== iso Tk BarrelSelections.push_back(0.07); ///==== iso em BarrelSelections.push_back(0.10); ///==== iso had BarrelSelections.push_back(0.07); ///==== iso combined BarrelSelections.push_back(0.040); ///==== hOe BarrelSelections.push_back(0.01); ///==== sigmaIetaIeta BarrelSelections.push_back(0.06); ///==== dPhi BarrelSelections.push_back(0.004); ///==== dEta EndCapSelections.push_back(0.04); ///==== iso Tk EndCapSelections.push_back(0.05); ///==== iso em EndCapSelections.push_back(0.025); ///==== iso had EndCapSelections.push_back(0.06); ///==== iso combined EndCapSelections.push_back(0.025); ///==== hOe EndCapSelections.push_back(0.03); ///==== sigmaIetaIeta EndCapSelections.push_back(0.03); ///==== dPhi EndCapSelections.push_back(0.007); ///==== dEta */ ///**** 70% **** /* BarrelSelections.push_back(0.05); ///==== iso Tk BarrelSelections.push_back(0.06); ///==== iso em BarrelSelections.push_back(0.03); ///==== iso had BarrelSelections.push_back(0.04); ///==== iso combined BarrelSelections.push_back(0.025); ///==== hOe BarrelSelections.push_back(0.01); ///==== sigmaIetaIeta BarrelSelections.push_back(0.004); ///==== dPhi BarrelSelections.push_back(0.004); ///==== dEta EndCapSelections.push_back(0.025); ///==== iso Tk EndCapSelections.push_back(0.025); ///==== iso em EndCapSelections.push_back(0.02); ///==== iso had EndCapSelections.push_back(0.03); ///==== iso combined EndCapSelections.push_back(0.025); ///==== hOe EndCapSelections.push_back(0.03); ///==== sigmaIetaIeta EndCapSelections.push_back(0.02); ///==== dPhi EndCapSelections.push_back(0.005); ///==== dEta */ ///**** https://twiki.cern.ch/twiki/bin/viewauth/CMS/SimpleCutBasedEleID2011 --> 2011 Data ///**** 95% **** /* BarrelSelections.push_back(10000.); ///==== iso Tk BarrelSelections.push_back(10000.); ///==== iso em BarrelSelections.push_back(10000.); ///==== iso had BarrelSelections.push_back(0.150); ///==== iso combined BarrelSelections.push_back(10000.); ///==== hOe BarrelSelections.push_back(0.012); ///==== sigmaIetaIeta BarrelSelections.push_back(0.800); ///==== dPhi BarrelSelections.push_back(0.007); ///==== dEta EndCapSelections.push_back(10000.); ///==== iso Tk EndCapSelections.push_back(10000.); ///==== iso em EndCapSelections.push_back(10000.); ///==== iso had EndCapSelections.push_back(0.100); ///==== iso combined EndCapSelections.push_back(10000.); ///==== hOe EndCapSelections.push_back(0.031); ///==== sigmaIetaIeta EndCapSelections.push_back(0.7); ///==== dPhi EndCapSelections.push_back(0.011); ///==== dEta */ ///**** 90% **** /* BarrelSelections.push_back(10000.); ///==== iso Tk BarrelSelections.push_back(10000.); ///==== iso em BarrelSelections.push_back(10000.); ///==== iso had BarrelSelections.push_back(0.085); ///==== iso combined BarrelSelections.push_back(10000.); ///==== hOe BarrelSelections.push_back(0.01); ///==== sigmaIetaIeta BarrelSelections.push_back(0.071); ///==== dPhi BarrelSelections.push_back(0.007); ///==== dEta EndCapSelections.push_back(10000.); ///==== iso Tk EndCapSelections.push_back(10000.); ///==== iso em EndCapSelections.push_back(10000.); ///==== iso had EndCapSelections.push_back(0.051); ///==== iso combined EndCapSelections.push_back(10000.); ///==== hOe EndCapSelections.push_back(0.031); ///==== sigmaIetaIeta EndCapSelections.push_back(0.047); ///==== dPhi EndCapSelections.push_back(0.011); ///==== dEta */ ///**** 85% **** /* BarrelSelections.push_back(10000.); ///==== iso Tk BarrelSelections.push_back(10000.); ///==== iso em BarrelSelections.push_back(10000.); ///==== iso had BarrelSelections.push_back(0.053); ///==== iso combined BarrelSelections.push_back(10000.); ///==== hOe BarrelSelections.push_back(0.01); ///==== sigmaIetaIeta BarrelSelections.push_back(0.039); ///==== dPhi BarrelSelections.push_back(0.005); ///==== dEta EndCapSelections.push_back(10000.); ///==== iso Tk EndCapSelections.push_back(10000.); ///==== iso em EndCapSelections.push_back(10000.); ///==== iso had EndCapSelections.push_back(0.042); ///==== iso combined EndCapSelections.push_back(10000.); ///==== hOe EndCapSelections.push_back(0.031); ///==== sigmaIetaIeta EndCapSelections.push_back(0.028); ///==== dPhi EndCapSelections.push_back(0.007); ///==== dEta */ ///**** 80% **** /* BarrelSelections.push_back(10000.); ///==== iso Tk BarrelSelections.push_back(10000.); ///==== iso em BarrelSelections.push_back(10000.); ///==== iso had BarrelSelections.push_back(0.040); ///==== iso combined BarrelSelections.push_back(10000.); ///==== hOe BarrelSelections.push_back(0.01); ///==== sigmaIetaIeta BarrelSelections.push_back(0.027); ///==== dPhi BarrelSelections.push_back(0.005); ///==== dEta EndCapSelections.push_back(10000.); ///==== iso Tk EndCapSelections.push_back(10000.); ///==== iso em EndCapSelections.push_back(10000.); ///==== iso had EndCapSelections.push_back(0.033); ///==== iso combined EndCapSelections.push_back(10000.); ///==== hOe EndCapSelections.push_back(0.031); ///==== sigmaIetaIeta EndCapSelections.push_back(0.021); ///==== dPhi EndCapSelections.push_back(0.006); ///==== dEta */ ///*********************************** ///**** definition of muon ID **** std::vector<double> Selections; double muCombinedIso = gConfigParser -> readDoubleOption("Selection::muCombinedIso"); double muChi2Ndof = gConfigParser -> readDoubleOption("Selection::muChi2Ndof"); double muValidTrackerHits = gConfigParser -> readDoubleOption("Selection::muValidTrackerHits"); double muValidMuonHits = gConfigParser -> readDoubleOption("Selection::muValidMuonHits"); double mutracker = gConfigParser -> readDoubleOption("Selection::mutracker"); double mustandalone = gConfigParser -> readDoubleOption("Selection::mustandalone"); double muglobal = gConfigParser -> readDoubleOption("Selection::muglobal"); double mudzPV = gConfigParser -> readDoubleOption("Selection::mudzPV"); double mudxyPV = gConfigParser -> readDoubleOption("Selection::mudxyPV"); Selections.push_back(muCombinedIso); Selections.push_back(muChi2Ndof); Selections.push_back(muValidTrackerHits); Selections.push_back(muValidMuonHits); Selections.push_back(mutracker); Selections.push_back(mustandalone); Selections.push_back(muglobal); Selections.push_back(mudzPV); Selections.push_back(mudxyPV); /* Selections.push_back(0.15); ///==== iso Combined Selections.push_back(10); ///==== Chi2/ndof Selections.push_back(10); ///==== n ValidTrackerHits Selections.push_back(0); ///==== n ValidMuonHits Selections.push_back(1); ///==== tracker Selections.push_back(1); ///==== standalone Selections.push_back(1); ///==== global //Selections.push_back(1); ///==== goodMuon */ double start, end; std::cout << ">>>>> analysis::entryMIN " << entryMIN << " ==> entryMAX " << entryMAX << ":" << reader.GetEntries() << std::endl; int step = 0; start = clock(); for(int iEvent = entryMIN ; iEvent < entryMAX ; ++iEvent) { reader.GetEntry(iEvent); if((iEvent%entryMOD) == 0) std::cout << ">>>>> analysis::GetEntry " << iEvent << " : " << entryMAX - entryMIN << std::endl; ///==== define variables ==== std::vector<ROOT::Math::XYZTVector>* jets = reader.Get4V("jets"); // std::vector<ROOT::Math::XYZTVector>* muons = reader.Get4V("muons"); // std::vector<ROOT::Math::XYZTVector>* electrons = reader.Get4V("electrons"); ///********************************************************************************************* ///********************************************************************************************* ///============================= ///==== fill MC information ==== SetMCVariables(vars, reader); ///============================= ///==== fill Primary Vertex ==== SetPVVariables(vars, reader); ///================================ ///==== fill Event information ==== SetEventVariables(vars, reader); ///*************************************************** ///**** STEP -1 - Check no copies in DATA **** ///*************************************************** if (debug) std::cout << " STEP -1 " << std::endl; if( dataFlag == 1 ) { std::pair<int,int> eventLSandID(reader.GetInt("lumiId")->at(0), reader.GetInt("eventId")->at(0)); std::pair<int,std::pair<int,int> > eventRUNandLSandID(reader.GetInt("runId")->at(0), eventLSandID); if( eventsMap[eventRUNandLSandID] == 1 ) continue; else eventsMap[eventRUNandLSandID] = 1; } ///************************************************* ///**** Check comparison with JSON file *** ///************************************************* if( dataFlag == 1 ) { int runId = reader.GetInt("runId")->at(0); int lumiId = reader.GetInt("lumiId")->at(0); if(AcceptEventByRunAndLumiSection(runId, lumiId, jsonMap) == false) continue; } ///**************************** ///**** STEP 0 - Ntuplizer **** ///************* no additional selections applied step = 0; if (step > nStepToDo) { FillTree(vars); continue; } if (debug) std::cout << ">>> STEP 0 <<<" << std::endl; ///********************************************* ///**** STEP 1 - Jet cleaning + min pT **** ///************* it's performed another time here to make sure that the cleaning worked well ///************* Jet - electrons (pT > 5) ///************* Jet - muons (pT > 5) ///************ In addition only jets with pT > 15 are considered from now on! ///************ No selections are applied here step = 1; if (step > nStepToDo) { // FillTree(vars); continue; } if (debug) std::cout << ">>> STEP 1 <<<" << std::endl; std::vector<ROOT::Math::XYZTVector> leptons_jetCleaning; // build the collection of electros for jet cleaning ///==== CLEANING WITH ELECTRONS ==== for(unsigned int iEle = 0; iEle < (reader.Get4V("electrons")->size()); ++iEle) { if( reader.Get4V("electrons")->at(iEle).pt() < 5. ) continue; // bool flag = IsEleIsolatedID_VBF(reader,BarrelSelections,EndcapSelections,iEle); bool flag = IsEleIsolatedIDPUCorrected_VBF(reader,BarrelSelections,EndcapSelections,iEle); if (!flag) continue; leptons_jetCleaning.push_back( reader.Get4V("electrons")->at(iEle) ); } ///==== CLEANING WITH MUONS ==== for (int iMu = 0; iMu < reader.Get4V("muons")->size(); iMu++){ if (reader.Get4V("muons")->at(iMu).pt() < 5.0) continue; if (fabs(reader.Get4V("muons")->at(iMu).Eta()) > 2.5) continue; // bool flag = IsMuIsolatedID_VBF(reader,Selections,iMu); bool flag = IsMuIsolatedIDPUCorrected_VBF(reader,Selections,iMu); if (!flag) continue; leptons_jetCleaning.push_back( reader.Get4V("muons")->at(iMu) ); } ///==== now clean jet collection ==== int nJets = reader.Get4V("jets")->size(); std::vector<int> whitelistJet; ///~~~~ all jets, 0 if rejected, 1 if accepted std::vector<int> blacklistJet; ///~~~~ list of numbers of jets that are "rejected" std::vector<int> blacklistJet_forCJV; std::vector<int> blacklistJet_forBtag; for (int iJet = 0; iJet < nJets; iJet++){ bool skipJet = false; if (reader.Get4V("jets")->at(iJet).Et() < 15.0) skipJet = true; for(unsigned int iLep = 0; iLep < leptons_jetCleaning.size(); ++iLep) { ROOT::Math::XYZTVector lep = leptons_jetCleaning.at(iLep); if (ROOT::Math::VectorUtil::DeltaR(reader.Get4V("jets")->at(iJet),lep) < 0.3 ) skipJet = true; } if (skipJet) { whitelistJet.push_back(0); ///---- reject blacklistJet.push_back(iJet); ///---- reject ///== black list is in a different format blacklistJet_forCJV.push_back(iJet); ///---- reject ///== black list is in a different format blacklistJet_forBtag.push_back(iJet); ///---- reject ///== black list is in a different format } else { whitelistJet.push_back(1); ///---- select } } ///************************************** ///**** STEP 2 - Super-Preselections **** ///************* tighter preselections to start the analysis from the same point ///==== construct considered objets /// Objects considered and selections /// Muon /// Pt>10GeV, eta<2.5 /// MuonId & Iso /// /// Electron /// Pt>10GeV & |eta|<2.5 /// eleId & Iso /// /// At least two leptons /// Jet /// Antikt5, L2L3 correction jets /// At least two calo jets or two pf jets with pt>15 GeV //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ step = 2; if (step > nStepToDo) { // FillTree(vars); continue; } if (debug) std::cout << ">>> STEP 2 <<<" << std::endl; /// Electron /// Pt>10GeV & |eta|<2.5 /// IsoTr / pTele <0.5 /// eleId & Iso std::vector<int> whitelistEle; std::vector<int> blacklistEle; int nEles = reader.Get4V("electrons")->size(); for (int iEle = 0; iEle < nEles; iEle++){ bool skipEle = false; if (reader.Get4V("electrons")->at(iEle).pt() < 10.0) skipEle = true; if (fabs(reader.Get4V("electrons")->at(iEle).Eta()) > 2.5) skipEle = true; // bool flag = IsEleIsolatedID_VBF(reader,BarrelSelections,EndcapSelections,iEle); bool flag = IsEleIsolatedIDPUCorrected_VBF(reader,BarrelSelections,EndcapSelections,iEle); if (!flag) skipEle = true; if (skipEle) { whitelistEle.push_back(0); ///---- reject blacklistEle.push_back(iEle); ///---- reject ///== black list is in a different format } else { whitelistEle.push_back(1); ///---- select } } /// Muon /// Pt>10GeV, eta<2.5 /// MuonId & Iso std::vector<int> whitelistMu; std::vector<int> blacklistMu; int nMus = reader.Get4V("muons")->size(); for (int iMu = 0; iMu < nMus; iMu++){ bool skipMu = false; if (reader.Get4V("muons")->at(iMu).pt() < 10.0) skipMu = true; if (fabs(reader.Get4V("muons")->at(iMu).Eta()) > 2.5) skipMu = true; // bool flag = IsMuIsolatedID_VBF(reader,Selections,iMu); bool flag = IsMuIsolatedIDPUCorrected_VBF(reader,Selections,iMu); if (!flag) skipMu = true; if (skipMu) { whitelistMu.push_back(0); ///---- reject blacklistMu.push_back(iMu); ///---- reject ///== black list is in a different format } else { whitelistMu.push_back(1); ///---- select } } /// At least 2 leptons int numMus_Accepted = GetNumList(whitelistMu); int numEles_Accepted = GetNumList(whitelistEle); int numLeptons_Accepted = numMus_Accepted + numEles_Accepted; if (numLeptons_Accepted < 2) continue; /// Jet /// At least two calo jets or two pf jets with pt>20 GeV int numJets_Accepted = GetNumList(whitelistJet); if (numJets_Accepted < 2) continue; ///==== at least 2 jets "isolated" ///************************* ///**** STEP 3 - Jet ID **** ///************* Identification of two tag jets step = 3; if (step > nStepToDo) { // FillTree(vars); continue; } if (debug) std::cout << ">>> STEP 3 <<<" << std::endl; std::vector<int> itSelJet; double maxPt_jets_selected = SelectJets(itSelJet,*jets,"maxSumPt",-1.,&blacklistJet); int q1 = itSelJet.at(0); int q2 = itSelJet.at(1); ///---- check Pt order ---- if (jets->at(q1).Pt() < jets->at(q2).Pt()) { int tempq = q1; q1 = q2; q2 = tempq; } if (debug) std::cerr << " q1 = " << q1 << " : q2 = " << q2 << std::endl; ///---- update white/black list jets ---- for (int iJet = 0; iJet < nJets; iJet++){ if (q1 == iJet || q2 == iJet) { whitelistJet.at(iJet) = 1; blacklistJet.push_back(iJet); ///===> blacklistJet used for CJV => no 2 tag jets to be considered! blacklistJet_forCJV.push_back(iJet); ///===> blacklistJet used for CJV => no 2 tag jets to be considered! } else { whitelistJet.at(iJet) = 0; } } SetQJetVariables(vars, reader, q1, q2, blacklistJet_forCJV, blacklistJet_forBtag, blacklistJet_forBtag); ///******************************** ///**** STEP 4 - Lepton ID **** ///************* Identification of the two leptons step = 4; if (step > nStepToDo) { FillTree(vars); continue; } if (debug) std::cout << ">>> STEP 4 <<<" << std::endl; std::vector<ROOT::Math::XYZTVector> leptons; std::vector<int> leptonFlavours; std::vector<int> leptonILep; for(unsigned int iEle = 0; iEle < nEles; iEle++){ if (whitelistEle.at(iEle) == 1){ leptons.push_back( reader.Get4V("electrons")->at(iEle) ); leptonFlavours.push_back(11); leptonILep.push_back(iEle); } } for(unsigned int iMu = 0; iMu < nMus; iMu++){ if (whitelistMu.at(iMu) == 1){ leptons.push_back( reader.Get4V("muons")->at(iMu) ); leptonFlavours.push_back(13); leptonILep.push_back(iMu); } } std::vector<int> itSelLep; double maxPt_lept_selected = SelectJets(itSelLep,leptons,"maxSumPt",-1.,0); int l1 = itSelLep.at(0); int l2 = itSelLep.at(1); ///---- check Pt order ---- if (leptons.at(l1).Pt() < leptons.at(l2).Pt()) { int templ = l1; l1 = l2; l2 = templ; } if (debug) std::cerr << " l1 = " << l1 << " : l2 = " << l2 << std::endl; SetLeptonsVariables(vars, reader, leptonILep.at(l1), leptonILep.at(l2),leptonFlavours.at(l1), leptonFlavours.at(l2)); if (debug) std::cerr << ">> Lepton variables set" << std::endl; SetMetVariables(vars, reader, "PFMet", leptonILep.at(l1), leptonILep.at(l2),leptonFlavours.at(l1), leptonFlavours.at(l2)); if (debug) std::cerr << ">> MET variables set" << std::endl; //---- lepton veto std::vector<int> blacklistLepton; blacklistLepton.push_back(l1); blacklistLepton.push_back(l2); vars.Nleptons_pT5 = getNumberPTThreshold(leptons, 5, &blacklistLepton); vars.Nleptons_pT10 = getNumberPTThreshold(leptons, 10, &blacklistLepton); vars.Nleptons_pT15 = getNumberPTThreshold(leptons, 15, &blacklistLepton); vars.Nleptons_pT20 = getNumberPTThreshold(leptons, 20, &blacklistLepton); vars.Nleptons_pT25 = getNumberPTThreshold(leptons, 25, &blacklistLepton); vars.Nleptons_pT30 = getNumberPTThreshold(leptons, 30, &blacklistLepton); if (debug) std::cerr << ">> Lepton multiplicity set" << std::endl; ///********************************* ///**** STEP 5 - Jet Selections **** ///************* Loose selections of tag jets step = 5; if (step > nStepToDo) { FillTree(vars); continue; } if (debug) std::cout << ">>> STEP 5 <<<" << std::endl; ///---- hardcoded fixed preselections ---- VBF (begin) ---- if (vars.q1_pT < 20.) continue; if (vars.q2_pT < 15.) continue; if (vars.M_qq < 0.) continue; if (vars.DEta_qq < 0.) continue; ///---- hardcoded fixed preselections ---- VBF (end) ---- ///==== save trigger variables ==== SetTriggerVariables(vars, reader); ///************************************ ///**** STEP 6 - Final Production ***** ///************************************ ///**** No more selections applied **** step = 6; if (step > nStepToDo) { FillTree(vars); continue; } if (debug) std::cout << ">>> STEP 6 <<<" << std::endl; ///==== if not already filled ... ==== FillTree(vars); ///================================================= } end = clock(); std::cout <<"Time = " << ((double) (end - start)) << " (a.u.)" << std::endl; SaveTree(vars); std::cerr << " === end === " << std::endl; }
int main(int argc, char** argv) { //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> SimpleNtplePreselection::usage: " << argv[0] << " configFileName" << std::endl ; return 1; } // Parse the config file parseConfigFile (argv[1]) ; std::string inputFileList = gConfigParser -> readStringOption("Input::inputFileList"); std::string jsonFileName = gConfigParser -> readStringOption("Input::jsonFileName"); std::string outputRootFilePath = gConfigParser -> readStringOption("Output::outputRootFilePath"); std::string outputRootFileName = gConfigParser -> readStringOption("Output::outputRootFileName"); int entryMAX = gConfigParser -> readIntOption("Options::entryMAX"); int entryMODULO = gConfigParser -> readIntOption("Options::entryMODULO"); int dataFlag = gConfigParser -> readIntOption("Options::dataFlag"); int nEleMIN = gConfigParser -> readIntOption ("Cuts::nEleMIN"); float scEtMIN = gConfigParser -> readFloatOption("Cuts::scEtMIN"); float eleCombIsoOverPtEBMAX = gConfigParser -> readFloatOption("Cuts::eleCombIsoOverPtEBMAX"); float eleTkIsoOverPtEBMAX = gConfigParser -> readFloatOption("Cuts::eleTkIsoOverPtEBMAX"); float eleEmIsoOverPtEBMAX = gConfigParser -> readFloatOption("Cuts::eleEmIsoOverPtEBMAX"); float eleHadIsoOverPtEBMAX = gConfigParser -> readFloatOption("Cuts::eleHadIsoOverPtEBMAX"); float eleSigmaIetaIetaEBMAX = gConfigParser -> readFloatOption("Cuts::eleSigmaIetaIetaEBMAX"); float eleDphiInEBMAX = gConfigParser -> readFloatOption("Cuts::eleDphiInEBMAX"); float eleDetaInEBMAX = gConfigParser -> readFloatOption("Cuts::eleDetaInEBMAX"); float eleHOverEEBMAX = gConfigParser -> readFloatOption("Cuts::eleHOverEEBMAX"); float eleCombIsoOverPtEEMAX = gConfigParser -> readFloatOption("Cuts::eleCombIsoOverPtEEMAX"); float eleTkIsoOverPtEEMAX = gConfigParser -> readFloatOption("Cuts::eleTkIsoOverPtEEMAX"); float eleEmIsoOverPtEEMAX = gConfigParser -> readFloatOption("Cuts::eleEmIsoOverPtEEMAX"); float eleHadIsoOverPtEEMAX = gConfigParser -> readFloatOption("Cuts::eleHadIsoOverPtEEMAX"); float eleSigmaIetaIetaEEMAX = gConfigParser -> readFloatOption("Cuts::eleSigmaIetaIetaEEMAX"); float eleDphiInEEMAX = gConfigParser -> readFloatOption("Cuts::eleDphiInEEMAX"); float eleDetaInEEMAX = gConfigParser -> readFloatOption("Cuts::eleDetaInEEMAX"); float eleHOverEEEMAX = gConfigParser -> readFloatOption("Cuts::eleHOverEEEMAX"); float metEtMIN = gConfigParser -> readFloatOption("Cuts::metEtMIN"); // Get number of events std::cout << ">>> SimpleNtplePreselection::Get number of events" << std::endl; std::map<int,int> totalEvents = GetTotalEvents("AllPassFilterBegin/totalEvents", inputFileList.c_str()); std::string L1FilterName = "AllPassFilterL1Filter/totalEvents"; std::map<int,int> L1FilterEvents = GetTotalEvents(L1FilterName.c_str(), inputFileList.c_str()); std::string GoodVertexFilterName = "AllPassFilterGoodVertexFilter/totalEvents"; std::map<int,int> GoodVertexFilterEvents = GetTotalEvents(GoodVertexFilterName.c_str(), inputFileList.c_str()); std::string NoScrapingFilterName = "AllPassFilterNoScrapingFilter/totalEvents"; std::map<int,int> NoScrapingFilterEvents = GetTotalEvents(NoScrapingFilterName.c_str(), inputFileList.c_str()); std::string ElectronFilterName = "AllPassFilterElectronFilter/totalEvents"; std::map<int,int> ElectronFilterEvents = GetTotalEvents(ElectronFilterName.c_str(), inputFileList.c_str()); // Get run/LS map from JSON file std::cout << ">>> SimpleNtplePreselection::Get run/LS map from JSON file " << jsonFileName << std::endl; std::map<int, std::vector<std::pair<int, int> > > jsonMap; if(dataFlag == 1) jsonMap = readJSONFile(jsonFileName); // Open old tree std::cout << ">>> SimpleNtplePreselection::Open old tree" << std::endl; std::string treeName = "simpleNtple/SimpleNtple"; TChain* chain = new TChain(treeName.c_str()); if(!FillChain(*chain, inputFileList.c_str())) return 1; treeReader reader((TTree*)(chain), false); // Open output root file for clone tree TFile outputRootFile((outputRootFilePath+outputRootFileName).c_str(), "RECREATE"); outputRootFile.cd(); TTree* cloneTree = chain -> CloneTree(0); // define histograms std::cout << ">>> SimpleNtplePreselection::Define histograms" << std::endl; int nStep = 9; TH1F* events = new TH1F("events", "events", nStep, 0., 1.*nStep); std::map<int, int> stepEvents; std::map<int, std::string> stepName; int step = 1; stepEvents[step] = totalEvents[1]; stepName[step] = "total events"; step = 2; stepEvents[step] = L1FilterEvents[1]; stepName[step] = "L1Filter"; step = 3; stepEvents[step] = GoodVertexFilterEvents[1]; stepName[step] = "GoodVertexFilter"; step = 4; stepEvents[step] = NoScrapingFilterEvents[1]; stepName[step] = "NoScrapingFilter"; step = 5; stepEvents[step] = ElectronFilterEvents[1]; stepName[step] = "ElectronFilter"; // Loop over events std::cout << ">>>>> SimpleNtplePreselection::Read " << chain -> GetEntries() << " entries" << std::endl; for(int entry = 0 ; entry < chain -> GetEntries() ; ++entry) { reader.GetEntry(entry); if((entry%entryMODULO) == 0) std::cout << ">>>>> SimpleNtplePreselection::GetEntry " << entry << std::endl; if(entry == entryMAX) break; //*********************** // STEP 6 - HLT selection step = 6; //std::cout << ">>> step: " << step << std::endl; stepName[step] = "HLT"; bool skipEvent = true; std::vector<std::string> HLT_names = *(reader.GetString("HLT_Names")); for(unsigned int HLTIt = 0; HLTIt < HLT_names.size(); ++HLTIt) { if( (reader.GetString("HLT_Names")->at(HLTIt) == "HLT_Photon15_L1R") && (reader.GetFloat("HLT_Accept")->at(HLTIt) == 1) ) skipEvent = false; if( (reader.GetString("HLT_Names")->at(HLTIt) == "HLT_Ele15_LW_L1R") && (reader.GetFloat("HLT_Accept")->at(HLTIt) == 1) ) skipEvent = false; if( (reader.GetString("HLT_Names")->at(HLTIt) == "HLT_Ele15_SW_L1R") && (reader.GetFloat("HLT_Accept")->at(HLTIt) == 1) ) skipEvent = false; if( (reader.GetString("HLT_Names")->at(HLTIt) == "HLT_Ele15_SW_CaloEleId_L1R") && (reader.GetFloat("HLT_Accept")->at(HLTIt) == 1) ) skipEvent = false; } if( skipEvent == true ) continue; stepEvents[step] += 1; //************************** // STEP 7 - run/LS selection step = step+1; //std::cout << ">>> step: " << step << std::endl; stepName[step] = "run/LS"; skipEvent = false; if(dataFlag == 1) { int runId = reader.GetInt("runId")->at(0); int lumiId = reader.GetInt("lumiId")->at(0); if(AcceptEventByRunAndLumiSection(runId, lumiId, jsonMap) == false) skipEvent = true; } if( skipEvent == true ) continue; stepEvents[step] += 1; //************************* // STEP 8 - cut on electron step = step+1; //std::cout << ">>> step: " << step << std::endl; stepName[step] = "electron selection"; int nEle = 0; for(unsigned int eleIt = 0; eleIt < (reader.Get4V("electrons")->size()); ++eleIt) { // SC Et if( reader.GetFloat("electrons_scEt")->at(eleIt) < scEtMIN ) continue; // isolation + eleId float pt = reader.Get4V("electrons")->at(eleIt).pt(); float tkIso = reader.GetFloat("electrons_tkIso03")->at(eleIt); float emIso = reader.GetFloat("electrons_emIso03")->at(eleIt); float hadIso = reader.GetFloat("electrons_hadIso03_1")->at(eleIt) + reader.GetFloat("electrons_hadIso03_2")->at(eleIt); float sigmaIetaIeta = reader.GetFloat("electrons_sigmaIetaIeta")->at(eleIt); float dPhiIn = reader.GetFloat("electrons_deltaPhiIn")->at(eleIt); float dEtaIn = reader.GetFloat("electrons_deltaEtaIn")->at(eleIt); float hOverE = reader.GetFloat("electrons_hOverE")->at(eleIt); if( (reader.GetInt("electrons_isEB")->at(eleIt)) == 1 ) { if( ((tkIso + std::max(0., emIso-1.) + hadIso) / pt) > eleCombIsoOverPtEBMAX ) continue; if( (tkIso / pt) > eleTkIsoOverPtEBMAX ) continue; if( (emIso / pt) > eleEmIsoOverPtEBMAX ) continue; if( (hadIso / pt) > eleHadIsoOverPtEBMAX ) continue; if( sigmaIetaIeta > eleSigmaIetaIetaEBMAX ) continue; if( fabs(dPhiIn) > eleDphiInEBMAX ) continue; if( fabs(dEtaIn) > eleDetaInEBMAX ) continue; if( hOverE > eleHOverEEBMAX ) continue; } else { if( ((tkIso + emIso + hadIso) / pt) > eleCombIsoOverPtEEMAX ) continue; if( (tkIso / pt) > eleTkIsoOverPtEEMAX ) continue; if( (emIso / pt) > eleEmIsoOverPtEEMAX ) continue; if( (hadIso / pt) > eleHadIsoOverPtEEMAX ) continue; if( sigmaIetaIeta > eleSigmaIetaIetaEEMAX ) continue; if( fabs(dPhiIn) > eleDphiInEEMAX ) continue; if( fabs(dEtaIn) > eleDetaInEEMAX ) continue; if( hOverE > eleHOverEEEMAX ) continue; } // conversion rejection if( reader.GetInt("electrons_mishits")->at(eleIt) > 0 ) continue; if( reader.GetInt("electrons_nAmbiguousGsfTracks")->at(eleIt) > 0 ) continue; if( ( fabs(reader.GetFloat("electrons_dist")->at(eleIt)) < 0.02 ) && ( fabs(reader.GetFloat("electrons_dcot")->at(eleIt)) < 0.02 ) ) continue; // spike removal if( reader.GetInt("electrons_seedSeverityLevel")->at(eleIt) != 0 ) continue; if( reader.GetInt("electrons_seedFlag")->at(eleIt) != 0 ) continue; ++nEle; } if( nEle < nEleMIN ) continue; stepEvents[step] += 1; //******************** // STEP 9 - cut on met step = step+1; //std::cout << ">>> step: " << step << std::endl; stepName[step] = "met selection"; if( (reader.Get4V("PFMet")->at(0)).Et() < metEtMIN ) continue; stepEvents[step] += 1; //*********** // CLONE TREE cloneTree -> Fill(); } // loop over the events // save histograms for(step = 1; step <= nStep; ++step) { events -> SetBinContent(step, stepEvents[step]); events -> GetXaxis() -> SetBinLabel(step, stepName[step].c_str()); } events -> Write(); cloneTree -> AutoSave(); outputRootFile.Close(); return 0; }
void TreeToHistos(TChain* myChain, TString dirOut, ofstream& outlog, int nEntries, TString halftag, float spikeCut, TString hlt_sel, int sev_user, bool debug=false) { // get the tree int nEvent, nRun, nLumi, trig_isUnbiased, trig_isL1SingleEG2, trig_isL1SingleEG5, trig_isL1SingleEG8, vtx_N; int trig_HLT_path[4]; // Masked TT int trig_nMaskedCh; int trig_iMaskedTTeta[4032], trig_iMaskedTTphi[4032]; // TP info int trig_tower_N,trig_tower_ieta[4032],trig_tower_iphi[4032],trig_tower_adc[4032],trig_tower_sFGVB[4032]; int trig_tower_N_modif,trig_tower_ieta_modif[4032],trig_tower_iphi_modif[4032],trig_tower_adc_modif[4032],trig_tower_sFGVB_modif[4032]; int trig_L1emIso_N, trig_L1emNonIso_N, trig_L1emIso_N_modif, trig_L1emNonIso_N_modif; int trig_tower_N_emul,trig_tower_ieta_emul[4032],trig_tower_iphi_emul[4032],trig_tower_adc_emul[4032][5],trig_tower_sFGVB_emul[4032][5]; // L1 candidates info int trig_L1emIso_ieta[4], trig_L1emIso_iphi[4], trig_L1emIso_rank[4]; int trig_L1emNonIso_ieta[4], trig_L1emNonIso_iphi[4], trig_L1emNonIso_rank[4]; int trig_L1emIso_ieta_modif[4], trig_L1emIso_iphi_modif[4], trig_L1emIso_rank_modif[4]; int trig_L1emNonIso_ieta_modif[4], trig_L1emNonIso_iphi_modif[4], trig_L1emNonIso_rank_modif[4]; // Spikes int spike_N,spike_TTieta[5000], spike_TTiphi[5000], spike_Rieta[5000], spike_Riphi[5000], spike_severityLevel[5000], spike_outOfTime[5000]; double spike_Et[5000], spike_eta[5000], spike_phi[5000], spike_theta[5000]; // Global myChain->SetBranchAddress("nEvent",&nEvent); myChain->SetBranchAddress("nRun",&nRun); myChain->SetBranchAddress("nLumi",&nLumi); //myChain->SetBranchAddress("trig_HLT_path",&trig_HLT_path); myChain->SetBranchAddress("vtx_N",&vtx_N); myChain->SetBranchAddress("trig_isUnbiased",&trig_isUnbiased); myChain->SetBranchAddress("trig_isL1SingleEG2",&trig_isL1SingleEG2); myChain->SetBranchAddress("trig_isL1SingleEG5",&trig_isL1SingleEG5); myChain->SetBranchAddress("trig_isL1SingleEG8",&trig_isL1SingleEG8); // L1 candidates myChain->SetBranchAddress("trig_L1emIso_N", &trig_L1emIso_N_modif); myChain->SetBranchAddress("trig_L1emIso_ieta", &trig_L1emIso_ieta_modif); myChain->SetBranchAddress("trig_L1emIso_iphi", &trig_L1emIso_iphi_modif); myChain->SetBranchAddress("trig_L1emIso_rank", &trig_L1emIso_rank_modif); myChain->SetBranchAddress("trig_L1emNonIso_N", &trig_L1emNonIso_N_modif); myChain->SetBranchAddress("trig_L1emNonIso_ieta", &trig_L1emNonIso_ieta_modif); myChain->SetBranchAddress("trig_L1emNonIso_iphi", &trig_L1emNonIso_iphi_modif); myChain->SetBranchAddress("trig_L1emNonIso_rank", &trig_L1emNonIso_rank_modif); myChain->SetBranchAddress("trig_L1emIso_N_M", &trig_L1emIso_N); myChain->SetBranchAddress("trig_L1emIso_ieta_M", &trig_L1emIso_ieta); myChain->SetBranchAddress("trig_L1emIso_iphi_M", &trig_L1emIso_iphi); myChain->SetBranchAddress("trig_L1emIso_rank_M", &trig_L1emIso_rank); myChain->SetBranchAddress("trig_L1emNonIso_N_M", &trig_L1emNonIso_N); myChain->SetBranchAddress("trig_L1emNonIso_ieta_M", &trig_L1emNonIso_ieta); myChain->SetBranchAddress("trig_L1emNonIso_iphi_M", &trig_L1emNonIso_iphi); myChain->SetBranchAddress("trig_L1emNonIso_rank_M", &trig_L1emNonIso_rank); // Trigger Towers // masked // myChain->SetBranchAddress("trig_nMaskedRCT", &trig_nMaskedRCT); // myChain->SetBranchAddress("trig_iMaskedRCTeta", &trig_iMaskedRCTeta); // myChain->SetBranchAddress("trig_iMaskedRCTcrate", &trig_iMaskedRCTcrate); // myChain->SetBranchAddress("trig_iMaskedRCTphi", &trig_iMaskedRCTphi); myChain->SetBranchAddress("trig_nMaskedCh", &trig_nMaskedCh); myChain->SetBranchAddress("trig_iMaskedTTeta", &trig_iMaskedTTeta); myChain->SetBranchAddress("trig_iMaskedTTphi", &trig_iMaskedTTphi); // normal collection myChain->SetBranchAddress("trig_tower_N", &trig_tower_N); myChain->SetBranchAddress("trig_tower_ieta", &trig_tower_ieta); myChain->SetBranchAddress("trig_tower_iphi", &trig_tower_iphi); myChain->SetBranchAddress("trig_tower_adc", &trig_tower_adc); myChain->SetBranchAddress("trig_tower_sFGVB", &trig_tower_sFGVB); // modified collection myChain->SetBranchAddress("trig_tower_N_modif", &trig_tower_N_modif); myChain->SetBranchAddress("trig_tower_ieta_modif", &trig_tower_ieta_modif); myChain->SetBranchAddress("trig_tower_iphi_modif", &trig_tower_iphi_modif); myChain->SetBranchAddress("trig_tower_adc_modif", &trig_tower_adc_modif); myChain->SetBranchAddress("trig_tower_sFGVB_modif", &trig_tower_sFGVB_modif); myChain->SetBranchAddress("trig_tower_N_emul", &trig_tower_N_emul); myChain->SetBranchAddress("trig_tower_ieta_emul", &trig_tower_ieta_emul); myChain->SetBranchAddress("trig_tower_iphi_emul", &trig_tower_iphi_emul); myChain->SetBranchAddress("trig_tower_adc_emul", &trig_tower_adc_emul); myChain->SetBranchAddress("trig_tower_sFGVB_emul", &trig_tower_sFGVB_emul); // Spikes myChain->SetBranchAddress("spike_N",&spike_N); myChain->SetBranchAddress("spike_TTieta",&spike_TTieta); myChain->SetBranchAddress("spike_TTiphi",&spike_TTiphi); myChain->SetBranchAddress("spike_Rieta",&spike_Rieta); myChain->SetBranchAddress("spike_Riphi",&spike_Riphi); myChain->SetBranchAddress("spike_severityLevel",&spike_severityLevel); myChain->SetBranchAddress("spike_outOfTime",&spike_outOfTime); myChain->SetBranchAddress("spike_Et",&spike_Et); myChain->SetBranchAddress("spike_eta",&spike_eta); myChain->SetBranchAddress("spike_phi",&spike_phi); myChain->SetBranchAddress("spike_theta",&spike_theta); MAPTTS adcTT; MAPTTS::iterator iterTT; pair<int,int> coords; vector< pair<int,int> > maskedTT; const int nEG = 8; int trigthresh[nEG] = {2,5,8,10,12,15,20} ; bool triggEG[nEG], triggEGM[nEG]; for(int i=0 ; i<7 ; i++) { triggEG[i] = false ; triggEGM[i] = false ; } vector<int> firedEG_N; // EG 2/5/8/10/12/15/20/30 vector<int> firedEG_M; vector<int> matchIso, matchNonIso, matchIsoM, matchNonIsoM; const int nVtx=40; int iVtx=0; vector<int> IdxVtx; int nSpikyL1[nEG][nVtx], nLostSpikyL1[nEG][nVtx], nSpikes[nVtx], nSpikyL1sat[nVtx], nSpikesWellId[nVtx], nDiffSFGVB[nVtx], nMatchedTT[nVtx], nLostTT[nVtx]; for(iVtx=0 ; iVtx<nVtx ; iVtx++) { nSpikes[iVtx] = nSpikyL1sat[iVtx] = nSpikesWellId[iVtx] = nDiffSFGVB[iVtx] = nMatchedTT[iVtx] = nLostTT[iVtx] = 0; for(int itg=0 ; itg<nEG ; itg++) nSpikyL1[itg][iVtx] = nLostSpikyL1[itg][iVtx] = 0 ; } bool isGoodRun,output,saturates,wellId,missed,eliminated,zeroedTT,trigEG8,trigEG8M; string flag; // ------------------------------------------------------------------------------- // JSON FILE READER // ------------------------------------------------------------------------------- // define map of run/LS //string jsonFile = "/data_CMS/cms/ndaci/ndaci_2011A/JSON/Cert_160404-177515_7TeV_PromptReco_Collisions11_JSON.txt"; string jsonFile = "/data_CMS/cms/ndaci/ndaci_2011A/JSON/Cert_160404-178677_7TeV_PromptReco_Collisions11_JSON.txt"; map<int, vector<pair<int, int> > > jsonMap = readJSONFile(jsonFile); if(debug) cout << "gonna loop over events" << endl; TString filename; int nCurrentRun; int numEntries = myChain->GetEntries () ; outlog << "numEntries=" << numEntries << endl; int nProcess = numEntries; if(nEntries>=0 && nEntries<numEntries) nProcess = nEntries; // loop over events for (int iEvent = 0 ; iEvent < nProcess ; iEvent++ ) { IdxVtx.clear(); IdxVtx.push_back(0); if(vtx_N>0 && vtx_N<40) IdxVtx.push_back(vtx_N); //if(iEvent%500 != 0) continue; myChain->GetEntry (iEvent) ; // run selection isGoodRun = AcceptEventByRunAndLumiSection(nRun, nLumi, jsonMap); if(!isGoodRun) continue; // HLT selection if( hlt_sel=="unbias" ) { if( trig_isUnbiased==0 ) { continue; } } if(debug) cout << "passed json" << endl; // show which file is being processed if(iEvent==0) { filename = myChain->GetFile()->GetName() ; outlog << "File : " << filename << endl; } else if( filename != myChain->GetFile()->GetName() ) { filename = myChain->GetFile()->GetName() ; outlog << "File : " << myChain->GetFile()->GetName() << endl; } // show which run/category is being processed if(iEvent==0) { nCurrentRun = nRun ; outlog << "nRun=" << nRun << endl; } else if(nRun!=nCurrentRun) { nCurrentRun=nRun ; outlog << "nRun=" << nRun << endl; } //cout << nRun << " " << nEvent << endl; // map the towers adcTT.clear(); for(int t=0 ; t<trig_tower_N ; t++) { coords = make_pair( trig_tower_ieta[t] , trig_tower_iphi[t] ); adcTT[coords].first.first = trig_tower_adc[t]; adcTT[coords].second.first = trig_tower_sFGVB[t]; //if(trig_tower_ieta[t]>-17 && trig_tower_ieta[t]<18) //for(int i=0 ; i<IdxCat.size() ; i++) //h_adc[0][IdxCat[i]]->Fill(0.25*trig_tower_adc[t]); } for(int t=0 ; t<trig_tower_N_emul ; t++) { coords = make_pair( trig_tower_ieta_emul[t] , trig_tower_iphi_emul[t] ); iterTT = adcTT.find( coords ); if( iterTT != adcTT.end() ) { adcTT[coords].first.second = trig_tower_adc_emul[t][2]; adcTT[coords].second.second = trig_tower_sFGVB_emul[t][2]; //if(trig_tower_ieta_emul[t]>-17 && trig_tower_ieta_emul[t]<18) //for(int i=0 ; i<IdxCat.size() ; i++) //h_adc[3][iCat]->Fill(0.25*trig_tower_adc_emul[t][2]); } else { outlog << "mapping problem" << endl; adcTT[coords].first.first = -777; adcTT[coords].first.second = trig_tower_adc_emul[t][2]; adcTT[coords].second.first = -777; adcTT[coords].second.second = trig_tower_sFGVB_emul[t][2]; } } // get masked towers maskedTT.clear(); for(int iTT=0 ; iTT<trig_nMaskedCh ; iTT++) { maskedTT.push_back( make_pair( trig_iMaskedTTeta[iTT] , trig_iMaskedTTphi[iTT] ) ); } // loop over evil rechits if(debug) cout << "loop over evil rechits" << endl; saturates = false; for(int irh=0 ; irh<spike_N ; irh++) { if( spike_severityLevel[irh]>=sev_user && spike_severityLevel[irh]!=5 ) { // (kTime) + kWeird but not kProblematic // selection on the energy if( spike_Et[irh]<spikeCut ) continue; //if(vtx_N>0 && vtx_N<40) IdxVtx.push_back(vtx_N); for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nSpikes[IdxVtx[iVtx]]++ ; matchIso.clear(); matchNonIso.clear(); matchIsoM.clear(); matchNonIsoM.clear(); if(spike_Et[irh]>0) { output=false; saturates = false; for(int itg=0 ; itg<nEG ; itg++) triggEG[itg] = triggEGM[itg] = false; for(int ic=0 ; ic<4 ; ic++) { if(trig_L1emIso_ieta[ic]==spike_Rieta[irh] && trig_L1emIso_iphi[ic]==spike_Riphi[irh]) { output = true; matchIso.push_back(ic); if(trig_L1emIso_rank[ic]>=63) saturates = true; for(int itg=0 ; itg<nEG ; itg++) if(trig_L1emIso_rank[ic]>=trigthresh[itg]) triggEG[itg] = true; } if(trig_L1emNonIso_ieta[ic]==spike_Rieta[irh] && trig_L1emNonIso_iphi[ic]==spike_Riphi[irh]) { output = true; matchNonIso.push_back(ic); if(trig_L1emNonIso_rank[ic]>=63) saturates = true; for(int itg=0 ; itg<nEG ; itg++) if(trig_L1emNonIso_rank[ic]>=trigthresh[itg]) triggEG[itg] = true; } if(trig_L1emIso_ieta_modif[ic]==spike_Rieta[irh] && trig_L1emIso_iphi_modif[ic]==spike_Riphi[irh]) { output = true; matchIsoM.push_back(ic); if(trig_L1emIso_rank_modif[ic]>=63) saturates = true; for(int itg=0 ; itg<nEG ; itg++) if(trig_L1emIso_rank_modif[ic]>=trigthresh[itg]) triggEGM[itg] = true; } if(trig_L1emNonIso_ieta_modif[ic]==spike_Rieta[irh] && trig_L1emNonIso_iphi_modif[ic]==spike_Riphi[irh]) { output = true; matchNonIsoM.push_back(ic); if(trig_L1emNonIso_rank_modif[ic]>=63) saturates = true; for(int itg=0 ; itg<nEG ; itg++) if(trig_L1emNonIso_rank_modif[ic]>=trigthresh[itg]) triggEGM[itg] = true; } } coords = make_pair(spike_TTieta[irh] , spike_TTiphi[irh]); bool b_mask = false; for(int iTT=0 ; iTT<maskedTT.size() ; iTT++) { if( maskedTT[iTT] == coords ) b_mask = true; } //if(output) { if(true) { outlog << "Spike nRun=" << nRun << " nEvent=" << nEvent << "("<<iEvent<<")" << endl << "Rieta=" << spike_Rieta[irh] << " Riphi=" << spike_Riphi[irh] << " TTieta=" << spike_TTieta[irh] << " TTiphi=" << spike_TTiphi[irh] //<< " outOfTime=" << spike_outOfTime[irh] << " severity=" << spike_severityLevel[irh] << " Et=" << spike_Et[irh]; if(b_mask) outlog << " | masked" ; outlog << endl; if(matchIso.size()>0) for(int ic=0 ; ic<matchIso.size() ; ic++) outlog << "Iso rank=" << trig_L1emIso_rank[matchIso[ic]] << " "; if(matchNonIso.size()>0) for(int ic=0 ; ic<matchNonIso.size() ; ic++) outlog << "NonIso rank=" << trig_L1emNonIso_rank[matchNonIso[ic]] << " "; if(matchIsoM.size()>0) for(int ic=0 ; ic<matchIsoM.size() ; ic++) outlog << "IsoM rank=" << trig_L1emIso_rank_modif[matchIsoM[ic]] << " "; if(matchNonIsoM.size()>0) for(int ic=0 ; ic<matchNonIsoM.size() ; ic++) outlog << "NonIsoM rank=" << trig_L1emNonIso_rank_modif[matchNonIsoM[ic]] ; outlog<<endl; outlog << "Trigger Tower : adc=" << adcTT[coords].first.first << " adc_emul=" << adcTT[coords].first.second << " sFGVB=" << adcTT[coords].second.first << " sFGVB_emul=" << adcTT[coords].second.second ; if(adcTT[coords].second.first != adcTT[coords].second.second) { for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nDiffSFGVB[IdxVtx[iVtx]]++ ; outlog << " !! sFGVB diff !!" ; } outlog << endl; wellId = zeroedTT = eliminated = missed = false; // non L1-matching-dependant properties if(adcTT[coords].second.first==0) { wellId = true; for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nSpikesWellId[IdxVtx[iVtx]]++ ; } if(adcTT[coords].first.second>0) { for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nMatchedTT[IdxVtx[iVtx]]++; if(adcTT[coords].first.first==0) { for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nLostTT[IdxVtx[iVtx]]++; zeroedTT = true; } } // non L1-matching // L1-matching-dependant properties if( matchIso.size()>0 || matchNonIso.size()>0 ) { if(saturates) { //saturates = true; for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nSpikyL1sat[IdxVtx[iVtx]]++ ; } } // L1-matching // EGX for(int itg=0 ; itg<nEG ; itg++) { if( triggEG[itg] ) { for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nSpikyL1[itg][IdxVtx[iVtx]]++ ; if( !triggEGM[itg] ) { for(iVtx=0 ; iVtx<IdxVtx.size() ; iVtx++) nLostSpikyL1[itg][IdxVtx[iVtx]]++ ; eliminated = true; } } // EGX-L1-matching } // Modified L1-matching // EG8 if(triggEGM[2]) { missed = true; } if(wellId) outlog << " wellId"; if(zeroedTT) outlog << " zeroedTT" ; if(eliminated) outlog << " eliminatedEG8"; if(missed) outlog << " missedEG8"; if(saturates) outlog << " saturates"; outlog << endl ; // show all the trigger towers of the region if( b_mask ) { outlog << "Trigger towers of the region" << endl; vector<int> ietaTT = getEtaTT( spike_Rieta[irh] ); vector<int> iphiTT = getPhiTT( spike_Riphi[irh] ); pair<int,int> etaphi; for(int i=0 ; i<ietaTT.size() ; i++) { for(int j=0 ; j<iphiTT.size() ; j++) { etaphi = make_pair( ietaTT[i] , iphiTT[j] ); if( adcTT[etaphi].first.second != 0 ) { outlog << "ietaTT=" << ietaTT[i] << " iphiTT=" << iphiTT[j] << " adc=" << adcTT[etaphi].first.first << " adc_emul=" << adcTT[etaphi].first.second << " sFGVB=" << adcTT[etaphi].second.first << " sFGVB_emul=" << adcTT[etaphi].second.second << endl; } } } } outlog << endl; } // endif output } //endif rechit et > 8 GeV }//endif } // loop over rechits }//loop over events // show counters outlog << "COUNTING RESULTS" << endl; for(iVtx=0 ; iVtx<nVtx ; iVtx++) { outlog << "nSpikes=" << nSpikes[iVtx] << " | nSpikesWellId="<< nSpikesWellId[iVtx] //<< " | nSpikyL1EG8=" << nSpikyL1[2][iVtx] << " | nSpikyL1sat=" << nSpikyL1sat[iVtx] << endl //<< " | nLostSpikyL1EG8=" << nLostSpikyL1[2][iVtx] << " | nMatchedTT=" << nMatchedTT[iVtx] << " | nLostTT=" << nLostTT[iVtx] << " | nDiffSFGVB=" << nDiffSFGVB[iVtx] << endl << "nSpikyL1EG=["; for(int iEG=0 ; iEG<nEG ; iEG++) { outlog << nSpikyL1[iEG][iVtx] ; if(iEG<nEG-1) outlog << " ; " ; } outlog << endl << "nLostSpikyL1EG=["; for(int iEG=0 ; iEG<nEG ; iEG++) { outlog << nLostSpikyL1[iEG][iVtx] ; if(iEG<nEG-1) outlog << " ; " ; } outlog << endl; } ofstream outcount(dirOut+"counters"+halftag+".csv",ios::out); for(iVtx=0 ; iVtx<nVtx ; iVtx++) { outcount << nSpikes[iVtx] << " | " << nSpikesWellId[iVtx] << " | " << nMatchedTT[iVtx] << " | " << nLostTT[iVtx] << " | " << nDiffSFGVB[iVtx] << " | " << nSpikyL1sat[iVtx] << endl; for(int iEG=0 ; iEG<nEG ; iEG++) { outcount << nSpikyL1[iEG][iVtx] ; if(iEG<nEG-1) outcount << " | "; } outcount << endl; for(int iEG=0 ; iEG<nEG ; iEG++) { outcount << nLostSpikyL1[iEG][iVtx] ; if(iEG<nEG-1) outcount << " | "; } outcount << endl; } // plots if(debug) cout << "is gonna plot in file" << endl; // TFile *outplot = new TFile(dirOut+"spike_plots"+halftag+".root","RECREATE"); // for(iCat=0 ; iCat<nCat ; iCat++) { // for(int i=0 ; i<nHistos ; i++) { // h_adc[i][iCat]->Write(); // h_sp[i][iCat]->Write(); // h_sptp[i][iCat]->Write(); // } // } // outplot->Close(); if(debug) cout << "plotted in file" << endl; gStyle->SetPalette(1); if(debug) cout << "is gonna plot" << endl; }