static int processCommand(char *line, int no) { int ret, args; char *command = NULL; char *arg = NULL; char *arg2 = NULL; if (line == NULL) return (-1); if (line[0] == '#') return (0); args = scanCommand(line, &command, &arg, &arg2); if (args < 0) return (-1); if (args == 0) return (0); if (!strcmp(command, "connect")) { if (testState.connected) { fprintf(stderr, "connect line %d: already connected\n", no); return (-1); } if (arg != NULL) { #ifdef HAVE_SETENV setenv("GAM_CLIENT_ID", arg, 1); #elif HAVE_PUTENV char *client_id = malloc (strlen (arg) + sizeof "GAM_CLIENT_ID="); if (client_id) { strcpy (client_id, "GAM_CLIENT_ID="); strcat (client_id, arg); putenv (client_id); } #endif /* HAVE_SETENV */ } ret = FAMOpen(&(testState.fc)); if (ret < 0) { fprintf(stderr, "connect line %d: failed to connect\n", no); return (-1); } testState.connected = 1; if (arg != NULL) printf("connected to %s\n", arg); else printf("connected\n"); } else if (!strcmp(command, "kill")) { /* * okay, it's heavy but that's the simplest way since we do not have * the pid(s) of the servers running. */ ret = system("killall gam_server"); if (ret < 0) { fprintf(stderr, "kill line %d: failed to killall gam_server\n", no); return (-1); } printf("killall gam_server\n"); } else if (!strcmp(command, "disconnect")) { if (testState.connected == 0) { fprintf(stderr, "disconnect line %d: not connected\n", no); return (-1); } ret = FAMClose(&(testState.fc)); if (ret < 0) { fprintf(stderr, "connect line %d: failed to disconnect\n", no); return (-1); } testState.connected = 0; printf("disconnected\n"); } else if (!strcmp(command, "mondir")) { if (args >= 2) { if (arg[0] != '/') snprintf(filename, sizeof(filename), "%s/%s", pwd, arg); else snprintf(filename, sizeof(filename), "%s", arg); } if (args == 2) { ret = FAMMonitorDirectory(&(testState.fc), filename, &(testState. fr[testState.nb_requests]), NULL); } else if (args == 3) { int index; if (sscanf(arg2, "%d", &index) <= 0) { fprintf(stderr, "mondir line %d: invalid index value %s\n", no, arg2); return (-1); } testState.fr[testState.nb_requests].reqnum = index; ret = FAMMonitorDirectory2(&(testState.fc), filename, &(testState. fr[testState.nb_requests])); } else { fprintf(stderr, "mondir line %d: invalid format\n", no); return (-1); } if (ret < 0) { fprintf(stderr, "mondir line %d: failed to monitor %s\n", no, arg); return (-1); } printf("mondir %s %d\n", arg, testState.nb_requests); testState.nb_requests++; } else if (!strcmp(command, "monfile")) { if (args != 2) { fprintf(stderr, "monfile line %d: lacks name\n", no); return (-1); } if (arg[0] != '/') snprintf(filename, sizeof(filename), "%s/%s", pwd, arg); else snprintf(filename, sizeof(filename), "%s", arg); ret = FAMMonitorFile(&(testState.fc), filename, &(testState.fr[testState.nb_requests]), NULL); if (ret < 0) { fprintf(stderr, "monfile line %d: failed to monitor %s\n", no, arg); return (-1); } printf("monfile %s %d\n", arg, testState.nb_requests); testState.nb_requests++; } else if (!strcmp(command, "pending")) { if (args != 1) { fprintf(stderr, "pending line %d: extra argument %s\n", no, arg); return (-1); } ret = FAMPending(&(testState.fc)); if (ret < 0) { fprintf(stderr, "pending line %d: failed\n", no); return (-1); } printf("pending %d\n", ret); } else if (!strcmp(command, "mkdir")) { if (args != 2) { fprintf(stderr, "mkdir line %d: lacks name\n", no); return (-1); } ret = mkdir(arg, 0755); if (ret < 0) { fprintf(stderr, "mkdir line %d: failed to create %s\n", no, arg); return (-1); } printf("mkdir %s\n", arg); } else if (!strcmp(command, "chmod")) { if (args != 3) { fprintf(stderr, "chmod line %d: lacks path and mode\n", no); return (-1); } ret = chmod(arg, strtol (arg2, NULL, 8)); if (ret < 0) { fprintf(stderr, "chmod line %d: failed to chmod %s to %s\n", no, arg, arg2); return (-1); } printf("chmod %s to %s\n", arg, arg2); } else if (!strcmp(command, "chown")) { if (args != 3) { fprintf(stderr, "chown line %d: lacks path and owner\n", no); return (-1); } struct stat sb; if (!lstat (arg, &sb)) { ret = (S_ISLNK (sb.st_mode)) ? lchown(arg, strtol(arg2, NULL, 10), -1) : chown(arg, strtol(arg2, NULL, 10), -1); } else ret=-1; if (ret < 0) { fprintf(stderr, "chown line %d: failed to chown %s to %s\n", no, arg, arg2); return (-1); } printf("chown %s to %s\n", arg, arg2); } else if (!strcmp(command, "mkfile")) { if (args != 2) { fprintf(stderr, "mkfile line %d: lacks name\n", no); return (-1); } ret = open(arg, O_CREAT | O_WRONLY, 0666); if (ret < 0) { fprintf(stderr, "mkfile line %d: failed to open %s\n", no, arg); return (-1); } close(ret); printf("mkfile %s\n", arg); } else if (!strcmp(command, "append")) { if (args != 2) { fprintf(stderr, "mkfile line %d: lacks name\n", no); return (-1); } ret = open(arg, O_RDWR | O_APPEND); if (ret < 0) { fprintf(stderr, "append line %d: failed to open %s\n", no, arg); return (-1); } write(ret, "a", 1); close(ret); printf("append %s\n", arg); } else if (!strcmp(command, "rmdir")) { if (args != 2) { fprintf(stderr, "rmdir line %d: lacks name\n", no); return (-1); } ret = rmdir(arg); if (ret < 0) { fprintf(stderr, "rmdir line %d: failed to remove %s\n", no, arg); return (-1); } printf("rmdir %s\n", arg); } else if (!strcmp(command, "rmfile")) { if (args != 2) { fprintf(stderr, "rmfile line %d: lacks name\n", no); return (-1); } ret = unlink(arg); if (ret < 0) { fprintf(stderr, "rmfile line %d: failed to unlink %s\n", no, arg); return (-1); } printf("rmfile %s\n", arg); } else if (!strcmp(command, "move")) { if (args != 3) { fprintf(stderr, "move line %d: lacks something\n", no); return (-1); } ret = rename(arg, arg2); if (ret < 0) { fprintf(stderr, "move line %d: failed to move %s\n", no, arg); return (-1); } printf("move %s %s\n", arg, arg2); } else if (!strcmp(command, "link")) { if (args != 3) { fprintf(stderr, "link line %d: lacks target and name\n", no); return (-1); } ret = symlink(arg, arg2); if (ret < 0) { fprintf(stderr, "link line %d: failed to link to %s\n", no, arg); return (-1); } printf("link %s to %s\n", arg2, arg); } else if (!strcmp(command, "event")) { printEvent(no); } else if (!strcmp(command, "events")) { printEvents(no); } else if (!strcmp(command, "expect")) { int count; int delay = 0; int nb_events = testState.nb_events; if (args != 2) { fprintf(stderr, "expect line %d: lacks number\n", no); return (-1); } if (sscanf(arg, "%d", &count) <= 0) { fprintf(stderr, "expect line %d: invalid number value %s\n", no, arg); return (-1); } /* * wait at most 3 secs before declaring failure */ while ((delay < 30) && (testState.nb_events < nb_events + count)) { debugLoop(100); /* printf("+"); fflush(stdout); */ delay++; } if (testState.nb_events < nb_events + count) { printf("expect line %d: got %d of %d expected events\n", no, testState.nb_events - nb_events, count); return (-1); } } else if (!strcmp(command, "sleep")) { int i; for (i = 0; (i < 30) && (FAMPending(&(testState.fc)) == 0); i++) usleep(50000); } else if (!strcmp(command, "wait")) { sleep(1); } else if (!strcmp(command, "cancel")) { if (args == 2) { int req_index = 0; if (sscanf(arg, "%d", &req_index) <= 0 || req_index >= testState.nb_requests) { fprintf(stderr, "cancel line %d: invalid req_index value %s\n", no, arg); return (-1); } ret = FAMCancelMonitor(&(testState.fc), &(testState.fr[req_index])); } else { fprintf(stderr, "cancel line %d: invalid format\n", no); return (-1); } if (ret < 0) { fprintf(stderr, "cancel line %d: failed to cancel req_index %s\n", no, arg); return (-1); } printf("cancel %s %d\n", arg, testState.nb_requests); } else { fprintf(stderr, "Unable to parse line %d: %s\n", no, line); return (-1); } return (0); }
void printEvent(session* ses, const char* msg) { string msgStr(msg); printEvent(ses, msgStr); }
int process(int fd, char* watch_dir) { struct inotify_event* event; int length = 0; char buffer[BUF_SIZE]; length = read(fd, buffer, BUF_SIZE); for (int i = 0; i < length;) { event = (struct inotify_event*)(buffer + i); printf("\n"); printEvent(event); char* extension; if (event->mask & IN_DELETE_SELF) { writeWarning("Watch directory was deleted"); return 1; } else if ((extension = strstr(event->name, ".")) != NULL) { size_t name_len = strlen(watch_dir) + strlen(event->name) + 1; char* fullname = malloc(name_len); snprintf(fullname, name_len, "%s%s", watch_dir, event->name); int file_size = getFileSize(fullname); printf("File size: %d\n", file_size); if (file_size > 0) // firefox likes to create empty files for the temp files to be renamed to { printf("Extension: %s\n", extension); if (strend(extension, ".txt") || strend(extension, ".pdf")) { moveFile(fullname, "/home/calcifer/Documents"); } else if (strend(extension, ".tar.gz") || strend(extension, ".tar") || strend(extension, ".tar.bz2") || strend(extension, ".zip") || strend(extension, ".7z") || strend(extension, ".ar") || strend(extension, ".ace")) { moveFile(fullname, "/home/calcifer/Documents/archives"); } else if (strend(extension, ".deb") || strend(extension, ".rpm") || strend(extension, ".msi") || strend(extension, ".apk") || strend(extension, ".app")) { moveFile(fullname, "/home/calcifer/Documents/installers"); } else if (strend(extension, ".torrent")) { moveFile(fullname, "/home/calcifer/Downloads/torrents"); } else if (strend(extension, ".mp4") || strend(extension, ".video") || strend(extension, ".mkv") || strend(extension, ".avi")) { moveFile(fullname, "/home/calcifer/Videos"); } else if (strend(extension, ".odt") || strend(extension, ".ods") || strend(extension, ".odp") || strend(extension, ".doc") || strend(extension, ".xls") || strend(extension, ".ppt") || strend(extension, ".docx") || strend(extension, ".xlsx") || strend(extension, ".pptx")) { moveFile(fullname, "/home/calcifer/Documents/office"); } else if (strend(extension, ".ovpn")) { moveFile(fullname, "/home/calcifer/Web"); } else if (strend(extension, ".mp3")) { moveFile(fullname, "/home/calcifer/Music"); } else if (strend(extension, ".gif")) { moveFile(fullname, "/home/calcifer/Pictures/gifs"); } else if (strend(extension, ".jpg") || strend(extension, ".jpeg") || strend(extension, ".png") || strend(extension, ".bmp") || strend(extension, ".svg") || strend(extension, ".tif") || strend(extension, ".tiff")) { moveFile(fullname, "/home/calcifer/Pictures"); } else if (strend(extension, ".c") || strend(extension, ".h") || strend(extension, ".cpp") || strend(extension, ".hpp") || strend(extension, ".py") || strend(extension, ".py3") || strend(extension, ".rb") || strend(extension, ".cs") || strend(extension, ".php") || strend(extension, ".js") || strend(extension, ".html") || strend(extension, ".java")) { moveFile(fullname, "/home/calcifer/Documents/code/unorganized"); } else if (strend(extension, ".iso") || strend(extension, ".vbox") || strend(extension, ".vdi")) { moveFile(fullname, "/home/calcifer/Documents/disc-images"); } else if (strend(extension, ".desktop")) { moveFile(fullname, "/home/calcifer/Desktop"); } } free(fullname); } i += sizeof(struct inotify_event) + event->len; } return 0; // shouldn't ever be possible, infinite loop }
/****************************** arrival **************************************** void arrival(Simulation sim, Widget *pWidget) Purpose: Handles the arrival event for a given widget. In this case, just print if verbose mode is activated. Parameters: I Simulation sim Simulation running the event. I Widget *pWidget Current widget. Returns: Notes: *******************************************************************************/ void arrival(Simulation sim, Widget *pWidget) { printEvent(sim, " %6d %8ld %s", sim->iClock, pWidget->lWidgetNr, "Arrived"); }
void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArray &prefix) { if (!xml.readNextStartElement()) return; if (xml.name() != "protocol") { xml.raiseError(QStringLiteral("The file is not a wayland protocol file.")); return; } protocolName = byteArrayValue(xml, "name"); if (protocolName.isEmpty()) { xml.raiseError(QStringLiteral("Missing protocol name.")); return; } //We should convert - to _ so that the preprocessor wont generate code which will lead to unexpected behavior //However, the wayland-scanner doesn't do so we will do the same for now //QByteArray preProcessorProtocolName = QByteArray(protocolName).replace('-', '_').toUpper(); QByteArray preProcessorProtocolName = QByteArray(protocolName).toUpper(); QList<WaylandInterface> interfaces; while (xml.readNextStartElement()) { if (xml.name() == "interface") interfaces << readInterface(xml); else xml.skipCurrentElement(); } if (xml.hasError()) return; if (option == ServerHeader) { QByteArray inclusionGuard = QByteArray("QT_WAYLAND_SERVER_") + preProcessorProtocolName.constData(); printf("#ifndef %s\n", inclusionGuard.constData()); printf("#define %s\n", inclusionGuard.constData()); printf("\n"); printf("#include \"wayland-server.h\"\n"); if (headerPath.isEmpty()) printf("#include \"wayland-%s-server-protocol.h\"\n", QByteArray(protocolName).replace('_', '-').constData()); else printf("#include <%s/wayland-%s-server-protocol.h>\n", headerPath.constData(), QByteArray(protocolName).replace('_', '-').constData()); printf("#include <QByteArray>\n"); printf("#include <QMultiMap>\n"); printf("#include <QString>\n"); printf("\n"); printf("#ifndef WAYLAND_VERSION_CHECK\n"); printf("#define WAYLAND_VERSION_CHECK(major, minor, micro) \\\n"); printf(" ((WAYLAND_VERSION_MAJOR > (major)) || \\\n"); printf(" (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \\\n"); printf(" (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro)))\n"); printf("#endif\n"); printf("\n"); printf("QT_BEGIN_NAMESPACE\n"); QByteArray serverExport; if (headerPath.size()) { serverExport = QByteArray("Q_WAYLAND_SERVER_") + preProcessorProtocolName + "_EXPORT"; printf("\n"); printf("#if !defined(%s)\n", serverExport.constData()); printf("# if defined(QT_SHARED)\n"); printf("# define %s Q_DECL_EXPORT\n", serverExport.constData()); printf("# else\n"); printf("# define %s\n", serverExport.constData()); printf("# endif\n"); printf("#endif\n"); } printf("\n"); printf("namespace QtWaylandServer {\n"); for (int j = 0; j < interfaces.size(); ++j) { const WaylandInterface &interface = interfaces.at(j); if (ignoreInterface(interface.name)) continue; const char *interfaceName = interface.name.constData(); QByteArray stripped = stripInterfaceName(interface.name, prefix); const char *interfaceNameStripped = stripped.constData(); printf(" class %s %s\n {\n", serverExport.constData(), interfaceName); printf(" public:\n"); printf(" %s(struct ::wl_client *client, int id, int version);\n", interfaceName); printf(" %s(struct ::wl_display *display, int version);\n", interfaceName); printf(" %s();\n", interfaceName); printf("\n"); printf(" virtual ~%s();\n", interfaceName); printf("\n"); printf(" class Resource\n"); printf(" {\n"); printf(" public:\n"); printf(" Resource() : %s_object(0), handle(0) {}\n", interfaceNameStripped); printf(" virtual ~Resource() {}\n"); printf("\n"); printf(" %s *%s_object;\n", interfaceName, interfaceNameStripped); printf(" struct ::wl_resource *handle;\n"); printf("\n"); printf(" struct ::wl_client *client() const { return handle->client; }\n"); printf(" int version() const { return wl_resource_get_version(handle); }\n"); printf("\n"); printf(" static Resource *fromResource(struct ::wl_resource *resource) { return static_cast<Resource *>(resource->data); }\n"); printf(" };\n"); printf("\n"); printf(" void init(struct ::wl_client *client, int id, int version);\n"); printf(" void init(struct ::wl_display *display, int version);\n"); printf("\n"); printf(" Resource *add(struct ::wl_client *client, int version);\n"); printf(" Resource *add(struct ::wl_client *client, int id, int version);\n"); printf(" Resource *add(struct wl_list *resource_list, struct ::wl_client *client, int id, int version);\n"); printf("\n"); printf(" Resource *resource() { return m_resource; }\n"); printf(" const Resource *resource() const { return m_resource; }\n"); printf("\n"); printf(" QMultiMap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }\n"); printf(" const QMultiMap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }\n"); printf("\n"); printf(" bool isGlobal() const { return m_global != 0; }\n"); printf(" bool isResource() const { return m_resource != 0; }\n"); printEnums(interface.enums); bool hasEvents = !interface.events.isEmpty(); if (hasEvents) { printf("\n"); foreach (const WaylandEvent &e, interface.events) { printf(" void send_"); printEvent(e); printf(";\n"); printf(" void send_"); printEvent(e, false, true); printf(";\n"); } } printf("\n"); printf(" protected:\n"); printf(" virtual Resource *%s_allocate();\n", interfaceNameStripped); printf("\n"); printf(" virtual void %s_bind_resource(Resource *resource);\n", interfaceNameStripped); printf(" virtual void %s_destroy_resource(Resource *resource);\n", interfaceNameStripped); bool hasRequests = !interface.requests.isEmpty(); if (hasRequests) { printf("\n"); foreach (const WaylandEvent &e, interface.requests) { printf(" virtual void %s_", interfaceNameStripped); printEvent(e); printf(";\n"); } } printf("\n"); printf(" private:\n"); printf(" static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);\n"); printf(" static void destroy_func(struct ::wl_resource *client_resource);\n"); printf("\n"); printf(" Resource *bind(struct ::wl_client *client, uint32_t id, int version);\n"); if (hasRequests) { printf("\n"); printf(" static const struct ::%s_interface m_%s_interface;\n", interfaceName, interfaceName); printf("\n"); for (int i = 0; i < interface.requests.size(); ++i) { const WaylandEvent &e = interface.requests.at(i); printf(" static void "); printEventHandlerSignature(e, interfaceName); printf(";\n"); } } printf("\n"); printf(" QMultiMap<struct ::wl_client*, Resource*> m_resource_map;\n"); printf(" Resource *m_resource;\n"); printf(" struct ::wl_global *m_global;\n"); printf(" uint32_t m_globalVersion;\n"); printf(" };\n"); if (j < interfaces.size() - 1) printf("\n"); } printf("}\n"); printf("\n"); printf("QT_END_NAMESPACE\n"); printf("\n"); printf("#endif\n"); }
void ZgSelectData::Loop(Int_t eleID_index, Int_t phoID_index, Float_t DelRCut, Float_t ZMassCutL, Float_t ZMassCutU) { FILE * fZeegammaOut ; fZeegammaOut = fopen(Form("ZeegammaList.txt"),"w"); Double_t phoEtV2,phoEtaV2,a_phoEt,a_phoEta,a_Mee,a_Meeg,phoSeedTime_; // TNtuple *NTMass = new TNtuple("ntuple_mass","mll:mllg"); //photonID table TString phoID_String[]={"Poter's95","Poter's90","Poter's85","RS-Ming","Poter's70","Poter's60","EG Loose","EG Tight","QCD photon" ,"MIT","Roma","RS-Ming"}; TString eleID_String[]={"HWWRelIso60","HWWRelIso70","HWWRelIso80","HWWRelIso85","HWWRelIso90","HWWRelIso95", "RelIso60","RelIso70","RelIso80","RelIso85","RelIso90","RelIso95", "HWWRelIso60","HWWRelIso70","HWWRelIso80","HWWRelIso85","HWWRelIso90","HWWRelIso95"}; //Some Cuts Int_t NPhoLeft=0; Float_t ElePtCut=20,PhoPtCut=15; //Upper and Lower cuts for anti-selection(use for bgk) Float_t PhoHoverPreCut=0.5; //Some Variables Int_t EID_Level[100]; Int_t nWrite=0; Int_t PhoInEE=0, Ele1InEE=0, Ele2InEE=0; Int_t Ele_num=0; Int_t PassEID[100]; Int_t ele1_index=0, ele2_index=0, pho_index=0; Int_t iCheck[10]={0,0,0,0,0,0,0,0,0,0}; Float_t Leading1=0, Leading2=0; Float_t ThisValue=0; Float_t MZee=0; Float_t MC_dPhi=0, MC_dEta=0, DelR1=0, DelR2=0; Double_t MaxPhoEt(0) , MaxZee(0), MaxZeeg(0); TLorentzVector ele1,ele2,gamma,Zee,Mllg; //Histograms.. clock_t start, end ; start = clock(); if (fChain == 0) return; cout << "Total events need to run : " << fChain->GetEntries() << endl ; Long64_t nTest1=0,nTest2=0,nTest3=0; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; //Long64_t ThisRun=9999999; Int_t GoodVtx=0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; //if (nWrite>=1) break; if ( run > 166861 ) continue ; GoodVtx=0; // if (jentry % 1000000 ==1) cout<<jentry<<endl; iCheck[0]++; for (Int_t iVtx=0;iVtx<nVtx;iVtx++){ if (vtxNDF[iVtx] > 4 && fabs(vtx[iVtx][2]) <= 24 && vtxD0[iVtx] <= 2) GoodVtx++; } if (GoodVtx<1) continue; if (IsVtxGood ==0 ) continue; if (IsTracksGood ==0 ) continue; // electron and photon energy correction vector<Float_t> eleEn_ ; vector<Float_t> phoE_ ; vector<Float_t> elePt_ ; vector<Float_t> phoEt_ ; eleEn_.clear(); phoE_.clear(); elePt_.clear(); phoEt_.clear(); eleEn_ = newEleEn() ; phoE_ = newPhoEn() ; elePt_ = newElePt(eleEn_) ; phoEt_ = newPhoEt(phoE_ ) ; iCheck[1]++; Int_t eleTrg_index = -1; phoEtV2 = -999; phoEtaV2 = -999; a_phoEt = -999; a_phoEta = -999; a_Mee = -999; a_Meeg = -999; phoSeedTime_ = -9999; if (HLTIndex[121] >= 0){ // HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v1 if ( HLT[HLTIndex[121]] != 1 ) continue ; eleTrg_index = 20 ; } else if (HLTIndex[122] >= 0){ // HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v2 if ( HLT[HLTIndex[122]] != 1 ) continue ; eleTrg_index = 21 ; } else if (HLTIndex[123] >= 0){ // HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v3 if ( HLT[HLTIndex[123]] != 1 ) continue ; eleTrg_index = 22 ; } else if (HLTIndex[124] >= 0){ // HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v4 if ( HLT[HLTIndex[124]] != 1 ) continue ; eleTrg_index = 23 ; } else if (HLTIndex[125] >= 0){ // HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v5 if ( HLT[HLTIndex[125]] != 1 ) continue ; eleTrg_index = 24 ; } else { continue ; } if (eleTrg_index == -1 ) continue ; iCheck[2]++; for (Int_t ii=0;ii<100;ii++) { PassEID[ii]=-1; EID_Level[ii] = 0 ; } iCheck[3]++ ; Ele_num=0;//1 Ele1InEE=-1, Ele2InEE=-1, PhoInEE=-1; for (Int_t iEle=0;iEle<nEle;iEle++){ if ( fabs(eleSCEta[iEle]) > 2.5 ) continue; if ( fabs(eleSCEta[iEle]) > 1.4442 && fabs(eleSCEta[iEle]) < 1.566 ) continue; if ( fabs(eleSCEta[iEle]) < 1.4442 ) { if(eleSigmaIEtaIEta[iEle] < 0.002) continue; } if ( fabs(eleSCEta[iEle]) <= 1.4442 ) Ele1InEE = 0; else if (fabs(eleSCEta[iEle]) <= 2.5 && fabs(eleSCEta[iEle])>=1.566) Ele1InEE = 1; // Electron ID and trigger if (elePassID(iEle,eleID_index,elePt_) ){ EID_Level[iEle]++ ; if ( eleTrg[iEle][eleTrg_index] == 1 ) { EID_Level[iEle]++ ; } } if (EID_Level[iEle] >= 2 ) Ele_num++; } MZee=0; Ele1InEE=-1, Ele2InEE=-1, PhoInEE=-1; if (Ele_num < 2 ) continue ; // Select 2 leading electrons if (Ele_num>=2) { //pass the Z mass cut, no cut for now... Leading1=-1,Leading2=-1; ele2_index=-1,ele1_index=-1; for (Int_t i1=0; i1<nEle; i1++){ int pre_Index1 = ele1_index ; int pre_Index2 = ele2_index ; if (elePt_[i1]>Leading1 && elePt_[i1]>Leading2) { Leading2=Leading1; ele2_index=ele1_index; Leading1=elePt_[i1]; ele1_index=i1; } else if (elePt_[i1]<Leading1 && elePt_[i1]>Leading2) { Leading2=elePt_[i1]; ele2_index=i1; } // judge if this pair will pass selection if (ele1_index != -1 && ele2_index != -1){ if ( ( EID_Level[ele1_index] + EID_Level[ele2_index] < 4) || elePt_[ele1_index] < ElePtCut || elePt_[ele2_index] < ElePtCut ) { ele1_index = pre_Index1 ; ele2_index = pre_Index2 ; } } } if (ele1_index != -1 && ele2_index != -1){ ele1.SetPtEtaPhiE(elePt_[ele1_index],eleEta[ele1_index],elePhi[ele1_index],eleEn_[ele1_index]); ele2.SetPtEtaPhiE(elePt_[ele2_index],eleEta[ele2_index],elePhi[ele2_index],eleEn_[ele2_index]); Zee=ele1+ele2; MZee=Zee.M(); } else { MZee = 0. ; } } if (ele1_index == -1 || ele2_index == -1) continue ; iCheck[4]++ ; if (MZee > ZMassCutL && MZee < ZMassCutU) { iCheck[8]++; iCheck[5]++; //Photon selection pho_index=-1; ThisValue=0; NPhoLeft =0; bool flagPhoID = false ; for (Int_t iPho=0;iPho<nPho;iPho++){ if (phoEt_[iPho] < PhoPtCut) continue; if (fabs(phoSCEta[iPho]) > 2.5) continue; if (fabs(phoSCEta[iPho]) > 1.4442 && fabs(phoSCEta[iPho]) < 1.566 ) continue; if (phohasPixelSeed[iPho] == 1) continue; if (phoHoverE[iPho] > PhoHoverPreCut) continue; if (fabs(phoSCEta[iPho]) < 1.4442) { if (phoSigmaIEtaIEta[iPho]<0.002) continue; } if ( fabs(phoSCEta[iPho]) < 1.4442 ) PhoInEE = 0; else if (fabs(phoSCEta[iPho])<2.5 && fabs(phoSCEta[iPho])>1.566) PhoInEE = 1; if (PhoInEE != 1 && PhoInEE != 0) continue ; if (!phoPassID(iPho,3,phoEt_)) continue ; flagPhoID = true ; MC_dPhi=0.0; MC_dEta=0.0; DelR1=0.0; MC_dPhi = phoPhi[iPho] - elePhi[ele1_index]; if (MC_dPhi > 3.1415927) MC_dPhi -= 2*3.1415927; if (MC_dPhi < -3.1415927) MC_dPhi += 2*3.1415927; MC_dEta = phoEta[iPho] - eleEta[ele1_index]; DelR1=sqrt(MC_dEta*MC_dEta + MC_dPhi*MC_dPhi); MC_dPhi=0.0; MC_dEta=0.0; DelR2=0.0; MC_dPhi = phoPhi[iPho] - elePhi[ele2_index]; if (MC_dPhi > 3.1415927) MC_dPhi -= 2*3.1415927; if (MC_dPhi < -3.1415927) MC_dPhi += 2*3.1415927; MC_dEta = phoEta[iPho] - eleEta[ele2_index]; DelR2=sqrt(MC_dEta*MC_dEta + MC_dPhi*MC_dPhi); if (DelR1 < DelRCut || DelR2 < DelRCut) continue; if (ThisValue < phoEt_[iPho]){ NPhoLeft++; ThisValue = phoEt_[iPho]; pho_index = iPho; } } if (flagPhoID) iCheck[6]++; if (pho_index!=-1) { if ( fabs(phoSCEta[pho_index]) < 1.4442 ) PhoInEE = 0; else if (fabs(phoSCEta[pho_index]) < 2.5 && fabs(phoSCEta[pho_index]) > 1.566) PhoInEE = 1; ele1.SetPtEtaPhiE(elePt_[ele1_index],eleEta[ele1_index],elePhi[ele1_index],eleEn_[ele1_index]); ele2.SetPtEtaPhiE(elePt_[ele2_index],eleEta[ele2_index],elePhi[ele2_index],eleEn_[ele2_index]); gamma.SetPtEtaPhiE(phoEt_[pho_index],phoEta[pho_index],phoPhi[pho_index],phoE_[pho_index]); Zee=ele1+ele2; Mllg=ele1+ele2+gamma; //Fill Pho2 & Meeg1 // overFlowFill(hMeeg[0],Mllg.M(),EvtWeight); MC_dPhi=0.0; MC_dEta=0.0; DelR1=0.0; MC_dPhi = phoPhi[pho_index] - elePhi[ele1_index]; if (MC_dPhi > 3.1415927) MC_dPhi -= 2*3.1415927; if (MC_dPhi < -3.1415927) MC_dPhi += 2*3.1415927; MC_dEta = phoEta[pho_index] - eleEta[ele1_index]; DelR1=sqrt(MC_dEta*MC_dEta + MC_dPhi*MC_dPhi); MC_dPhi=0.0; MC_dEta=0.0; DelR2=0.0; MC_dPhi = phoPhi[pho_index] - elePhi[ele2_index]; if (MC_dPhi > 3.1415927) MC_dPhi -= 2*3.1415927; if (MC_dPhi < -3.1415927) MC_dPhi += 2*3.1415927; MC_dEta = phoEta[pho_index] - eleEta[ele2_index]; DelR2=sqrt(MC_dEta*MC_dEta + MC_dPhi*MC_dPhi); if (DelR1> DelRCut && DelR2>DelRCut){ // NTMass->Fill(Mllg.M(),Zee.M()); iCheck[7]++; printEvent(ele1_index,ele2_index,pho_index,elePt_) ; if (MaxPhoEt < phoEt_[pho_index]) MaxPhoEt = phoEt_[pho_index] ; if (phoEt_[pho_index] > 150. ){ cout << "checkEvent " << "nPho " << nPho ; cout << " " << phoEt_.size() << " " << " " << phoE_.size() ; cout << " phoEt " << phoEt[pho_index] << " " << phoEt_[pho_index] ; cout << " phoE " << phoE[pho_index] << " " << phoE_[pho_index] << endl ; } if (MaxZee < Zee.M() ) MaxZee = Zee.M() ; if (MaxZeeg < Mllg.M() ) MaxZeeg = Mllg.M() ; nWrite++; phoEtV2 = phoEt_[pho_index]; phoEtaV2 = phoEta[pho_index]; phoSeedTime_ = phoSeedTime[pho_index]; // tree_->Fill(); cout<<"#Zgamma:"<<setw(3)<<nWrite<<setw(8)<<"run:"<<setw(7)<<run<<setw(10)<<"event:"<<setw(12)<<event<<setw(12)<<"lumis:"<<setw(5)<<lumis<<endl; cout<<" ele1:"<<elePt_[ele1_index]<<","<<eleEta[ele1_index]<<",ele2:"<<elePt_[ele2_index]<<","<<eleEta[ele2_index]<<",pho:"<<phoEt_[pho_index]<<","<<phoEta[pho_index]<<","<<Zee.M()<<","<<Mllg.M()<<",phoSeedTime:"<<phoSeedTime[pho_index]<<",nPho:"<<NPhoLeft<<endl; fprintf(fZeegammaOut ,"#Zgamma: %d run %d event %d lumi %d\n" , nWrite , run , event , lumis ) ; // for (Int_t iHLT=0;iHLT<20;iHLT++) cout<<" iHLT:"<<iHLT<<":"<<HLTIndex[iHLT]<<endl; } } } } float passRatio[8] = { 0. } ; for (int i = 0; i < 7; i++){ passRatio[i] = (iCheck[i]==0) ? 0. : float(1.0*iCheck[i+1]/iCheck[i]) ; } cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl; cout<<"Selection information:"<<endl; cout<<"elePt : Pt > "<< ElePtCut <<" ,eleID:" << eleID_String[eleID_index] << endl; cout<<"phoPt : Pt > "<< PhoPtCut <<" ,phoID:" << phoID_String[phoID_index] << endl; cout<<"Z mass window : " << ZMassCutL <<" < MZee < "<< ZMassCutU << endl; cout<<"deltaR : dR > "<< DelRCut <<endl; cout<<"Total event : "<<iCheck[0]<<" "<<1.<<endl; cout<<"Pass event : "<<iCheck[1]<<" "<<passRatio[0]<<endl; cout<<"Pass HLT : "<<iCheck[2]<<" "<<passRatio[1]<<endl; cout<<"Fired elec : "<<iCheck[3]<<" "<<passRatio[2]<<endl ; cout<<"Pass EleID : "<<iCheck[4]<<" "<<passRatio[3]<<endl; cout<<"Pass mass : "<<iCheck[5]<<" "<<passRatio[4]<<endl; cout<<"Pass PhoID : "<<iCheck[6]<<" "<<passRatio[5]<<endl; cout<<"Pass dR : "<<iCheck[7]<<" "<<passRatio[6]<<endl; cout<<"Found Zee+gamma candidades:"<<nWrite<<endl; cout<<"Max phoEt : "<< MaxPhoEt << endl ; cout<<"Max phoZee : "<< MaxZee << endl ; cout<<"Max phoZeeg : "<< MaxZeeg << endl ; cout<<"ZMass pairs : "<<iCheck[8]<<endl ; //cout<<ThisRun<<endl; cout<<"Save Anti:"<<nTest1<<",Zg:"<<nTest2<<",All:"<<nTest3<<endl; cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl; fclose (fZeegammaOut ) ; end = clock(); double dif = (double)( end - start) / CLOCKS_PER_SEC ; cout << "Execute time = " << dif << " s" << endl ; }
void processEvent(event e, char* eventType) { printEvent(e, eventType); }
void EffectHunter::collectFPS() { long fpsSum = 0; bool firstDamageFlag = true; XDamageCreate(mXWindowDisplay, mWinId, XDamageReportRawRectangles); int damageEvt, damageErr; if (!XDamageQueryExtension (mXWindowDisplay, &damageEvt, &damageErr)) { std::cerr << "not support damage\n"; exit(-1); } XEvent e; if (mMode == SAMPLE_FPS || mMode == SAMPLE_FPS_JITTERNESS) { struct itimerval itVal; itVal.it_interval.tv_sec = 1; itVal.it_interval.tv_usec = 0; itVal.it_value.tv_sec = 1; itVal.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itVal, NULL); XSync(mXWindowDisplay, true); while (!mTermFlag) { XNextEvent(mXWindowDisplay, &e); if (e.type == (damageEvt + XDamageNotify)) { if (mMode == SAMPLE_FPS_JITTERNESS) { printEvent(&e); } mFPS++; } } itVal.it_interval.tv_sec = 0; itVal.it_interval.tv_usec = 0; itVal.it_value.tv_sec = 0; itVal.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itVal, NULL);; std::cout << " [Info]: Sampling finished." << std::endl; for(int i=0; i<mSampleCount; i++) { fpsSum += mFPSs[i]; } std::cout << " [Info]: Average FPS - " << (double)fpsSum/mSampleCount << std::endl; } else if (mMode == SAMPLE_TIMESTAMP) { XSync(mXWindowDisplay, true); while (!mTermFlag) { XNextEvent(mXWindowDisplay, &e); if (e.type == (damageEvt + XDamageNotify)) { //printEvent(&e); gettimeofday(mLastXDamageEventTimeStamp, NULL); if (firstDamageFlag) { mFirstXDamageEventTimeStamp->tv_sec = mLastXDamageEventTimeStamp->tv_sec; mFirstXDamageEventTimeStamp->tv_usec = mLastXDamageEventTimeStamp->tv_usec; firstDamageFlag = false; } } } } }