void DataFlowTrace::Init(const std::string &DirPath, const std::string &FocusFunction) { if (DirPath.empty()) return; const char *kFunctionsTxt = "functions.txt"; Printf("INFO: DataFlowTrace: reading from '%s'\n", DirPath.c_str()); Vector<SizedFile> Files; GetSizedFilesFromDir(DirPath, &Files); std::string L; // Read functions.txt std::ifstream IF(DirPlusFile(DirPath, kFunctionsTxt)); size_t FocusFuncIdx = SIZE_MAX; size_t NumFunctions = 0; while (std::getline(IF, L, '\n')) { NumFunctions++; if (FocusFunction == L) FocusFuncIdx = NumFunctions - 1; } if (!NumFunctions || FocusFuncIdx == SIZE_MAX || Files.size() <= 1) return; // Read traces. size_t NumTraceFiles = 0; size_t NumTracesWithFocusFunction = 0; for (auto &SF : Files) { auto Name = Basename(SF.File); if (Name == kFunctionsTxt) continue; auto ParseError = [&](const char *Err) { Printf("DataFlowTrace: parse error: %s\n File: %s\n Line: %s\n", Err, Name.c_str(), L.c_str()); }; NumTraceFiles++; // Printf("=== %s\n", Name.c_str()); std::ifstream IF(SF.File); while (std::getline(IF, L, '\n')) { size_t SpacePos = L.find(' '); if (SpacePos == std::string::npos) return ParseError("no space in the trace line"); if (L.empty() || L[0] != 'F') return ParseError("the trace line doesn't start with 'F'"); size_t N = std::atol(L.c_str() + 1); if (N >= NumFunctions) return ParseError("N is greater than the number of functions"); if (N == FocusFuncIdx) { NumTracesWithFocusFunction++; const char *Beg = L.c_str() + SpacePos + 1; const char *End = L.c_str() + L.size(); assert(Beg < End); size_t Len = End - Beg; Vector<uint8_t> V(Len); for (size_t I = 0; I < Len; I++) { if (Beg[I] != '0' && Beg[I] != '1') ParseError("the trace should contain only 0 or 1"); V[I] = Beg[I] == '1'; } Traces[Name] = V; // Print just a few small traces. if (NumTracesWithFocusFunction <= 3 && Len <= 16) Printf("%s => |%s|\n", Name.c_str(), L.c_str() + SpacePos + 1); break; // No need to parse the following lines. } } } assert(NumTraceFiles == Files.size() - 1); Printf("INFO: DataFlowTrace: %zd trace files, %zd functions, " "%zd traces with focus function\n", NumTraceFiles, NumFunctions, NumTracesWithFocusFunction); }
void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill) { level_info_t *nextinfo = NULL; if (unloading) { Printf (TEXTCOLOR_RED "Unloading scripts cannot exit the level again.\n"); return; } if (gameaction == ga_completed && !(i_compatflags2 & COMPATF2_MULTIEXIT)) // do not exit multiple times. { return; } if (levelname == NULL || *levelname == 0) { // end the game levelname = NULL; if (!level.NextMap.Compare("enDSeQ",6)) { nextlevel = level.NextMap; // If there is already an end sequence please leave it alone! } else { nextlevel.Format("enDSeQ%04x", int(gameinfo.DefaultEndSequence)); } } else if (strncmp(levelname, "enDSeQ", 6) != 0) { FString reallevelname = levelname; CheckWarpTransMap(reallevelname, true); nextinfo = FindLevelInfo (reallevelname, false); if (nextinfo != NULL) { level_info_t *nextredir = nextinfo->CheckLevelRedirect(); if (nextredir != NULL) { nextinfo = nextredir; } nextlevel = nextinfo->MapName; } else { nextlevel = levelname; } } else { nextlevel = levelname; } if (nextSkill != -1) NextSkill = nextSkill; if (flags & CHANGELEVEL_NOINTERMISSION) { level.flags |= LEVEL_NOINTERMISSION; } cluster_info_t *thiscluster = FindClusterInfo (level.cluster); cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL; startpos = position; gameaction = ga_completed; if (nextinfo != NULL) { if (thiscluster != nextcluster || (thiscluster && !(thiscluster->flags & CLUSTER_HUB))) { if (nextinfo->flags2 & LEVEL2_RESETINVENTORY) { flags |= CHANGELEVEL_RESETINVENTORY; } if (nextinfo->flags2 & LEVEL2_RESETHEALTH) { flags |= CHANGELEVEL_RESETHEALTH; } } } changeflags = flags; bglobal.End(); //Added by MC: // [RH] Give scripts a chance to do something unloading = true; FBehavior::StaticStartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true); unloading = false; STAT_ChangeLevel(nextlevel); if (thiscluster && (thiscluster->flags & CLUSTER_HUB)) { if ((level.flags & LEVEL_NOINTERMISSION) || (nextcluster == thiscluster)) NoWipe = 35; D_DrawIcon = "TELEICON"; } for(int i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { player_t *player = &players[i]; // Un-crouch all players here. player->Uncrouch(); // If this is co-op, respawn any dead players now so they can // keep their inventory on the next map. if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn) && !deathmatch && player->playerstate == PST_DEAD) { // Copied from the end of P_DeathThink [[ player->cls = NULL; // Force a new class if the player is using a random class player->playerstate = PST_REBORN; if (player->mo->special1 > 2) { player->mo->special1 = 0; } // ]] G_DoReborn(i, false); } } } }
void Uprintf(char *string, int length, int num_1, int num_2, int num_3, int num_4) { Printf(string, length, (num_1 * 100000) + num_2, (num_3 * 100000) + num_4); }
int res_send(struct SocketBase * libPtr, const char * buf, int buflen, char * answer, int anslen) { register int n; int try, v_circuit, resplen, nscount; int gotsomewhere = 0, connected = 0; int connreset = 0; u_short id, len; char *cp; fd_set dsmask; struct timeval timeout; struct in_addr *ns; struct sockaddr_in host; HEADER *hp = (HEADER *) buf; HEADER *anhp = (HEADER *) answer; u_char terrno = ETIMEDOUT; #define JUNK_SIZE 512 char junk[JUNK_SIZE]; /* buffer for trash data */ #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send()\n")); D(bug("[AROSTCP](res_send.c) res_send: using socket %d\n", res_sock)); #endif #ifdef RES_DEBUG printf("res_send()\n"); __p_query(buf, libPtr); #endif /* RES_DEBUG */ v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ; id = hp->id; /* * Send request, RETRY times, or until successful */ for (try = 0; try < _res.retry; try++) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Attempt %d\n", try)); #endif nscount = 0; DRES(Printf("Retry #%ld\n",try);) for (ns = _res.nsaddr_list; ns->s_addr; ns++) { nscount++; #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Querying server #%ld address = %s\n", nscount, __inet_ntoa(ns->s_addr, libPtr))); #endif #ifdef RES_DEBUG Printf("Querying server #%ld address = %s\n", nscount, __Inet_NtoA(ns->s_addr, libPtr)); #endif /* RES_DEBUG */ host.sin_len = sizeof(host); host.sin_family = AF_INET; host.sin_port = htons(NAMESERVER_PORT); host.sin_addr.s_addr = ns->s_addr; aligned_bzero_const(&host.sin_zero, sizeof(host.sin_zero)); usevc: if (v_circuit) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Using v_circuit\n")); #endif int truncated = 0; /* * Use virtual circuit; * at most one attempt per server. */ try = _res.retry; if (res_sock < 0) { res_sock = __socket(AF_INET, SOCK_STREAM, 0, libPtr); if (res_sock < 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Failed to create socket!!\n")); terrno = readErrnoValue(libPtr); #endif #ifdef RES_DEBUG Perror("socket (vc)"); #endif /* RES_DEBUG */ continue; } #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: created socket %d\n", res_sock)); #endif if (__connect(res_sock, (struct sockaddr *)&host, sizeof(struct sockaddr), libPtr) < 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Failed to connect\n")); #endif terrno = readErrnoValue(libPtr); #ifdef RES_DEBUG Perror("connect (vc)"); #endif /* RES_DEBUG */ (void) __CloseSocket(res_sock, libPtr); res_sock = -1; continue; } } /* * Send length & message */ len = htons((u_short)buflen); if ((__send(res_sock, (char *)&len, sizeof(len), 0, libPtr) != sizeof(len)) || ((__send(res_sock, (char *)buf, buflen, 0, libPtr) != buflen))) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Failed sending query\n")); #endif terrno = readErrnoValue(libPtr); #ifdef RES_DEBUG Perror("write(vc)"); #endif /* RES_DEBUG */ (void) __CloseSocket(res_sock, libPtr); res_sock = -1; continue; } /* * Receive length & response */ cp = answer; len = sizeof(short); while (len != 0 && (n = __recv(res_sock, (char *)cp, (int)len, 0, libPtr)) > 0) { cp += n; len -= n; } if (n <= 0) { terrno = readErrnoValue(libPtr); #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Failed recieving response\n")); #endif #ifdef RES_DEBUG Perror("read (vc)"); #endif /* RES_DEBUG */ (void) __CloseSocket(res_sock, libPtr); res_sock = -1; /* * A long running process might get its TCP * connection reset if the remote server was * restarted. Requery the server instead of * trying a new one. When there is only one * server, this means that a query might work * instead of failing. We only allow one reset * per query to prevent looping. */ if (terrno == ECONNRESET && !connreset) { connreset = 1; ns--; } continue; } cp = answer; if ((resplen = ntohs(*(u_short *)cp)) > anslen) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Truncated response\n")); #endif #ifdef RES_DEBUG Printf("response truncated\n"); #endif /* RES_DEBUG */ len = anslen; truncated = 1; } else len = resplen; while (len != 0 && (n = __recv(res_sock, (char *)cp, (int)len, 0, libPtr)) > 0) { cp += n; len -= n; } if (n <= 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Error recieving response\n")); #endif terrno = readErrnoValue(libPtr); #ifdef RES_DEBUG Perror("read (vc)"); #endif /* RES_DEBUG */ (void) __CloseSocket(res_sock, libPtr); res_sock = -1; continue; } if (truncated) { /* * Flush rest of answer * so connection stays in synch. */ anhp->tc = 1; len = resplen - anslen; while (len != 0) { n = (len > JUNK_SIZE ? JUNK_SIZE : len); if ((n = __recv(res_sock, junk, n, 0, libPtr)) > 0) len -= n; else break; } } } else { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Using datagrams\n")); #endif /* * Use datagrams. */ if (res_sock < 0) { res_sock = __socket(AF_INET, SOCK_DGRAM, 0, libPtr); if (res_sock < 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Failed to create socket\n")); #endif terrno = readErrnoValue(libPtr); #ifdef RES_DEBUG Perror("socket (dg)"); #endif /* RES_DEBUG */ continue; } } /* * I'm tired of answering this question, so: * On a 4.3BSD+ machine (client and server, * actually), sending to a nameserver datagram * port with no nameserver will cause an * ICMP port unreachable message to be returned. * If our datagram socket is "connected" to the * server, we get an ECONNREFUSED error on the next * socket operation, and select returns if the * error message is received. We can thus detect * the absence of a nameserver without timing out. * If we have sent queries to at least two servers, * however, we don't want to remain connected, * as we wish to receive answers from the first * server to respond. */ #warning "TODO*: see comment here .." /* This piece of code still behaves slightly wrong in case of ECONNREFUSED error. On next retry socket will be in disconnected state and instead of getting ECONNREFUSED again we'll timeout in WaitSelect() and get ETIMEDOUT. However, this is not critical and is queued for future - Pavel Fedin*/ if (try == 0 && nscount == 1) { /* * Don't use connect if we might * still receive a response * from another server. */ if (connected == 0) { if (__connect(res_sock, (struct sockaddr *)&host, sizeof(struct sockaddr), libPtr) < 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Error connecting\n")); #endif #ifdef RES_DEBUG Perror("connect (dg)"); #endif /* RES_DEBUG */ continue; } connected = 1; } if (__send(res_sock, buf, buflen, 0, libPtr) != buflen) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Error sending\n")); #endif #ifdef RES_DEBUG Perror("send (dg)"); #endif /* RES_DEBUG */ continue; } } else { /* * Disconnect if we want to listen * for responses from more than one server. */ if (connected) { (void) __connect(res_sock, &no_addr, sizeof(no_addr), libPtr); connected = 0; } if (__sendto(res_sock, buf, buflen, 0, (struct sockaddr *)&host, sizeof(struct sockaddr), libPtr) != buflen) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: [__sendto] Error\n")); #endif #ifdef RES_DEBUG Perror("sendto (dg)"); #endif /* RES_DEBUG */ continue; } } /* * Wait for reply */ timeout.tv_sec = (_res.retrans << try); if (try > 0) timeout.tv_sec /= nscount; if (timeout.tv_sec <= 0) timeout.tv_sec = 1; timeout.tv_usec = 0; wait: FD_ZERO(&dsmask); FD_SET(res_sock, &dsmask); n = __WaitSelect(res_sock+1, &dsmask, NULL, NULL, &timeout, NULL, libPtr); if (n < 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: [__WaitSelect] Error\n")); #endif #ifdef RES_DEBUG Perror("select"); #endif /* RES_DEBUG */ terrno = readErrnoValue(libPtr); if (terrno == EINTR) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: closing socket\n")); #endif __CloseSocket(res_sock, libPtr); res_sock = -1; return (-1); } continue; } if (n == 0) { /* * timeout */ #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Timeout!\n")); #endif #ifdef RES_DEBUG Printf("timeout\n"); #endif /* RES_DEBUG */ #if 1 || BSD >= 43 gotsomewhere = 1; #endif continue; } if ((resplen = __recv(res_sock, answer, anslen, 0, libPtr)) <= 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Error recieving\n")); #endif #ifdef RES_DEBUG Perror("recv (dg)"); #endif /* RES_DEBUG */ continue; } gotsomewhere = 1; if (id != anhp->id) { /* * response from old query, ignore it */ #ifdef RES_DEBUG Printf("old answer:\n"); __p_query(answer, libPtr); #endif /* RES_DEBUG */ goto wait; } if (!(_res.options & RES_IGNTC) && anhp->tc) { /* * get rest of answer; * use TCP with same server. */ #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Response is truncated\n")); #endif #ifdef RES_DEBUG Printf("truncated answer\n"); #endif /* RES_DEBUG */ (void)__CloseSocket(res_sock, libPtr); res_sock = -1; v_circuit = 1; goto usevc; } } #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Recieved answer\n")); #endif #ifdef RES_DEBUG Printf("got answer:\n"); __p_query(answer, libPtr); #endif /* RES_DEBUG */ /* * If using virtual circuits, we assume that the first server * is preferred * over the rest (i.e. it is on the local * machine) and only keep that one open. * If we have temporarily opened a virtual circuit, * or if we haven't been asked to keep a socket open, * close the socket. */ if ((v_circuit && ((_res.options & RES_USEVC) == 0 || ns->s_addr != 0)) || (_res.options & RES_STAYOPEN) == 0) { #if defined(__AROS__) D(bug("[AROSTCP](res_send.c) res_send: Closing socket\n")); #endif (void) __CloseSocket(res_sock, libPtr); res_sock = -1; } return (resplen); }
void main_makeOCDB(Int_t runNumber, TString targetOCDBstorage="", TString sourceOCDBstorage="raw://", Int_t detectorBitsQualityFlag = -1) { // // extract OCDB entries for detectors participating in the calibration for the current run // // switch off log info AliLog::SetClassDebugLevel("AliESDEvent",0); // config GRP printf("runNumber from runCalibTrain = %d\n",runNumber); ConfigCalibTrain(runNumber, sourceOCDBstorage.Data()); // check the presence of the detectors AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data"); AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject()); if (!grpData) {printf("Failed to get GRP data for run %d",runNumber); return;} Int_t activeDetectors = grpData->GetDetectorMask(); TString detStr = AliDAQ::ListOfTriggeredDetectors(activeDetectors); printf("Detectors in the data:\n%s\n",detStr.Data()); TString LHCperiod = grpData->GetLHCPeriod(); Bool_t isLHC10 = LHCperiod.Contains("LHC10"); Bool_t isLHC11 = LHCperiod.Contains("LHC11"); Bool_t isLHC12 = LHCperiod.Contains("LHC12"); Bool_t isLHC13 = LHCperiod.Contains("LHC13"); Bool_t isLHC13b = LHCperiod.Contains("LHC13b"); Bool_t isLHC13c = LHCperiod.Contains("LHC13c"); printf("LHCperiod:%s\n isLHC10:%d isLHC11:%d isLHC12:%d isLHC13:%d isLHC13b:%d isLHC13c:%d\n",LHCperiod.Data(),(Int_t)isLHC10,(Int_t)isLHC11,(Int_t)isLHC12,(Int_t)isLHC13,(Int_t)isLHC13b,(Int_t)isLHC13c); TString beamtype=grpData->GetBeamType(); // Steering Tasks - set output storage // DefaultStorage set already before - in ConfigCalibTrain.C // Setting the mirror SEs for the default storage TString mirrorsStr(gSystem->Getenv("MIRRORSE") ? gSystem->Getenv("MIRRORSE") : "ALICE::CERN::OCDB,ALICE::FZK::SE,ALICE::CNAF::SE"); AliCDBManager::Instance()->SetMirrorSEs(mirrorsStr.Data()); printf("List of mirror SEs set to: \"%s\"\n",mirrorsStr.Data()); // activate target OCDB storage AliCDBStorage* targetStorage = 0x0; if (targetOCDBstorage.Length()==0) { targetOCDBstorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; targetStorage = AliCDBManager::Instance()->GetStorage(targetOCDBstorage.Data()); } else if (targetOCDBstorage.CompareTo("same",TString::kIgnoreCase) == 0 ){ targetStorage = AliCDBManager::Instance()->GetDefaultStorage(); } else { targetStorage = AliCDBManager::Instance()->GetStorage(targetOCDBstorage.Data()); } printf("** targetOCDBstorage: \"%s\"\n",targetOCDBstorage.Data()); // specific storage for TPC/Calib/Correction entry if (gSystem->AccessPathName("TPC", kFileExists)==0) { AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Correction","local://"); } // Magnetic field AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField(); Double_t bz = fld->SolenoidField(); Bool_t isMagFieldON = kTRUE; if (TMath::Abs(bz)>0) { printf("Mag field is %f --> ON\n", bz); } else { isMagFieldON = kFALSE; printf("Mag field is %f --> OFF\n", bz); } // Quality flags Bool_t TPC_qf = kTRUE; Bool_t TOF_qf = kTRUE; Bool_t TRD_qf = kTRUE; Bool_t T0_qf = kTRUE; Bool_t SDD_qf = kTRUE; Bool_t SPD_qf = kTRUE; Bool_t AD_qf = kTRUE; /* // RS: commenting to sync with working version from alidaq if (detectorBitsQualityFlag != -1){ TPC_qf = ((detectorBitsQualityFlag & AliDAQ::kTPC_QF) == AliDAQ::kTPC_QF)? kTRUE : kFALSE; TOF_qf = ((detectorBitsQualityFlag & AliDAQ::kTOF_QF) == AliDAQ::kTOF_QF)? kTRUE : kFALSE; TRD_qf = ((detectorBitsQualityFlag & AliDAQ::kTRD_QF) == AliDAQ::kTRD_QF)? kTRUE : kFALSE; T0_qf = ((detectorBitsQualityFlag & AliDAQ::kT0_QF) == AliDAQ::kT0_QF)? kTRUE : kFALSE; SDD_qf = ((detectorBitsQualityFlag & AliDAQ::kSDD_QF) == AliDAQ::kSDD_QF)? kTRUE : kFALSE; SPD_qf = ((detectorBitsQualityFlag & AliDAQ::kSPD_QF) == AliDAQ::kSPD_QF)? kTRUE : kFALSE; AD_qf = ((detectorBitsQualityFlag & AliDAQ::kAD_QF) == AliDAQ::kAD_QF)? kTRUE : kFALSE; } */ Printf("Quality flags: detectorBitsQualityFlag = %d, TPC = %d, TOF = %d, TRD = %d, T0 = %d, SDD = %d, SPD = %d, AD = %d", detectorBitsQualityFlag, (Int_t)TPC_qf, (Int_t)TOF_qf, (Int_t)TRD_qf, (Int_t)T0_qf, (Int_t)SDD_qf, (Int_t)SPD_qf, (Int_t)AD_qf); // =========================================================================== // ===| TPC part |============================================================ // AliTPCPreprocessorOffline *procesTPC = 0; if (detStr.Contains("TPC") && TPC_qf){ Printf("\n******* Calibrating TPC *******"); // ===| set up residual storage |=========================================== TString targetStorageResidual="local://"+gSystem->GetFromPipe("pwd")+"/OCDB"; // --- check for overwrites const TString targetStorageResidualEnv(gSystem->Getenv("targetStorageResidual")); if (!targetStorageResidualEnv.IsNull()) targetStorageResidual=targetStorageResidualEnv; AliCDBStorage *residualStorage = AliCDBManager::Instance()->GetStorage(targetStorageResidual.Data()); // ===| set up TPC calibration object |===================================== procesTPC = new AliTPCPreprocessorOffline; // ---| set up gain calibratin type |--------------------------------------- // // default is Combined Calibration + Residual QA in CPass1 // will be overwritte by mergeMakeOCDB.byComponent.perStage.sh // NOTE: This must be consistent to the settings in runCPass*.sh (runCalibTrain.C) // procesTPC->SetGainCalibrationType(AliTPCPreprocessorOffline::kResidualGainQA); // --- check for overwrites from environment variable // const TString sGainTypeFromEnv(gSystem->Getenv("TPC_CPass1_GainCalibType")); if (!sGainTypeFromEnv.IsNull()) { if (!procesTPC->SetGainCalibrationType(sGainTypeFromEnv)) { ::Fatal("makeOCDB","Could not set up gain calibration type from environment variable TPC_CPass1_GainCalibType: %s",sGainTypeFromEnv.Data()); } ::Info("makeOCDB","Setting gain calibration type from environment variable TPC_CPass1_GainCalibType: %d", Int_t(procesTPC->GetGainCalibrationType())); } // ---| switch on parameter validation |------------------------------------ procesTPC->SetTimeGainRange(0.5,5.0); if(beamtype=="A-A"){ procesTPC->SetMinTracksVdrift(100000); }else{ procesTPC->SetMinTracksVdrift(10000); if(LHCperiod.Contains("LHC16")) procesTPC->SetMaxVDriftCorr(0.2); } procesTPC->SwitchOnValidation(); // ===| Run calibration |=================================================== // // ---| Make time gain calibration |---------------------------------------- if (isMagFieldON) procesTPC->CalibTimeGain("CalibObjects.root", runNumber, runNumber, targetStorage, residualStorage); // ---| Make vdrift calibration |------------------------------------------- // ---| Disabling: now the vdrift is done in the TPC SP calibration process (but the input is still available in the CalibObjects.root file, if needed // procesTPC->CalibTimeVdrift("CalibObjects.root",runNumber, runNumber, residualStorage); } else { Printf("\n******* NOT Calibrating TPC: detStr = %s, TPC_qf = %d *******", detStr.Data(), (Int_t)TPC_qf); } // =========================================================================== // ===| TOF part |============================================================ // AliTOFAnalysisTaskCalibPass0 *procesTOF=0; if (detStr.Contains("TOF") && detStr.Contains("TPC") && TOF_qf){ procesTOF = new AliTOFAnalysisTaskCalibPass0; Printf("\n******* Calibrating TOF *******"); if (isMagFieldON) procesTOF->ProcessOutput("CalibObjects.root", targetStorage); else { printf("Not calibrating TOF in case of mag field OFF\n"); } } else { Printf("\n******* NOT Calibrating TOF: detStr = %s, TOF_qf = %d *******", detStr.Data(), (Int_t)TOF_qf); } // T0 part AliT0PreprocessorOffline *procesT0= 0; if (detStr.Contains("T0") && T0_qf) { Printf("\n******* Calibrating T0 *******"); procesT0 = new AliT0PreprocessorOffline; // Make calibration of channels offset procesT0->setDArun(100000); procesT0->Process("CalibObjects.root",runNumber, runNumber, targetStorage); } else { Printf("\n******* NOT Calibrating T0: detStr = %s, T0_qf = %d *******", detStr.Data(), (Int_t)T0_qf); } //TRD part AliTRDPreprocessorOffline *procesTRD = 0; if (detStr.Contains("TRD") && detStr.Contains("TPC") && TRD_qf){ Printf("\n******* Calibrating TRD *******"); procesTRD = new AliTRDPreprocessorOffline; if(isLHC10 || isLHC13b || isLHC13c) procesTRD->SetSwitchOnChamberStatus(kFALSE); procesTRD->SetLinearFitForVdrift(kTRUE); procesTRD->SetMinStatsVdriftT0PH(600*10); procesTRD->SetMinStatsVdriftLinear(50); procesTRD->SetMinStatsGain(600); procesTRD->SetLimitValidateNoData(140); procesTRD->SetLimitValidateBadCalib(140); procesTRD->SetMinTimeOffsetValidate(-2.1); procesTRD->SetAlternativeDriftVelocityFit(kTRUE); if((!isLHC10) && (!isLHC11) && (!isLHC12) && (!isLHC13)) { printf("Run II\n"); procesTRD->SetT0Shift1(0.2524132);// release the condition on the first bin and last bins } procesTRD->Init("CalibObjects.root"); Int_t versionVdriftUsed = procesTRD->GetVersionVdriftUsed(); Int_t subversionVdriftUsed = procesTRD->GetSubVersionVdriftUsed(); Int_t versionGainUsed = procesTRD->GetVersionGainUsed(); Int_t subversionGainUsed = procesTRD->GetSubVersionGainUsed(); Int_t versionExBUsed = procesTRD->GetVersionExBUsed(); Int_t subversionExBUsed = procesTRD->GetSubVersionExBUsed(); printf("version and subversion vdrift %d and %d\n",versionVdriftUsed,subversionVdriftUsed); printf("version and subversion gain %d and %d\n",versionGainUsed,subversionGainUsed); printf("version and subversion exb %d and %d\n",versionExBUsed,subversionExBUsed); procesTRD->Process("CalibObjects.root",runNumber,runNumber,targetStorage); } else { Printf("\n******* NOT Calibrating TRD: detStr = %s, TRD_qf = %d *******", detStr.Data(), (Int_t)TRD_qf); } //Mean Vertex AliMeanVertexPreprocessorOffline * procesMeanVtx=0; if (detStr.Contains("ITSSPD") && SPD_qf) { Printf("\n******* Calibrating MeanVertex *******"); procesMeanVtx = new AliMeanVertexPreprocessorOffline; procesMeanVtx->ProcessOutput("CalibObjects.root", targetStorage, runNumber); } else { Printf("\n******* NOT Calibrating MeanVertex: detStr = %s, SPD_qf = %d *******", detStr.Data(), (Int_t)SPD_qf); } AliAnalysisTaskADCalib *procesAD = NULL; if (detStr.Contains("AD") && AD_qf) { Printf("\n******* Calibrating AD *******"); procesAD = new AliAnalysisTaskADCalib; procesAD->ProcessOutput("CalibObjects.root", targetStorage, runNumber); } else { Printf("\n******* NOT Calibrating AD: detStr = %s, AD_qf = %d*******", detStr.Data(), (Int_t)AD_qf); } // // Print calibration status into the stdout // Int_t trdStatus = (procesTRD) ? procesTRD->GetStatus():0; Int_t tofStatus = (procesTOF) ? procesTOF->GetStatus():0; Int_t t0Status = (procesT0) ? procesT0->GetStatus():0; Int_t tpcStatus = (procesTPC) ? procesTPC->GetStatus():0; Int_t adStatus = (procesAD) ? procesAD->GetStatus():0; // printf("\n"); printf("******* CPass1 calibration status *******\n"); printf("TRD calibration status=%d\n",trdStatus); printf("TOF calibration status=%d\n",tofStatus); printf("TPC calibration status=%d\n",tpcStatus); printf("T0 calibration status=%d\n",t0Status); printf("AD calibration status=%d\n",adStatus); TTreeSRedirector *pcstream = new TTreeSRedirector("cpassStat.root","recreate"); printCalibStat(runNumber, "CalibObjects.root",pcstream); delete pcstream; return; }
void main (int argc, char *argv[]) { int numprocs = 0; // Used to store number of processes to create int i; // Loop index variable missile_code *mc; // Used to get address of shared memory page uint32 h_mem; // Used to hold handle to shared memory page sem_t s_procs_completed; // Semaphore used to wait until all spawned processes have completed char h_mem_str[10]; // Used as command-line argument to pass mem_handle to new processes char s_procs_completed_str[10]; // Used as command-line argument to pass page_mapped handle to new processes if (argc != 2) { Printf("Usage: "); Printf(argv[0]); Printf(" <number of processes to create>\n"); Exit(); } // Convert string from ascii command line argument to integer number numprocs = dstrtol(argv[1], NULL, 10); // the "10" means base 10 Printf("Creating %d processes\n", numprocs); // Allocate space for a shared memory page, which is exactly 64KB // Note that it doesn't matter how much memory we actually need: we // always get 64KB if ((h_mem = shmget()) == 0) { Printf("ERROR: could not allocate shared memory page in "); Printf(argv[0]); Printf(", exiting...\n"); Exit(); } // Map shared memory page into this process's memory space if ((mc = (missile_code *)shmat(h_mem)) == NULL) { Printf("Could not map the shared page to virtual address in "); Printf(argv[0]); Printf(", exiting..\n"); Exit(); } // Put some values in the shared memory, to be read by other processes mc->numprocs = numprocs; mc->really_important_char = 'A'; // Create semaphore to not exit this process until all other processes // have signalled that they are complete. To do this, we will initialize // the semaphore to (-1) * (number of signals), where "number of signals" // should be equal to the number of processes we're spawning - 1. Once // each of the processes has signaled, the semaphore should be back to // zero and the final sem_wait below will return. if ((s_procs_completed = sem_create(-(numprocs-1))) == SYNC_FAIL) { Printf("Bad sem_create in "); Printf(argv[0]); Printf("\n"); Exit(); } // Setup the command-line arguments for the new process. We're going to // pass the handles to the shared memory page and the semaphore as strings // on the command line, so we must first convert them from ints to strings. ditoa(h_mem, h_mem_str); ditoa(s_procs_completed, s_procs_completed_str); // Now we can create the processes. Note that you MUST end your call to // process_create with a NULL argument so that the operating system // knows how many arguments you are sending. for(i=0; i<numprocs; i++) { Printf("h_mem_str : %s semaphore_str : %s", h_mem_str, s_procs_completed_str); process_create(FILENAME_TO_RUN, h_mem_str, s_procs_completed_str, NULL); Printf("Process %d created\n", i); } // And finally, wait until all spawned processes have finished. if (sem_wait(s_procs_completed) != SYNC_SUCCESS) { Printf("Bad semaphore s_procs_completed (%d) in ", s_procs_completed); Printf(argv[0]); Printf("\n"); Exit(); } Printf("All other processes completed, exiting main process.\n"); }
static void PrintLastError () { Printf (TEXTCOLOR_RED " %s\n", strerror(errno)); }
bool FCajunMaster::LoadBots () { FScanner sc; FString tmp; bool gotteam = false; int loaded_bots = 0; bglobal.ForgetBots (); tmp = M_GetCajunPath(BOTFILENAME); if (tmp.IsEmpty()) { DPrintf ("No " BOTFILENAME ", so no bots\n"); return false; } sc.OpenFile(tmp); while (sc.GetString ()) { if (!sc.Compare ("{")) { sc.ScriptError ("Unexpected token '%s'\n", sc.String); } botinfo_t *newinfo = new botinfo_t; bool gotclass = false; memset (newinfo, 0, sizeof(*newinfo)); newinfo->info = copystring ("\\autoaim\\0\\movebob\\.25"); for (;;) { sc.MustGetString (); if (sc.Compare ("}")) break; switch (sc.MatchString (BotConfigStrings)) { case BOTCFG_NAME: sc.MustGetString (); appendinfo (newinfo->info, "name"); appendinfo (newinfo->info, sc.String); newinfo->name = copystring (sc.String); break; case BOTCFG_AIMING: sc.MustGetNumber (); newinfo->skill.aiming = sc.Number; break; case BOTCFG_PERFECTION: sc.MustGetNumber (); newinfo->skill.perfection = sc.Number; break; case BOTCFG_REACTION: sc.MustGetNumber (); newinfo->skill.reaction = sc.Number; break; case BOTCFG_ISP: sc.MustGetNumber (); newinfo->skill.isp = sc.Number; break; case BOTCFG_TEAM: { char teamstr[16]; BYTE teamnum; sc.MustGetString (); if (IsNum (sc.String)) { teamnum = atoi (sc.String); if (!TeamLibrary.IsValidTeam (teamnum)) { teamnum = TEAM_NONE; } } else { teamnum = TEAM_NONE; for (unsigned int i = 0; i < Teams.Size(); ++i) { if (stricmp (Teams[i].GetName (), sc.String) == 0) { teamnum = i; break; } } } appendinfo (newinfo->info, "team"); mysnprintf (teamstr, countof(teamstr), "%d", teamnum); appendinfo (newinfo->info, teamstr); gotteam = true; break; } default: if (stricmp (sc.String, "playerclass") == 0) { gotclass = true; } appendinfo (newinfo->info, sc.String); sc.MustGetString (); appendinfo (newinfo->info, sc.String); break; } } if (!gotclass) { // Bots that don't specify a class get a random one appendinfo (newinfo->info, "playerclass"); appendinfo (newinfo->info, "random"); } if (!gotteam) { // Same for bot teams appendinfo (newinfo->info, "team"); appendinfo (newinfo->info, "255"); } newinfo->next = bglobal.botinfo; newinfo->lastteam = TEAM_NONE; bglobal.botinfo = newinfo; loaded_bots++; } Printf ("%d bots read from %s\n", loaded_bots, BOTFILENAME); return true; }
void TextWindow::ShowListOfStyles(void) { Printf(true, "%Ft color style-name"); bool darkbg = false; Style *s; for(s = SK.style.First(); s; s = SK.style.NextAfter(s)) { Printf(false, "%Bp %Bz %Bp %Fl%Ll%f%D%s%E", darkbg ? 'd' : 'a', &s->color, darkbg ? 'd' : 'a', ScreenShowStyleInfo, s->h.v, s->DescriptionString()); darkbg = !darkbg; } Printf(true, " %Fl%Ll%fcreate a new custom style%E", &ScreenCreateCustomStyle); Printf(false, ""); RgbColor rgb = SS.backgroundColor; Printf(false, "%Ft background color (r, g, b)%E"); Printf(false, "%Ba %@, %@, %@ %Fl%D%f%Ll[change]%E", rgb.redF(), rgb.greenF(), rgb.blueF(), top[rows-1] + 2, &ScreenChangeBackgroundColor); Printf(false, ""); Printf(false, "%Ft background bitmap image%E"); if(SS.bgImage.fromFile) { Printf(false, "%Ba %Ftwidth:%E %dpx %Ftheight:%E %dpx", SS.bgImage.w, SS.bgImage.h); Printf(false, " %Ftscale:%E %# px/%s %Fl%Ll%f%D[change]%E", SS.bgImage.scale*SS.MmPerUnit(), SS.UnitName(), &ScreenChangeBackgroundImageScale, top[rows-1] + 2); Printf(false, "%Ba %Fl%Lc%fclear background image%E", &ScreenBackgroundImage); } else { Printf(false, "%Ba none - %Fl%Ll%fload background image%E", &ScreenBackgroundImage); Printf(false, " (bottom left will be center of view)"); } Printf(false, ""); Printf(false, " %Fl%Ll%fload factory defaults%E", &ScreenLoadFactoryDefaultStyles); }
void GuardNotDead() { Printf(Exception,"CCore::Video::GuardNotDead() : frame window is alive"); }
bool FCajunMaster::SpawnBot (const char *name, int color) { //COLORS static const char colors[11][17] = { "\\color\\40 cf 00", //0 = Green "\\color\\b0 b0 b0", //1 = Gray "\\color\\50 50 60", //2 = Indigo "\\color\\8f 00 00", //3 = Deep Red "\\color\\ff ff ff", //4 = White "\\color\\ff af 3f", //5 = Bright Brown "\\color\\bf 00 00", //6 = Red "\\color\\00 00 ff", //7 = Blue "\\color\\00 00 7f", //8 = Dark Blue "\\color\\ff ff 00", //9 = Yellow "\\color\\cf df 90" //10 = Bleached Bone }; botinfo_t *thebot = botinfo; int botshift = 0; if (name) { // Check if exist or already in the game. while (thebot && stricmp (name, thebot->name)) { botshift++; thebot = thebot->next; } if (thebot == NULL) { Printf ("couldn't find %s in %s\n", name, BOTFILENAME); return false; } else if (thebot->inuse == BOTINUSE_Waiting) { return false; } else if (thebot->inuse == BOTINUSE_Yes) { Printf ("%s is already in the thick\n", name); return false; } } else { //Spawn a random bot from bots.cfg if no name given. TArray<botinfo_t *> BotInfoAvailable; while (thebot) { if (thebot->inuse == BOTINUSE_No) BotInfoAvailable.Push (thebot); thebot = thebot->next; } if (BotInfoAvailable.Size () == 0) { Printf ("Couldn't spawn bot; no bot left in %s\n", BOTFILENAME); return false; } thebot = BotInfoAvailable[pr_botspawn() % BotInfoAvailable.Size ()]; botinfo_t *thebot2 = botinfo; while (thebot2) { if (thebot == thebot2) break; botshift++; thebot2 = thebot2->next; } } thebot->inuse = BOTINUSE_Waiting; Net_WriteByte (DEM_ADDBOT); Net_WriteByte (botshift); { //Set color. char concat[512]; strcpy (concat, thebot->info); if (color == NOCOLOR && bot_next_color < NOCOLOR && bot_next_color >= 0) { strcat (concat, colors[bot_next_color]); } if (TeamLibrary.IsValidTeam (thebot->lastteam)) { // Keep the bot on the same team when switching levels mysnprintf (concat + strlen(concat), countof(concat) - strlen(concat), "\\team\\%d\n", thebot->lastteam); } Net_WriteString (concat); } Net_WriteByte(thebot->skill.aiming); Net_WriteByte(thebot->skill.perfection); Net_WriteByte(thebot->skill.reaction); Net_WriteByte(thebot->skill.isp); return true; }
void GuardNoClient() { Printf(Exception,"CCore::Video::GuardNoClient() : no client is attached to a frame window"); }
void R_InitSkins (void) { FSoundID playersoundrefs[NUMSKINSOUNDS]; spritedef_t temp; int sndlumps[NUMSKINSOUNDS]; char key[65]; DWORD intname, crouchname; size_t i; int j, k, base; int lastlump; int aliasid; bool remove; PClassPlayerPawn *basetype, *transtype; key[sizeof(key)-1] = 0; i = PlayerClasses.Size () - 1; lastlump = 0; for (j = 0; j < NUMSKINSOUNDS; ++j) { playersoundrefs[j] = skinsoundnames[j][1]; } while ((base = Wads.FindLump ("S_SKIN", &lastlump, true)) != -1) { // The player sprite has 23 frames. This means that the S_SKIN // marker needs a minimum of 23 lumps after it. if (base >= Wads.GetNumLumps() - 23 || base == -1) continue; i++; for (j = 0; j < NUMSKINSOUNDS; j++) sndlumps[j] = -1; skins[i].namespc = Wads.GetLumpNamespace (base); FScanner sc(base); intname = 0; crouchname = 0; remove = false; basetype = NULL; transtype = NULL; // Data is stored as "key = data". while (sc.GetString ()) { strncpy (key, sc.String, sizeof(key)-1); if (!sc.GetString() || sc.String[0] != '=') { Printf (PRINT_BOLD, "Bad format for skin %d: %s\n", (int)i, key); break; } sc.GetString (); if (0 == stricmp (key, "name")) { strncpy (skins[i].name, sc.String, 16); for (j = 0; (size_t)j < i; j++) { if (stricmp (skins[i].name, skins[j].name) == 0) { mysnprintf (skins[i].name, countof(skins[i].name), "skin%d", (int)i); Printf (PRINT_BOLD, "Skin %s duplicated as %s\n", skins[j].name, skins[i].name); break; } } } else if (0 == stricmp (key, "sprite")) { for (j = 3; j >= 0; j--) sc.String[j] = toupper (sc.String[j]); intname = *((DWORD *)sc.String); } else if (0 == stricmp (key, "crouchsprite")) { for (j = 3; j >= 0; j--) sc.String[j] = toupper (sc.String[j]); crouchname = *((DWORD *)sc.String); } else if (0 == stricmp (key, "face")) { for (j = 2; j >= 0; j--) skins[i].face[j] = toupper (sc.String[j]); skins[i].face[3] = '\0'; } else if (0 == stricmp (key, "gender")) { skins[i].gender = D_GenderToInt (sc.String); } else if (0 == stricmp (key, "scale")) { skins[i].Scale.X = clamp(atof (sc.String), 1./65536, 256.); skins[i].Scale.Y = skins[i].Scale.X; } else if (0 == stricmp (key, "game")) { if (gameinfo.gametype == GAME_Heretic) basetype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_HereticPlayer)); else if (gameinfo.gametype == GAME_Strife) basetype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_StrifePlayer)); else basetype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_DoomPlayer)); transtype = basetype; if (stricmp (sc.String, "heretic") == 0) { if (gameinfo.gametype & GAME_DoomChex) { transtype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_HereticPlayer)); skins[i].othergame = true; } else if (gameinfo.gametype != GAME_Heretic) { remove = true; } } else if (stricmp (sc.String, "strife") == 0) { if (gameinfo.gametype != GAME_Strife) { remove = true; } } else { if (gameinfo.gametype == GAME_Heretic) { transtype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_DoomPlayer)); skins[i].othergame = true; } else if (!(gameinfo.gametype & GAME_DoomChex)) { remove = true; } } if (remove) break; } else if (0 == stricmp (key, "class")) { // [GRB] Define the skin for a specific player class int pclass = D_PlayerClassToInt (sc.String); if (pclass < 0) { remove = true; break; } basetype = transtype = PlayerClasses[pclass].Type; } else if (key[0] == '*') { // Player sound replacment (ZDoom extension) int lump = Wads.CheckNumForName (sc.String, skins[i].namespc); if (lump == -1) { lump = Wads.CheckNumForFullName (sc.String, true, ns_sounds); } if (lump != -1) { if (stricmp (key, "*pain") == 0) { // Replace all pain sounds in one go aliasid = S_AddPlayerSound (skins[i].name, skins[i].gender, playersoundrefs[0], lump, true); for (int l = 3; l > 0; --l) { S_AddPlayerSoundExisting (skins[i].name, skins[i].gender, playersoundrefs[l], aliasid, true); } } else { int sndref = S_FindSoundNoHash (key); if (sndref != 0) { S_AddPlayerSound (skins[i].name, skins[i].gender, sndref, lump, true); } } } } else { for (j = 0; j < NUMSKINSOUNDS; j++) { if (stricmp (key, skinsoundnames[j][0]) == 0) { sndlumps[j] = Wads.CheckNumForName (sc.String, skins[i].namespc); if (sndlumps[j] == -1) { // Replacement not found, try finding it in the global namespace sndlumps[j] = Wads.CheckNumForFullName (sc.String, true, ns_sounds); } } } //if (j == 8) // Printf ("Funny info for skin %i: %s = %s\n", i, key, sc.String); } } // [GRB] Assume Doom skin by default if (!remove && basetype == NULL) { if (gameinfo.gametype & GAME_DoomChex) { basetype = transtype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_DoomPlayer)); } else if (gameinfo.gametype == GAME_Heretic) { basetype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_HereticPlayer)); transtype = dyn_cast<PClassPlayerPawn>(PClass::FindActor(NAME_DoomPlayer)); skins[i].othergame = true; } else { remove = true; } } if (!remove) { skins[i].range0start = transtype->ColorRangeStart; skins[i].range0end = transtype->ColorRangeEnd; remove = true; for (j = 0; j < (int)PlayerClasses.Size (); j++) { PClassPlayerPawn *type = PlayerClasses[j].Type; if (type->IsDescendantOf (basetype) && GetDefaultByType(type)->SpawnState->sprite == GetDefaultByType(basetype)->SpawnState->sprite && type->ColorRangeStart == basetype->ColorRangeStart && type->ColorRangeEnd == basetype->ColorRangeEnd) { PlayerClasses[j].Skins.Push ((int)i); remove = false; } } } if (!remove) { if (skins[i].name[0] == 0) mysnprintf (skins[i].name, countof(skins[i].name), "skin%d", (int)i); // Now collect the sprite frames for this skin. If the sprite name was not // specified, use whatever immediately follows the specifier lump. if (intname == 0) { char name[9]; Wads.GetLumpName (name, base+1); memcpy(&intname, name, 4); } int basens = Wads.GetLumpNamespace(base); for(int spr = 0; spr<2; spr++) { spriteframewithrotate sprtemp[MAX_SPRITE_FRAMES]; memset (sprtemp, 0xFFFF, sizeof(sprtemp)); for (k = 0; k < MAX_SPRITE_FRAMES; ++k) { sprtemp[k].Flip = 0; sprtemp[k].Voxel = NULL; } int maxframe = -1; if (spr == 1) { if (crouchname !=0 && crouchname != intname) { intname = crouchname; } else { skins[i].crouchsprite = -1; break; } } for (k = base + 1; Wads.GetLumpNamespace(k) == basens; k++) { char lname[9]; DWORD lnameint; Wads.GetLumpName (lname, k); memcpy(&lnameint, lname, 4); if (lnameint == intname) { FTextureID picnum = TexMan.CreateTexture(k, FTexture::TEX_SkinSprite); bool res = R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false, sprtemp, maxframe); if (lname[6] && res) R_InstallSpriteLump (picnum, lname[6] - 'A', lname[7], true, sprtemp, maxframe); } } if (spr == 0 && maxframe <= 0) { Printf (PRINT_BOLD, "Skin %s (#%d) has no frames. Removing.\n", skins[i].name, (int)i); remove = true; break; } Wads.GetLumpName (temp.name, base+1); temp.name[4] = 0; int sprno = (int)sprites.Push (temp); if (spr==0) skins[i].sprite = sprno; else skins[i].crouchsprite = sprno; R_InstallSprite (sprno, sprtemp, maxframe); } } if (remove) { if (i < numskins-1) memmove (&skins[i], &skins[i+1], sizeof(skins[0])*(numskins-i-1)); i--; continue; } // Register any sounds this skin provides aliasid = 0; for (j = 0; j < NUMSKINSOUNDS; j++) { if (sndlumps[j] != -1) { if (j == 0 || sndlumps[j] != sndlumps[j-1]) { aliasid = S_AddPlayerSound (skins[i].name, skins[i].gender, playersoundrefs[j], sndlumps[j], true); } else { S_AddPlayerSoundExisting (skins[i].name, skins[i].gender, playersoundrefs[j], aliasid, true); } } } // Make sure face prefix is a full 3 chars if (skins[i].face[1] == 0 || skins[i].face[2] == 0) { skins[i].face[0] = 0; } } if (numskins > PlayerClasses.Size ()) { // The sound table may have changed, so rehash it. S_HashSounds (); S_ShrinkPlayerSoundLists (); } }
// // R_InstallSpriteLump // Local function for R_InitSprites. // // [RH] Removed checks for coexistance of rotation 0 with other // rotations and made it look more like BOOM's version. // static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool flipped, spriteframewithrotate *sprtemp, int &maxframe) { unsigned rotation; if (rot >= '0' && rot <= '9') { rotation = rot - '0'; } else if (rot >= 'A') { rotation = rot - 'A' + 10; } else { rotation = 17; } if (frame >= MAX_SPRITE_FRAMES || rotation > 16) { Printf (TEXTCOLOR_RED"R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan[lump]->Name.GetChars()); return false; } if ((int)frame > maxframe) maxframe = frame; if (rotation == 0) { // the lump should be used for all rotations // false=0, true=1, but array initialised to -1 // allows doom to have a "no value set yet" boolean value! int r; for (r = 14; r >= 0; r -= 2) { if (!sprtemp[frame].Texture[r].isValid()) { sprtemp[frame].Texture[r] = lump; if (flipped) { sprtemp[frame].Flip |= 1 << r; } sprtemp[frame].rotate = false; } } } else { if (rotation <= 8) { rotation = (rotation - 1) * 2; } else { rotation = (rotation - 9) * 2 + 1; } if (!sprtemp[frame].Texture[rotation].isValid()) { // the lump is only used for one rotation sprtemp[frame].Texture[rotation] = lump; if (flipped) { sprtemp[frame].Flip |= 1 << rotation; } sprtemp[frame].rotate = true; } } return true; }
void M_FindResponseFile (void) { const int limit = 100; // avoid infinite recursion int added_stuff = 0; int i = 1; while (i < Args->NumArgs()) { if (Args->GetArg(i)[0] != '@') { i++; } else { char **argv; char *file = NULL; int argc = 0; FILE *handle; int size; long argsize = 0; int index; // Any more response files after the limit will be removed from the // command line. if (added_stuff < limit) { // READ THE RESPONSE FILE INTO MEMORY handle = fopen (Args->GetArg(i) + 1,"rb"); if (!handle) { // [RH] Make this a warning, not an error. Printf ("No such response file (%s)!\n", Args->GetArg(i) + 1); } else { Printf ("Found response file %s!\n", Args->GetArg(i) + 1); fseek (handle, 0, SEEK_END); size = ftell (handle); fseek (handle, 0, SEEK_SET); file = new char[size+1]; fread (file, size, 1, handle); file[size] = 0; fclose (handle); argsize = ParseCommandLine (file, &argc, NULL); } } else { Printf ("Ignored response file %s.\n", Args->GetArg(i) + 1); } if (argc != 0) { argv = (char **)M_Malloc (argc*sizeof(char *) + argsize); argv[0] = (char *)argv + argc*sizeof(char *); ParseCommandLine (file, NULL, argv); // Create a new argument vector DArgs *newargs = new DArgs; // Copy parameters before response file. for (index = 0; index < i; ++index) newargs->AppendArg(Args->GetArg(index)); // Copy parameters from response file. for (index = 0; index < argc; ++index) newargs->AppendArg(argv[index]); // Copy parameters after response file. for (index = i + 1; index < Args->NumArgs(); ++index) newargs->AppendArg(Args->GetArg(index)); // Use the new argument vector as the global Args object. Args = newargs; if (++added_stuff == limit) { Printf("Response file limit of %d hit.\n", limit); } } else { // Remove the response file from the Args object Args->RemoveArg(i); } if (file != NULL) { delete[] file; } } } if (added_stuff > 0) { // DISPLAY ARGS Printf ("Added %d response file%s, now have %d command-line args:\n", added_stuff, added_stuff > 1 ? "s" : "", Args->NumArgs ()); for (int k = 1; k < Args->NumArgs (); k++) Printf ("%s\n", Args->GetArg (k)); } }
void TextWindow::ShowStyleInfo(void) { Printf(true, "%Fl%f%Ll(back to list of styles)%E", &ScreenShowListOfStyles); Style *s = Style::Get(shown.style); if(s->h.v < Style::FIRST_CUSTOM) { Printf(true, "%FtSTYLE %E%s ", s->DescriptionString()); } else { Printf(true, "%FtSTYLE %E%s " "[%Fl%Ll%D%frename%E/%Fl%Ll%D%fdel%E]", s->DescriptionString(), s->h.v, &ScreenChangeStyleName, s->h.v, &ScreenDeleteStyle); } Printf(true, "%Ft line stroke style%E"); Printf(false, "%Ba %Ftcolor %E%Bz %Ba (%@, %@, %@) %D%f%Ls%Fl[change]%E", &s->color, s->color.redF(), s->color.greenF(), s->color.blueF(), s->h.v, ScreenChangeStyleColor); // The line width, and its units if(s->widthAs == Style::UNITS_AS_PIXELS) { Printf(false, " %Ftwidth%E %@ %D%f%Lp%Fl[change]%E", s->width, s->h.v, &ScreenChangeStyleWidthOrTextHeight, (s->h.v < Style::FIRST_CUSTOM) ? 'w' : 'W'); } else { Printf(false, " %Ftwidth%E %s %D%f%Lp%Fl[change]%E", SS.MmToString(s->width), s->h.v, &ScreenChangeStyleWidthOrTextHeight, (s->h.v < Style::FIRST_CUSTOM) ? 'w' : 'W'); } bool widthpx = (s->widthAs == Style::UNITS_AS_PIXELS); if(s->h.v < Style::FIRST_CUSTOM) { Printf(false,"%Ba %Ftin units of %Fdpixels%E"); } else { Printf(false,"%Ba %Ftin units of %Fd" "%D%f%LW%c pixels%E " "%D%f%Lw%c %s", s->h.v, &ScreenChangeStyleYesNo, widthpx ? RADIO_TRUE : RADIO_FALSE, s->h.v, &ScreenChangeStyleYesNo, !widthpx ? RADIO_TRUE : RADIO_FALSE, SS.UnitName()); } if(s->h.v >= Style::FIRST_CUSTOM) { // The fill color, and whether contours are filled Printf(false, ""); Printf(false, "%Ft contour fill style%E"); Printf(false, "%Ba %Ftcolor %E%Bz %Ba (%@, %@, %@) %D%f%Lf%Fl[change]%E", &s->fillColor, s->fillColor.redF(), s->fillColor.greenF(), s->fillColor.blueF(), s->h.v, ScreenChangeStyleColor); Printf(false, "%Bd %D%f%Lf%c contours are filled%E", s->h.v, &ScreenChangeStyleYesNo, s->filled ? CHECK_TRUE : CHECK_FALSE); } // The text height, and its units Printf(false, ""); Printf(false, "%Ft text comment style%E"); const char *chng = (s->h.v < Style::FIRST_CUSTOM) ? "" : "[change]"; if(s->textHeightAs == Style::UNITS_AS_PIXELS) { Printf(false, "%Ba %Ftheight %E%@ %D%f%Lt%Fl%s%E", s->textHeight, s->h.v, &ScreenChangeStyleWidthOrTextHeight, chng); } else { Printf(false, "%Ba %Ftheight %E%s %D%f%Lt%Fl%s%E", SS.MmToString(s->textHeight), s->h.v, &ScreenChangeStyleWidthOrTextHeight, chng); } bool textHeightpx = (s->textHeightAs == Style::UNITS_AS_PIXELS); if(s->h.v < Style::FIRST_CUSTOM) { Printf(false,"%Bd %Ftin units of %Fdpixels"); } else { Printf(false,"%Bd %Ftin units of %Fd" "%D%f%LG%c pixels%E " "%D%f%Lg%c %s", s->h.v, &ScreenChangeStyleYesNo, textHeightpx ? RADIO_TRUE : RADIO_FALSE, s->h.v, &ScreenChangeStyleYesNo, !textHeightpx ? RADIO_TRUE : RADIO_FALSE, SS.UnitName()); } if(s->h.v >= Style::FIRST_CUSTOM) { Printf(false, "%Ba %Ftangle %E%@ %D%f%Ll%Fl[change]%E", s->textAngle, s->h.v, &ScreenChangeStyleTextAngle); Printf(false, ""); Printf(false, "%Ft text comment alignment%E"); bool neither; neither = !(s->textOrigin & (Style::ORIGIN_LEFT | Style::ORIGIN_RIGHT)); Printf(false, "%Ba " "%D%f%LL%c left%E " "%D%f%LH%c center%E " "%D%f%LR%c right%E ", s->h.v, &ScreenChangeStyleYesNo, (s->textOrigin & Style::ORIGIN_LEFT) ? RADIO_TRUE : RADIO_FALSE, s->h.v, &ScreenChangeStyleYesNo, neither ? RADIO_TRUE : RADIO_FALSE, s->h.v, &ScreenChangeStyleYesNo, (s->textOrigin & Style::ORIGIN_RIGHT) ? RADIO_TRUE : RADIO_FALSE); neither = !(s->textOrigin & (Style::ORIGIN_BOT | Style::ORIGIN_TOP)); Printf(false, "%Bd " "%D%f%LB%c bottom%E " "%D%f%LV%c center%E " "%D%f%LT%c top%E ", s->h.v, &ScreenChangeStyleYesNo, (s->textOrigin & Style::ORIGIN_BOT) ? RADIO_TRUE : RADIO_FALSE, s->h.v, &ScreenChangeStyleYesNo, neither ? RADIO_TRUE : RADIO_FALSE, s->h.v, &ScreenChangeStyleYesNo, (s->textOrigin & Style::ORIGIN_TOP) ? RADIO_TRUE : RADIO_FALSE); } if(s->h.v >= Style::FIRST_CUSTOM) { Printf(false, ""); Printf(false, " %Fd%D%f%Lv%c show these objects on screen%E", s->h.v, &ScreenChangeStyleYesNo, s->visible ? CHECK_TRUE : CHECK_FALSE); Printf(false, " %Fd%D%f%Le%c export these objects%E", s->h.v, &ScreenChangeStyleYesNo, s->exportable ? CHECK_TRUE : CHECK_FALSE); Printf(false, ""); Printf(false, "To assign lines or curves to this style,"); Printf(false, "right-click them on the drawing."); } }
void M_ScreenShot (const char *filename) { FILE *file; FString autoname; bool writepcx = (stricmp (screenshot_type, "pcx") == 0); // PNG is the default // find a file name to save it to if (filename == NULL || filename[0] == '\0') { size_t dirlen; autoname = Args->CheckValue("-shotdir"); if (autoname.IsEmpty()) { autoname = screenshot_dir; } dirlen = autoname.Len(); if (dirlen == 0) { autoname = M_GetScreenshotsPath(); dirlen = autoname.Len(); } if (dirlen > 0) { if (autoname[dirlen-1] != '/' && autoname[dirlen-1] != '\\') { autoname += '/'; } } autoname = NicePath(autoname); CreatePath(autoname); if (!FindFreeName (autoname, writepcx ? "pcx" : "png")) { Printf ("M_ScreenShot: Delete some screenshots\n"); return; } } else { autoname = filename; DefaultExtension (autoname, writepcx ? ".pcx" : ".png"); } // save the screenshot const BYTE *buffer; int pitch; ESSType color_type; screen->GetScreenshotBuffer(buffer, pitch, color_type); if (buffer != NULL) { PalEntry palette[256]; if (color_type == SS_PAL) { screen->GetFlashedPalette(palette); } file = fopen (autoname, "wb"); if (file == NULL) { Printf ("Could not open %s\n", autoname.GetChars()); screen->ReleaseScreenshotBuffer(); return; } if (writepcx) { WritePCXfile(file, buffer, palette, color_type, screen->GetWidth(), screen->GetHeight(), pitch); } else { WritePNGfile(file, buffer, palette, color_type, screen->GetWidth(), screen->GetHeight(), pitch); } fclose(file); screen->ReleaseScreenshotBuffer(); if (!screenshot_quiet) { int slash = -1; if (!longsavemessages) slash = autoname.LastIndexOfAny(":/\\"); Printf ("Captured %s\n", autoname.GetChars()+slash+1); } } else { if (!screenshot_quiet) { Printf ("Could not create screenshot.\n"); } } }
int main( void ) { struct RDArgs *rdargs; int rc = RETURN_OK; GfxBase = (struct GfxBase *) OpenLibrary( GRAPHICSNAME, 37 ); IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 37 ); if( GfxBase == NULL ) { Printf( "Unable to open %s version %ld\n", (ULONG) GRAPHICSNAME, 37 ); cleanup(); return RETURN_FAIL; } if( IntuitionBase == NULL ) { Printf( "Unable to open %s version %ld\n", (ULONG) "intuition.library", 37 ); cleanup(); return RETURN_FAIL; } rdargs = ReadArgs( TEMPLATE , (LONG *) &args, NULL ); if( rdargs != NULL ) { /* Refresh database */ if( args.refresh && !args.remove ) { ULONG id; OpenAHI(); /* First, empty the database */ for( id = AHI_NextAudioID( AHI_INVALID_ID ); id != (ULONG) AHI_INVALID_ID; id = AHI_NextAudioID( AHI_INVALID_ID ) ) { AHI_RemoveAudioMode( id ); } /* Now add all modes */ if( !AHI_LoadModeFile( "DEVS:AudioModes" ) ) { if( IS_MORPHOS ) { ULONG res; /* Be quiet here. - Piru */ APTR *windowptr = &((struct Process *) FindTask(NULL))->pr_WindowPtr; APTR oldwindowptr = *windowptr; *windowptr = (APTR) -1; res = AHI_LoadModeFile( "MOSSYS:DEVS/AudioModes" ); *windowptr = oldwindowptr; if( !res ) { if( !args.quiet ) { PrintFault( IoErr(), "AudioModes" ); } rc = RETURN_ERROR; } } else { if ( !args.quiet ) { PrintFault( IoErr(), "DEVS:AudioModes" ); } rc = RETURN_ERROR; } } } /* Load mode files */ if( args.files != NULL && !args.remove ) { int i = 0; OpenAHI(); while( args.files[i] ) { if( !AHI_LoadModeFile( args.files[i] ) && !args.quiet ) { PrintFault( IoErr(), args.files[i] ); rc = RETURN_ERROR; } i++; } } /* Remove database */ if( args.remove ) { if( args.files || args.refresh ) { PutStr( "The REMOVE switch cannot be used together with FILES or REFRESH.\n" ); rc = RETURN_FAIL; } else { ULONG id; OpenAHI(); for( id = AHI_NextAudioID( AHI_INVALID_ID ); id != (ULONG) AHI_INVALID_ID; id = AHI_NextAudioID( AHI_INVALID_ID ) ) { AHI_RemoveAudioMode( id ); } } } /* Make display mode doublescan (allowing > 28 kHz sample rates) */ if( args.dblscan ) { ULONG id; ULONG bestid = INVALID_ID; int minper = INT_MAX; struct Screen *screen = NULL; static const struct ColorSpec colorspecs[] = { { 0, 0, 0, 0 }, { 1, 0, 0, 0 }, {-1, 0, 0, 0 } }; union { struct MonitorInfo mon; struct DisplayInfo dis; } buffer; for( id = NextDisplayInfo( INVALID_ID ); id != (ULONG) INVALID_ID; id = NextDisplayInfo( id ) ) { int period; if( GetDisplayInfoData( NULL, (UBYTE*) &buffer.dis, sizeof(buffer.dis), DTAG_DISP, id ) ) { if( !(buffer.dis.PropertyFlags & (DIPF_IS_ECS | DIPF_IS_AA ) ) ) { continue; } } if( GetDisplayInfoData( NULL, (UBYTE*) &buffer.mon, sizeof(buffer.mon), DTAG_MNTR, id ) ) { period = buffer.mon.TotalColorClocks * buffer.mon.TotalRows / ( 2 * ( buffer.mon.TotalRows - buffer.mon.MinRow + 1 ) ); if( period < minper ) { minper = period; bestid = id; } } } if( bestid != (ULONG) INVALID_ID && minper < 100 ) { screen = OpenScreenTags( NULL, SA_DisplayID, bestid, SA_Colors, (ULONG) &colorspecs, TAG_DONE ); } else if( ( GfxBase->ChipRevBits0 & (GFXF_HR_DENISE | GFXF_AA_LISA ) ) != 0 ) { /* No suitable screen mode found, let's bang the hardware... Using code from Sebastiano Vigna <*****@*****.**>. */ struct Custom *custom = (struct Custom *) 0xdff000; custom->bplcon0 = 0x8211; custom->ddfstrt = 0x0018; custom->ddfstop = 0x0058; custom->hbstrt = 0x0009; custom->hsstop = 0x0017; custom->hbstop = 0x0021; custom->htotal = 0x0071; custom->vbstrt = 0x0000; custom->vsstrt = 0x0003; custom->vsstop = 0x0005; custom->vbstop = 0x001D; custom->vtotal = 0x020E; custom->beamcon0 = 0x0B88; custom->bplcon1 = 0x0000; custom->bplcon2 = 0x027F; custom->bplcon3 = 0x00A3; custom->bplcon4 = 0x0011; } if( screen != NULL ) { CloseScreen( screen ); } } FreeArgs( rdargs ); } cleanup(); return rc; }
void DumpSection(int no, FGLSection *sect) { Printf(PRINT_LOG, "Section %d, sector %d\n{\n", no, sect->sector->sectornum); for(int i = 0; i < sect->numloops; i++) { Printf(PRINT_LOG, "\tLoop %d\n\t{\n", i); FGLSectionLoop *loop = sect->GetLoop(i); for(int i = 0; i < loop->numlines; i++) { FGLSectionLine *ln = loop->GetLine(i); if (ln->sidedef != NULL) { vertex_t *v1 = V1(ln->sidedef); vertex_t *v2 = V2(ln->sidedef); double dx = FIXED2FLOAT(v2->x-v1->x); double dy = FIXED2FLOAT(v2->y-v1->y); double dx1 = FIXED2FLOAT(ln->start->x-v1->x); double dy1 = FIXED2FLOAT(ln->start->y-v1->y); double dx2 = FIXED2FLOAT(ln->end->x-v1->x); double dy2 = FIXED2FLOAT(ln->end->y-v1->y); double d = sqrt(dx*dx+dy*dy); double d1 = sqrt(dx1*dx1+dy1*dy1); double d2 = sqrt(dx2*dx2+dy2*dy2); Printf(PRINT_LOG, "\t\tLinedef %d, %s: Start (%1.2f, %1.2f), End (%1.2f, %1.2f)", ln->linedef - lines, ln->sidedef == ln->linedef->sidedef[0]? "front":"back", ln->start->x/65536.f, ln->start->y/65536.f, ln->end->x/65536.f, ln->end->y/65536.f); if (ln->otherside != -1) { Printf (PRINT_LOG, ", other side = %d", ln->otherside); } if (d1 > 0.005 || d2 < 0.995) { Printf(PRINT_LOG, ", Range = %1.3f, %1.3f", d1/d, d2/d); } } else { Printf(PRINT_LOG, "\t\tMiniseg: Start (%1.3f, %1.3f), End (%1.3f, %1.3f)\n", ln->start->x/65536.f, ln->start->y/65536.f, ln->end->x/65536.f, ln->end->y/65536.f); if (ln->otherside != -1) { Printf (PRINT_LOG, ", other side = %d", ln->otherside); } } Printf(PRINT_LOG, "\n"); } Printf(PRINT_LOG, "\t}\n"); } int prim = 1; for(unsigned i = 0; i < sect->vertices.Size(); i++) { int v = sect->vertices[i]; if (v < 0) { if (i > 0) { Printf(PRINT_LOG, "\t}\n"); } switch (v) { case -GL_TRIANGLE_FAN: Printf(PRINT_LOG, "\t%d: Triangle fan\n\t{\n", prim); break; case -GL_TRIANGLE_STRIP: Printf(PRINT_LOG, "\t%d: Triangle strip\n\t{\n", prim); break; case -GL_TRIANGLES: Printf(PRINT_LOG, "\t%d: Triangles\n\t{\n", prim); break; default: break; } prim++; } else { Printf(PRINT_LOG, "\t\tVertex %d: (%1.2f, %1.2f)\n", v, vertexes[v].x/65536.f, vertexes[v].y/65536.f); } } Printf(PRINT_LOG, "}\n\n"); }
void HHV4Vector::PrintErrors() const { std::cout << Name() << " "; Printf(" (Errors) %8.2f %8.4f %8.4f ", dE(), dEta(), dPhi()); }
void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) { int startlump; bool isdir = false; if (wadinfo == NULL) { // Does this exist? If so, is it a directory? struct stat info; if (stat(filename, &info) != 0) { Printf(TEXTCOLOR_RED "Could not stat %s\n", filename); PrintLastError(); return; } isdir = (info.st_mode & S_IFDIR) != 0; if (!isdir) { try { wadinfo = new FileReader(filename); } catch (CRecoverableError &err) { // Didn't find file Printf (TEXTCOLOR_RED "%s\n", err.GetMessage()); PrintLastError (); return; } } } Printf (" adding %s", filename); startlump = NumLumps; FResourceFile *resfile; if (!isdir) resfile = FResourceFile::OpenResourceFile(filename, wadinfo); else resfile = FResourceFile::OpenDirectory(filename); if (resfile != NULL) { DWORD lumpstart = LumpInfo.Size(); resfile->SetFirstLump(lumpstart); for (DWORD i=0; i < resfile->LumpCount(); i++) { FResourceLump *lump = resfile->GetLump(i); FWadCollection::LumpRecord *lump_p = &LumpInfo[LumpInfo.Reserve(1)]; lump_p->lump = lump; lump_p->wadnum = Files.Size(); } if (Files.Size() == IWAD_FILENUM && gameinfo.gametype == GAME_Strife && gameinfo.flags & GI_SHAREWARE) { resfile->FindStrifeTeaserVoices(); } Files.Push(resfile); for (DWORD i=0; i < resfile->LumpCount(); i++) { FResourceLump *lump = resfile->GetLump(i); if (lump->Flags & LUMPF_EMBEDDED) { FString path; path.Format("%s:%s", filename, lump->FullName.GetChars()); FileReader *embedded = lump->NewReader(); AddFile(path, embedded); } } if (hashfile) { BYTE cksum[16]; char cksumout[33]; memset(cksumout, 0, sizeof(cksumout)); FileReader *reader = wadinfo; if (reader != NULL) { MD5Context md5; reader->Seek(0, SEEK_SET); md5.Update(reader, reader->GetLength()); md5.Final(cksum); for (size_t j = 0; j < sizeof(cksum); ++j) { sprintf(cksumout + (j * 2), "%02X", cksum[j]); } fprintf(hashfile, "file: %s, hash: %s, size: %ld\n", filename, cksumout, reader->GetLength()); } else fprintf(hashfile, "file: %s, Directory structure\n", filename); for (DWORD i = 0; i < resfile->LumpCount(); i++) { FResourceLump *lump = resfile->GetLump(i); if (!(lump->Flags & LUMPF_EMBEDDED)) { reader = lump->NewReader(); MD5Context md5; md5.Update(reader, lump->LumpSize); md5.Final(cksum); for (size_t j = 0; j < sizeof(cksum); ++j) { sprintf(cksumout + (j * 2), "%02X", cksum[j]); } fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %d\n", filename, lump->FullName.IsNotEmpty() ? lump->FullName.GetChars() : lump->Name, cksumout, lump->LumpSize); delete reader; } } } return; } }
void MyMainFrame::DoSave() { //------ TGMainFrame::SaveSource() -------- Printf("Save in progress..."); SaveSource("",""); }
// const char* cDataType = "AOD", // set the analysis type, AOD or ESD //################################################## AliAnalysisManager* EmcalJetCDF ( const char* cRunPeriod = "LHC11d", // set the run period const char* cLocalFiles = "data.txt", // set the local list file const Int_t arg_sel_chg = 3145763, // "mykEMC_noGA", // physics selection const Int_t arg_sel_full = 3145763, // "mykEMC_noGA", // physics selection const Int_t mgr_mode = 0, // local = 0, proof = 1, grid = 2, mixing = 3 const Int_t alien_mode = 0, // test = 0, offline = 1, submit = 2, merge = 3, full = 4 const char* cTaskName = "CDFJets", // sets name of task manager unsigned int iNumFiles = 100, // numger of files to process from list file unsigned int iNumEvents = 999999999, // number of events to be analyzed bool bDoChargedJets = true, // enable charge jets bool bDoFullJets = false // enable full jets ) { //Load needed libs TString ListLibs = ""; // string list of loaded libs TString ListLibsExtra = ""; // string list of loaded extra libs LoadLibs( ListLibs, ListLibsExtra ); AnalysisType ManagerMode = static_cast<AnalysisType>(mgr_mode); PluginType PluginMode = static_cast<PluginType>(alien_mode); namespace CDF = PWGJE::EMCALJetTasks::AliAnalysisTaskEmcalJetCDF_NS; // shortcut to task namespace unsigned int kGridFilesPerJob = iNumFiles; // Maximum number of files per job (gives size of AOD) unsigned int kTTL = 64800 ; // Time To Live; 18h = 64800; 12h = 43200 bool bDoBackgroundSubtraction = true; bool bDoEmbedding = false; // Embeded Configuration options // Embedding files list const TString embeddedFilesList = "aodFilesEmbed.txt"; // If true, events that are not selected in the PbPb will not be used for embedding. // This ensures that good embedded events are not wasted on bad PbPb events. const bool internalEventSelection = true; // Do jet matching const bool useJetTagger = true; TString sGridMode ("test"); if ( PluginMode == PluginType::offline ) { sGridMode = "offline"; } if ( PluginMode == PluginType::submit ) { sGridMode = "submit"; } if ( PluginMode == PluginType::merge ) { sGridMode = "merge"; } if ( PluginMode == PluginType::full ) { sGridMode = "full"; } const char* cGridMode = sGridMode.Data(); TString sAnalysisType ("local"); if ( ManagerMode == AnalysisType::proof ) { sAnalysisType = "proof"; } if ( ManagerMode == AnalysisType::grid ) { sAnalysisType = "grid"; } if ( ManagerMode == AnalysisType::mixing ) { sAnalysisType = "mix"; } const char* cAnalysisType = sAnalysisType.Data(); cout << std::endl << ">>>>>>>> ManagerMode : " << ManagerMode << " ; String value : " << cAnalysisType << std::endl << ">>>>>>>> PluginMode : " << PluginMode << " ; String value : " << cGridMode << std::endl << std::endl; //--------------------------------------------------------------------------------------------- TRegexp false_regex ("[f,F][a,A][l,L][s,S][e,E]"); TRegexp true_regex ("[t,T][r,R][u,U][e,E]"); TRegexp enable_regex ("[e,E][n,N][a,A][b,B][l,L][e,E]"); TRegexp disable_regex ("[d,D][i,I][s,S][a,A][b,B][l,L][e,E]"); bool bDoSample = false; TString ENV_doSAMPLE = gSystem->Getenv("CDF_doSAMPLE"); if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("0") || ENV_doSAMPLE.Contains(false_regex) ) ) { bDoSample = kFALSE; } if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("1") || ENV_doSAMPLE.Contains(true_regex) ) ) { bDoSample = kTRUE; } bool bDoCDF = true; TString ENV_doCDF = gSystem->Getenv("CDF_doCDF"); if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("0") || ENV_doCDF.Contains(false_regex) ) ) { bDoCDF = kFALSE; } if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("1") || ENV_doCDF.Contains(true_regex) ) ) { bDoCDF = kTRUE; } // ###### DEBUG ###### Int_t debug = 0 ; // kFatal = 0, kError, kWarning, kInfo, kDebug, kMaxType UInt_t mgr_debug = 0 ; // AliAnalysisManager debug level UInt_t kUseSysInfo = 0 ; // activate debugging TString ENV_DEBUG = gSystem->Getenv("CDF_DEBUG"); if (!ENV_DEBUG.IsNull() && ENV_DEBUG.IsDigit() ) { debug = ENV_DEBUG.Atoi(); } TString ENV_DEBUG_MGR = gSystem->Getenv("CDF_DEBUG_MGR"); if (!ENV_DEBUG_MGR.IsNull() && ENV_DEBUG_MGR.IsDigit() ) { mgr_debug = ENV_DEBUG_MGR.Atoi(); } TString ENV_NSYSINFO = gSystem->Getenv("CDF_NSYSINFO"); if (!ENV_NSYSINFO.IsNull() && ENV_NSYSINFO.IsDigit() ) { kUseSysInfo = ENV_NSYSINFO.Atoi(); } if ( debug == 0 ) { AliLog::SetGlobalLogLevel ( AliLog::kFatal ); } if ( debug == 1 ) { AliLog::SetGlobalLogLevel ( AliLog::kError ); } if ( debug == 2 ) { AliLog::SetGlobalLogLevel ( AliLog::kWarning ); } if ( debug == 3 ) { AliLog::SetGlobalLogLevel ( AliLog::kInfo ); } if ( debug >= 4 ) { AliLog::SetGlobalLogLevel ( AliLog::kDebug ); } // Progress bar Bool_t bUseProgBar = kFALSE; // N.B. !! if true will set fDebug to 0 TString ENV_USEPROGBAR = gSystem->Getenv("PROGRESSBAR"); if (!ENV_USEPROGBAR.IsNull() && ( ENV_USEPROGBAR.EqualTo("1") || ENV_USEPROGBAR.Contains(true_regex) ) ) { bUseProgBar = kTRUE; } //################################################## // AliEN plugin variables //################################################## const char* curdir = gSystem->BaseName(gSystem->pwd()); TString kJobTag (curdir); TString execArgs (" -l -b -q -x"); TString exec = // "aliroot"; "root.exe"; TString kPluginExecutableCommand = exec + execArgs; TString kAliPhysicsVersion = "vAN-20190304-1"; // == grid plugin files rules TString kGridExtraFiles = ""; // extra files that will be added to the input list in the JDL TString kGridMergeExclude = "AliAOD.root AliAOD.Jets.root"; // Files that should not be merged TString kGridOutputStorages = "disk=2"; // Make replicas on the storages // FILES USED IN MACRO TString kCommonOutputFileName = "AnalysisResults.root"; //-------------------- // PROOF SETTINGS //-------------------- TString kAAF = ""; Int_t kProofReset = 0; (void)kProofReset; Int_t kWorkers = 20; (void)kWorkers; Int_t kCores = 8 ; (void)kCores; // AliRoot mode among the list supported by the proof cluster. // TString kAlirootMode = "ALIROOT"; // STEERBase,ESD,AOD,ANALYSIS,ANALYSISalice (default aliroot mode) //############################################################ // const AliAnalysisTaskEmcal::EDataType_t kAod = AliAnalysisTaskEmcal::kAOD; // const AliAnalysisTaskEmcal::EDataType_t kEsd = AliAnalysisTaskEmcal::kESD; const AliJetContainer::EJetType_t fulljet = AliJetContainer::kFullJet; const AliJetContainer::EJetType_t chgjet = AliJetContainer::kChargedJet; const AliJetContainer::EJetAlgo_t antikt = AliJetContainer::antikt_algorithm; const AliJetContainer::EJetAlgo_t kt = AliJetContainer::kt_algorithm; const AliJetContainer::ERecoScheme_t recomb = AliJetContainer::pt_scheme; // kTPC, kTPCfid, kEMCAL, kEMCALfid, kDCAL, kDCALfid, kDCALonly, kDCALonlyfid, kPHOS, kPHOSfid, kUser const AliEmcalJet::JetAcceptanceType acc_chgjets = AliEmcalJet::kTPCfid; const AliEmcalJet::JetAcceptanceType acc_fulljets = AliEmcalJet::kEMCALfid; //############################################################ // data source name TString kDataSource (cLocalFiles); // label of dataset from InputData.C TString kGridDataSet (""); if ( ManagerMode == AnalysisType::grid ) { kGridDataSet = kDataSource;} //############################################################ // SETUP OF TRIGGERS const AliEmcalPhysicsSelection::EOfflineEmcalTypes mykEMCAL = AliEmcalPhysicsSelection::kEmcalOk; const AliVEvent::EOfflineTriggerTypes mykEMC = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE | AliVEvent::kEMCEGA); const AliVEvent::EOfflineTriggerTypes mykEMC_noGA = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE); const AliVEvent::EOfflineTriggerTypes mykMB = AliVEvent::kAnyINT; const AliVEvent::EOfflineTriggerTypes mykMB_central = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral); const AliVEvent::EOfflineTriggerTypes mykMB_semicentral = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kSemiCentral); const AliVEvent::EOfflineTriggerTypes mykMB_mostcentral = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral | AliVEvent::kSemiCentral); AliVEvent::EOfflineTriggerTypes kPhysSel = mykMB; //AliVEvent::kAnyINT; // physics selection // AliVEvent::EOfflineTriggerTypes kSel_tasks = mykMB; AliVEvent::EOfflineTriggerTypes kSel_chg = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_chg); AliVEvent::EOfflineTriggerTypes kSel_full = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_full); //############################################################ // Analysis manager AliAnalysisManager* pMgr = new AliAnalysisManager(cTaskName); pMgr->SetDebugLevel(mgr_debug); if ( kUseSysInfo > 0 ) { pMgr->SetNSysInfo ( kUseSysInfo ); } // actual runName in the form of LHCXXX.... TString sRunName; Bool_t kIsAOD = kTRUE; AliAnalysisTaskEmcal::EDataType_t iDataType = AliAnalysisTaskEmcal::kAOD; // assuming default is to process AOD TString file; AliAnalysisAlien* plugin = NULL; if ( ManagerMode == AnalysisType::grid ) { // start grid analysis // ( const char* gridMode, const char* tag, unsigned int nr_test_files, unsigned int TTL, const char* outdir, const char subworkdir, const char* extradirlvl); plugin = CreateAlienHandler(cGridMode, kJobTag.Data(), kGridFilesPerJob, kTTL); if ( !plugin ) { ::Error ( "runEMCalJetSampleTask.C - StartGridAnalysis", "plugin invalid" ); return NULL; } pMgr->SetGridHandler(plugin); // use this command to run the macro plugin->SetExecutableCommand(kPluginExecutableCommand.Data()); // AliPhysics version. plugin->SetAliPhysicsVersion ( kAliPhysicsVersion.Data() ); // Here you can set the (Ali)PHYSICS version you want to use gROOT->LoadMacro("InputData.C"); InputData(kGridDataSet); sRunName = CDF::GetPeriod( plugin->GetGridDataDir() ); file = CDF::GetFileFromPath(plugin->GetDataPattern()); if (file.Contains("AliESD")) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; } plugin->SetMergeExcludes(kGridMergeExclude.Data()); } if ( ManagerMode == AnalysisType::local ) { // start local analysis if ( kDataSource.IsNull() ) { Printf("You need to provide the list of local files!"); return NULL; } TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles); if (!pChain) { std::cout << ">>>>>>>>>>>>>> CHAIN NOT CREATED <<<<<<<<<<<<<<" << std::endl; return NULL; } Printf("Setting local analysis for %d files from list %s, max events = %d", iNumFiles, kDataSource.Data(), iNumEvents); // get the path of first file file = pChain->GetFile()->GetEndpointUrl()->GetUrl(); sRunName = CDF::GetPeriod(file.Data()); // get the run name : first token beggining with lhc if ( CDF::GetFileFromPath(file).Contains("AliESD") ) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; } } TString sDataType ("AOD"); if (!kIsAOD) { sDataType = "ESD"; } std::cout << ">>> Analysis data type : " << sDataType.Data() << std::endl; // name of de period (for MC is the name of "achored to" production) TString sRunPeriod (cRunPeriod); sRunPeriod.ToLower(); bool isMC = false; isMC = CDF::PeriodIsMC(sRunName.Data()); // EMCAL corrections task configuration file TString EMCALcfg ("CDF_CorrectionsConf.yaml"); if (isMC) {EMCALcfg = "CDF_MC_CorrectionsConf.yaml";} if ( !kGridExtraFiles.IsNull() ) {kGridExtraFiles += " ";} kGridExtraFiles += EMCALcfg; AliAnalysisTaskEmcal::BeamType iBeamType = AliAnalysisTaskEmcal::kpp; Bool_t bIsRun2 = kFALSE; if (sRunPeriod.Length() == 6 && (sRunPeriod.BeginsWith("lhc15") || sRunPeriod.BeginsWith("lhc16") || sRunPeriod.BeginsWith("lhc17") || sRunPeriod.BeginsWith("lhc18") ) ) { bIsRun2 = kTRUE; } if (sRunPeriod == "lhc10h" || sRunPeriod == "lhc11h" || sRunPeriod == "lhc15o" || sRunPeriod == "lhc17n" ) { iBeamType = AliAnalysisTaskEmcal::kAA; } if (sRunPeriod == "lhc12g" || sRunPeriod == "lhc13b" || sRunPeriod == "lhc13c" || sRunPeriod == "lhc13d" || sRunPeriod == "lhc13e" || sRunPeriod == "lhc13f" || sRunPeriod == "lhc16q" || sRunPeriod == "lhc16r" || sRunPeriod == "lhc16s" || sRunPeriod == "lhc16t" ) { iBeamType = AliAnalysisTaskEmcal::kpA; } Double_t kGhostArea = 0.01; if (iBeamType != AliAnalysisTaskEmcal::kpp) { kGhostArea = 0.005; } AliTrackContainer::SetDefTrackCutsPeriod(sRunPeriod); Printf("Default track cut period set to: %s", AliTrackContainer::GetDefTrackCutsPeriod().Data()); Bool_t bDoEmcalCorrections = kFALSE; if (bDoFullJets) { bDoEmcalCorrections = kTRUE; } // ### Containers and string definitions TString name_tracks = "usedefault"; TString name_clusters = "usedefault"; TString name_cells = "usedefault"; // Set centrality estimator for centrality task TString cent_est_chg = "V0M" ; TString cent_est_full = "V0M" ; TString mc_container (""); if (isMC) { mc_container = "mcparticles"; } /* // General input object names TString tracksName = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kTrack); TString clustersName = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCluster); TString emcalCellsName = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCaloCells); // Combined (PbPb + embedded det level) TString emcalCellsCombined = emcalCellsName + "Combined"; TString clustersCombined = clustersName + "Combined"; */ //########################## // TASKS DEFINITIONS ### //########################## AliAODInputHandler* pAODHandler = NULL; AliESDInputHandler* pESDHandler = NULL; if (kIsAOD) { pAODHandler = AliAnalysisTaskEmcal::AddAODHandler(); } else { pESDHandler = AliAnalysisTaskEmcal::AddESDHandler(); } // CDBconnect task AliTaskCDBconnect* taskCDB = AliTaskCDBconnect::AddTaskCDBconnect(); taskCDB->SetFallBackToRaw(kTRUE); // Needed for the moment as not all grid sites do support cvmfs OCDB for the moment if (!taskCDB) { std::cout << "--------->>>> taskCDB :: could not connect!!!! CHECK CVMFS" << std::endl; return NULL;} // Physics selection task AliPhysicsSelectionTask* pPhysSelTask = NULL; if (!kIsAOD) { // signature : (Bool_t mCAnalysisFlag = kFALSE, Bool_t applyPileupCuts = kFALSE, UInt_t deprecatedFlag2 = 0, Bool_t useSpecialOutput=kFALSE) pPhysSelTask = AliPhysicsSelectionTask::AddTaskPhysicsSelection(); } // Centrality task // The Run 2 condition is too restrictive, but until the switch to MultSelection is complete, it is the best we can do AliCentralitySelectionTask* pCentralityTask = NULL; if ( !kIsAOD && (iBeamType != AliAnalysisTaskEmcal::kpp && bIsRun2) ) { //signature : (Bool_t fillHistos=kTRUE, Bool_t aod=kFALSE) pCentralityTask = AliCentralitySelectionTask::AddTaskCentrality(kFALSE, kIsAOD); pCentralityTask->SelectCollisionCandidates(AliVEvent::kAny); } // AliMultSelection AliMultSelectionTask* pMultSelTask = NULL; if (bIsRun2) { // signature : ( Bool_t lCalibration = kFALSE, TString lExtraOptions = "", Int_t lNDebugEstimators = 1, const TString lMasterJobSessionFlag = "") pMultSelTask = AliMultSelectionTask::AddTaskMultSelection(); pMultSelTask->SelectCollisionCandidates(AliVEvent::kAny); } // Embedding task if (bDoEmbedding) { // Debug options //AliLog::SetClassDebugLevel("AliAnalysisTaskEmcalEmbeddingHelper", AliLog::kDebug+0); // Setup embedding task AliAnalysisTaskEmcalEmbeddingHelper * embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::AddTaskEmcalEmbeddingHelper(); embeddingHelper->SelectCollisionCandidates(kPhysSel); // The pt hard bin should be set via the filenames in this file // If using a file pattern, it could be configured via embeddingHelper->SetPtHardBin(ptHardBin); embeddingHelper->SetFileListFilename(embeddedFilesList.Data()); // Some example settings for LHC12a15e_fix (anchored to LHC11h) embeddingHelper->SetNPtHardBins(11); embeddingHelper->SetMCRejectOutliers(); // Setup internal event selection and additional configuration options embeddingHelper->SetConfigurationPath("EmbeddingConfigurationExample.yaml"); // Initialize the task to complete the setup. embeddingHelper->Initialize(); } // EMCal corrections AliEmcalCorrectionTask* correctionTask = NULL; if (bDoEmcalCorrections) { // Configuration of the Correction Task is handled via a YAML file, which is setup below // signature : (TString suffix) correctionTask = AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask(); // correctionTask = AliEmcalCorrectionTask::ConfigureEmcalCorrectionTaskOnLEGOTrain(suffix); correctionTask->SelectCollisionCandidates(kPhysSel); correctionTask->SetUseNewCentralityEstimation(bIsRun2); correctionTask->SetForceBeamType(static_cast<AliEmcalCorrectionTask::BeamType>(iBeamType)); // Configure and initialize correctionTask->SetUserConfigurationFilename( EMCALcfg.Data() ); //correctionTask->SetUserConfigurationFilename("alien:///alice/cern.ch/user/m/mfasel/EMCALCorrectionConfig/ConfigDataPWGJEhighClusterThresholds.yaml"); correctionTask->Initialize(true); } // TObjArray correctionTasks; // // // Create the Correction Tasks // // "data" corresponds to the PbPb level // // "embed" corresponds to the embedded detector level // // "combined" corresponds to the hybrid (PbPb + embedded detector) level // correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("data")); // correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("embed")); // // It is important that combined is last! // correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("combined")); // // // Loop over all of the correction tasks to configure them // AliEmcalCorrectionTask * tempCorrectionTask = 0; // TIter next(&correctionTasks); // while (( tempCorrectionTask = static_cast<AliEmcalCorrectionTask *>(next()))) { // tempCorrectionTask->SelectCollisionCandidates(kPhysSel); // // Configure centrality // tempCorrectionTask->SetNCentBins(5); // tempCorrectionTask->SetUseNewCentralityEstimation(bIsRun2); // tempCorrectionTask->SetUserConfigurationFilename("$ALICE_PHYSICS/PWGJE/EMCALJetTasks/macros/EMCalCorrectionTaskEmbeddingExample.yaml"); // // tempCorrectionTask->Initialize(true); // } // Background TString sRhoChName; TString sRhoFuName; AliAnalysisTaskRho* pRhoTask = NULL; if ( bDoBackgroundSubtraction && iBeamType != AliAnalysisTaskEmcal::kpp ) { sRhoChName = "Rho"; sRhoFuName = "Rho_Scaled"; AliEmcalJetTask* pKtChJetTask = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", kt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 0., kFALSE, kFALSE); pKtChJetTask->SelectCollisionCandidates(kPhysSel); //signature : // const char* nTracks = "usedefault", const char* nClusters = "usedefault", const char* nRho = "Rho", Double_t jetradius = 0.2, UInt_t acceptance = AliEmcalJet::kTPCfid, // AliJetContainer::EJetType_t jetType = AliJetContainer::kChargedJet, const Bool_t histo = kFALSE, AliJetContainer::ERecoScheme_t rscheme = AliJetContainer::pt_scheme, const char* suffix = "" pRhoTask = AliAnalysisTaskRho::AddTaskRhoNew(name_tracks.Data(), name_clusters.Data(), sRhoChName, 0.4); pRhoTask->SetExcludeLeadJets(2); pRhoTask->SelectCollisionCandidates(kPhysSel); pRhoTask->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection); if (bDoFullJets) { TString sFuncPath = "alien:///alice/cern.ch/user/s/saiola/LHC11h_ScaleFactorFunctions.root"; TString sFuncName = "LHC11h_HadCorr20_ClustersV2"; pRhoTask->LoadRhoFunction(sFuncPath, sFuncName); } } // Find Charged jets AliEmcalJetTask* pChJet02Task = NULL; AliEmcalJetTask* pChJet04Task = NULL; AliEmcalJetTask* pChJet02Task_MC = NULL; AliEmcalJetTask* pChJet04Task_MC = NULL; if (bDoChargedJets) { pChJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pChJet02Task->SelectCollisionCandidates(kSel_chg); pChJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pChJet04Task->SelectCollisionCandidates(kSel_chg); if (isMC) { pChJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pChJet02Task_MC->SelectCollisionCandidates(kSel_chg); if (bDoEmbedding) { pChJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection); AliParticleContainer* partLevelTracks02Task_MC = pChJet02Task_MC->GetParticleContainer(0); // Called Embedded, but really just means get from an external event! partLevelTracks02Task_MC->SetIsEmbedding(kTRUE); } pChJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pChJet04Task_MC->SelectCollisionCandidates(kSel_chg); if (bDoEmbedding) { pChJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection); AliParticleContainer* partLevelTracks04Task_MC = pChJet04Task_MC->GetParticleContainer(0); // Called Embedded, but really just means get from an external event! partLevelTracks04Task_MC->SetIsEmbedding(kTRUE); } } // isMC } // bDoChargedJets // Find Full jets AliEmcalJetTask* pFuJet02Task = NULL; AliEmcalJetTask* pFuJet04Task = NULL; AliEmcalJetTask* pFuJet02Task_MC = NULL; AliEmcalJetTask* pFuJet04Task_MC = NULL; if (bDoFullJets) { pFuJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pFuJet02Task->SelectCollisionCandidates(kSel_full); pFuJet02Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr); pFuJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pFuJet04Task->SelectCollisionCandidates(kSel_full); pFuJet04Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr); if (isMC) { pFuJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pFuJet02Task_MC->SelectCollisionCandidates(kSel_chg); if (bDoEmbedding) { pFuJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection); AliParticleContainer* partLevelTracks02Task_MC = pFuJet02Task_MC->GetParticleContainer(0); // Called Embedded, but really just means get from an external event! partLevelTracks02Task_MC->SetIsEmbedding(kTRUE); } pFuJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE); pFuJet04Task_MC->SelectCollisionCandidates(kSel_chg); pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection); if (bDoEmbedding) { pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection); AliParticleContainer* partLevelTracks04Task_MC = pFuJet04Task_MC->GetParticleContainer(0); // Called Embedded, but really just means get from an external event! partLevelTracks04Task_MC->SetIsEmbedding(kTRUE); } } // isMC } // bDoFullJets //////////////////////// // ANALYSIS TASKS // //////////////////////// // Sample task - charge jets AliAnalysisTaskEmcalJetSample* sampleTaskchg = NULL; if (bDoSample && bDoChargedJets) { sampleTaskchg = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), "", "", "SMPCHG"); sampleTaskchg->SetHistoBins(600, 0, 300); sampleTaskchg->SelectCollisionCandidates(kSel_chg); sampleTaskchg->SetDebugLevel(debug); AliParticleContainer* sampleTaskchg_partCont = sampleTaskchg->GetParticleContainer(0); sampleTaskchg_partCont->SetParticlePtCut(0.15); if (bDoEmbedding) { sampleTaskchg_partCont->SetIsEmbedding(kTRUE); } if ( pMultSelTask ) { sampleTaskchg->SetUseNewCentralityEstimation(bIsRun2); sampleTaskchg->SetNCentBins(5); } } // Sample task - full jets AliAnalysisTaskEmcalJetSample* sampleTaskfull = NULL; if (bDoSample && bDoFullJets) { sampleTaskfull = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), name_clusters.Data(), name_cells.Data(), "SMPFULL"); sampleTaskfull->SetHistoBins(600, 0, 300); sampleTaskfull->SelectCollisionCandidates(kSel_full); sampleTaskfull->SetDebugLevel(debug); AliParticleContainer* sampleTaskfull_partCont = sampleTaskfull->GetParticleContainer(0); sampleTaskfull_partCont->SetParticlePtCut(0.15); AliClusterContainer* sampleTaskfull_clusCont = sampleTaskfull->GetClusterContainer(0); sampleTaskfull_clusCont->SetClusECut(0.); sampleTaskfull_clusCont->SetClusPtCut(0.); sampleTaskfull_clusCont->SetClusNonLinCorrEnergyCut(0.); sampleTaskfull_clusCont->SetClusHadCorrEnergyCut(0.30); sampleTaskfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr); if (bDoEmbedding) { sampleTaskfull_partCont->SetIsEmbedding(kTRUE); sampleTaskfull_clusCont->SetIsEmbedding(kTRUE); } if ( pMultSelTask ) { sampleTaskfull->SetUseNewCentralityEstimation(bIsRun2); sampleTaskfull->SetNCentBins(5); } } //### CDF task - charged jets AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg = NULL; AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg_MC = NULL; if (bDoCDF && bDoChargedJets) { anaTaskCDFchg = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), "", "", "", "CDFchg" ); anaTaskCDFchg->SetHistoBins(600, 0, 300); anaTaskCDFchg->SelectCollisionCandidates(kSel_chg); anaTaskCDFchg->SetDebugLevel(debug); AliParticleContainer* anaTaskCDFchg_partCont = anaTaskCDFchg->GetParticleContainer(0); anaTaskCDFchg_partCont->SetParticlePtCut(0.15); if (bDoEmbedding) { anaTaskCDFchg_partCont->SetIsEmbedding(kTRUE); } if ( pMultSelTask ) { anaTaskCDFchg->SetUseNewCentralityEstimation(bIsRun2); anaTaskCDFchg->SetNCentBins(5); anaTaskCDFchg->SetCentralityEstimator(cent_est_chg.Data()); } //################################################# if (isMC){ anaTaskCDFchg_MC = CDF::AddTaskEmcalJetCDF ( mc_container.Data(), "", "", "", "CDFchgMC" ); anaTaskCDFchg_MC->SetHistoBins(600, 0, 300); anaTaskCDFchg_MC->SelectCollisionCandidates(kSel_chg); anaTaskCDFchg_MC->SetDebugLevel(debug); AliParticleContainer* anaTaskCDFchg_partCont_MC = anaTaskCDFchg_MC->GetMCParticleContainer(0); anaTaskCDFchg_partCont->SetParticlePtCut(0.15); if (bDoEmbedding) { anaTaskCDFchg_partCont_MC->SetIsEmbedding(kTRUE); } if ( pMultSelTask ) { anaTaskCDFchg_MC->SetUseNewCentralityEstimation(bIsRun2); anaTaskCDFchg_MC->SetNCentBins(5); anaTaskCDFchg_MC->SetCentralityEstimator(cent_est_chg.Data()); } } } //### CDF task - full jets AliAnalysisTaskEmcalJetCDF* anaTaskCDFfull = NULL; if (bDoCDF && bDoFullJets) { anaTaskCDFfull = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), name_clusters.Data(), name_cells.Data(), mc_container.Data(), "CDFfull" ); anaTaskCDFfull->SetHistoBins(600, 0, 300); anaTaskCDFfull->SelectCollisionCandidates(kSel_full); anaTaskCDFfull->SetDebugLevel(debug); AliParticleContainer* anaTaskCDFfull_partCont = anaTaskCDFfull->GetParticleContainer(0); anaTaskCDFfull_partCont->SetParticlePtCut(0.15); AliClusterContainer* anaTaskCDFfull_clusCont = anaTaskCDFfull->GetClusterContainer(0); anaTaskCDFfull_clusCont->SetClusECut(0.); anaTaskCDFfull_clusCont->SetClusPtCut(0.); anaTaskCDFfull_clusCont->SetClusNonLinCorrEnergyCut(0.); anaTaskCDFfull_clusCont->SetClusHadCorrEnergyCut(0.30); anaTaskCDFfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr); if (bDoEmbedding) { anaTaskCDFfull_partCont->SetIsEmbedding(kTRUE); anaTaskCDFfull_clusCont->SetIsEmbedding(kTRUE); } if ( pMultSelTask ) { anaTaskCDFfull->SetUseNewCentralityEstimation(bIsRun2); anaTaskCDFfull->SetNCentBins(5); anaTaskCDFfull->SetCentralityEstimator(cent_est_full.Data()); } } //######################## // ANALYSIS TASKS - CONTAINERS SETUP //######################## // AliEmcalJetTask* pChJet02Task_MC = NULL; // AliEmcalJetTask* pChJet04Task_MC = NULL; // add jet containers to CDF task for charged jets if (bDoChargedJets && bDoCDF) { AliJetContainer* jetcont_chg = NULL; for ( Float_t fi = 0 ; fi<=100 ; fi+=10) { // CHG JETS 0.2 jetcont_chg = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet"); CDF::jetContSetParams (jetcont_chg, fi, fi+10, 0, 0); // CHG JETS 0.4 jetcont_chg = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet"); CDF::jetContSetParams (jetcont_chg, fi, fi+10, 0, 0); if (isMC) { // CHG JETS MC 0.2 jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets); CDF::jetContSetParams (jetcont_chg, fi, fi+10, 0, 0); // CHG JETS MC 0.4 jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets); CDF::jetContSetParams (jetcont_chg, fi, fi+10, 0, 0); } } jetcont_chg = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet"); CDF::jetContSetParams (jetcont_chg, 1., 500., 0, 0); jetcont_chg = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet"); CDF::jetContSetParams (jetcont_chg, 1., 500., 0, 0); if (isMC) { jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets); CDF::jetContSetParams (jetcont_chg, 1., 500., 0, 0); jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets); CDF::jetContSetParams (jetcont_chg, 1., 500., 0, 0); } jetcont_chg = NULL; } // add jet containers to CDF task for full jets if (bDoFullJets && bDoCDF) { AliJetContainer* jetcont_full = NULL; for ( Float_t fi = 0 ; fi<=100 ; fi+=10) { // FULL JETS 0.2 jetcont_full = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet"); CDF::jetContSetParams (jetcont_full, fi, fi+10, 0, 2); // FULL JETS 0.4 jetcont_full = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet"); CDF::jetContSetParams (jetcont_full, fi, fi+10, 0, 2); if (isMC) { // CHG JETS MC 0.2 jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets); CDF::jetContSetParams (jetcont_full, fi, fi+10, 0, 0); // CHG JETS MC 0.4 jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets); CDF::jetContSetParams (jetcont_full, fi, fi+10, 0, 0); } } jetcont_full = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet"); CDF::jetContSetParams (jetcont_full, 1., 500., 0, 2); jetcont_full = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet"); CDF::jetContSetParams (jetcont_full, 1., 500., 0, 2); if (isMC) { jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets); CDF::jetContSetParams (jetcont_full, 1., 500., 0, 0); jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets); CDF::jetContSetParams (jetcont_full, 1., 500., 0, 0); } jetcont_full = NULL; } // add jet containers to sample task for charged jets if (bDoChargedJets && bDoSample) { AliJetContainer* jetCont02chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet"); AliJetContainer* jetCont04chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet"); if (iBeamType != AliAnalysisTaskEmcal::kpp) { jetCont02chg_sample->SetRhoName(sRhoChName); jetCont02chg_sample->SetPercAreaCut(0.6); jetCont04chg_sample->SetRhoName(sRhoChName); jetCont04chg_sample->SetPercAreaCut(0.6); } } // add jet containers to sample task for full jets if (bDoFullJets && bDoSample) { AliJetContainer* jetCont02full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet"); AliJetContainer* jetCont04full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet"); if (iBeamType != AliAnalysisTaskEmcal::kpp) { jetCont02full_sample->SetRhoName(sRhoFuName); jetCont02full_sample->SetPercAreaCut(0.6); jetCont04full_sample->SetRhoName(sRhoFuName); jetCont04full_sample->SetPercAreaCut(0.6); } } TObjArray* tasks_list = pMgr->GetTasks(); TIter task_iter (tasks_list); AliAnalysisTaskSE* task = NULL; while (( task = dynamic_cast<AliAnalysisTaskSE*>(task_iter.Next()) )) { if (task->InheritsFrom("AliAnalysisTaskEmcal")) { Printf("Setting beam type %d for task %s", iBeamType, static_cast<AliAnalysisTaskEmcal*>(task)->GetName()); static_cast<AliAnalysisTaskEmcal*>(task)->SetForceBeamType(iBeamType); } } // Let's start ######################################################################################################### if ( !pMgr->InitAnalysis() ) { std::cout << ">>>>>>>>>>>>>> AliAnalysisManager Initialising FAILED!!! " << std::endl; return NULL; } std::cout << "##-->> Initialising Analysis :: Status :" << std::endl; pMgr->PrintStatus(); pMgr->SetUseProgressBar(bUseProgBar, 100); // task profiling if ( kUseSysInfo > 0 ) { for ( int i = 0; i < pMgr->GetTopTasks()->GetEntries(); i++ ) { pMgr->ProfileTask (i); } } CDF::SaveManager("train.root"); if ( ManagerMode == AnalysisType::local ) { // start local analysis // enable class level debugging for these classes if ( debug > 2 ) { // pMgr->AddClassDebug("AliJetContainer", 100); // pMgr->AddClassDebug("AliEmcalJetTask", 100); if (bDoCDF) { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetCDF", 100); } if (bDoSample) { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetSample", 100); } } TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles); if (!pChain) { std::cout << ">>>>>>>>>>>>>> CHAIN NOT CREATED <<<<<<<<<<<<<<" << std::endl; return NULL; } // start analysis Printf("Starting LOCAL Analysis..."); pMgr->StartAnalysis( cAnalysisType, pChain, iNumEvents ); } if ( ManagerMode == AnalysisType::grid ) { // start grid analysis // start analysis Printf("Starting GRID Analysis..."); ListLibs += kGridExtraFiles; if ( ListLibs.Length() ) { plugin->SetAdditionalLibs ( ListLibs.Data() ); } if ( ListLibsExtra.Length() ) { plugin->SetAdditionalRootLibs ( ListLibsExtra.Data() ); } if ( PluginMode == PluginType::test ) { plugin->StartAnalysis(iNumEvents); } else { pMgr->SetDebugLevel(0); plugin->StartAnalysis(); } } cout << "END of EmcalJetCDF.C" << std::endl; return pMgr; }
void main (int argc, char *argv[]) { char so4_buffer[SO4_SIZE]; char so2_molecule[SO2_SIZE] = {'S', 'O', '2'}; char o2_molecule[O2_SIZE] = {'O', '2'}; mbox_t h_mbox_so4; // Handle to the mailbox for so4 mbox_t h_mbox_so2; mbox_t h_mbox_o2; sem_t s_procs_completed; // Semaphore to signal the original process that we're done if (argc != 5) { Printf("Usage: %s <mailbox so4> <mailbox so2> <mailbox o2> <handle_to_page_mapped_semaphore>\n"); Exit(); } // Convert the command-line strings into integers for use as handles h_mbox_so4 = dstrtol(argv[1], NULL, 10); // The "10" means base 10 h_mbox_so2 = dstrtol(argv[2], NULL, 10); // The "10" means base 10 h_mbox_o2 = dstrtol(argv[3], NULL, 10); // The "10" means base 10 s_procs_completed = dstrtol(argv[4], NULL, 10); // Open the so4 mailbox if (mbox_open(h_mbox_so4) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not open the so4 mailbox!\n", getpid()); Exit(); } // Wait for the SO4 molecule from the mailbox if (mbox_recv(h_mbox_so4, SO4_SIZE, (void *) so4_buffer) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not receive message from the mbox %d!\n", getpid(), h_mbox_so4); Exit(); } // Close the SO4 mailbox if (mbox_close(h_mbox_so4) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Open the SO2 mailbox if (mbox_open(h_mbox_so2) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not open the so2 mailbox!\n", getpid()); Exit(); } // Send the SO2 to the SO2 mailbox if (mbox_send(h_mbox_so2, SO2_SIZE, (void *) so2_molecule) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_so2); Exit(); } // Close the SO2 mailbox if (mbox_close(h_mbox_so2) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Open the o2 mailbox if (mbox_open(h_mbox_o2) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not open the o2 mailbox!\n", getpid()); Exit(); } // Send the o2 to the o2 mailbox if (mbox_send(h_mbox_o2, O2_SIZE, (void *) o2_molecule) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_o2); Exit(); } // Close the o2 mailbox if (mbox_close(h_mbox_o2) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Now print a message to show that everything worked Printf("A molecule SO2 has been generated\n"); Printf("A molecule O2 has been generated\n"); // Signal the semaphore to tell the original process that we're done if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("Reaction 2 (%d): Bad semaphore s_procs_completed (%d)!\n", getpid(), s_procs_completed); Exit(); } Printf("Reaction 2 (%d): Done!\n", getpid()); }
void G_FinishTravel () { TThinkerIterator<APlayerPawn> it (STAT_TRAVELLING); APlayerPawn *pawn, *pawndup, *oldpawn, *next; AInventory *inv; FPlayerStart *start; int pnum; next = it.Next (); while ( (pawn = next) != NULL) { next = it.Next (); pnum = int(pawn->player - players); pawn->ChangeStatNum (STAT_PLAYER); pawndup = pawn->player->mo; assert (pawn != pawndup); start = G_PickPlayerStart(pnum, 0); if (start == NULL) { if (pawndup != nullptr) { Printf(TEXTCOLOR_RED "No player %d start to travel to!\n", pnum + 1); // Move to the coordinates this player had when they left the level. pawn->SetXYZ(pawndup->Pos()); } else { // Could not find a start for this player at all. This really should never happen but if it does, let's better abort. DThinker::DestroyThinkersInList(STAT_TRAVELLING); I_Error ("No player %d start to travel to!\n", pnum + 1); } } oldpawn = pawndup; // The player being spawned here is a short lived dummy and // must not start any ENTER script or big problems will happen. pawndup = P_SpawnPlayer(start, pnum, SPF_TEMPPLAYER); if (pawndup != NULL) { if (!(changeflags & CHANGELEVEL_KEEPFACING)) { pawn->Angles = pawndup->Angles; } pawn->SetXYZ(pawndup->Pos()); pawn->Vel = pawndup->Vel; pawn->Sector = pawndup->Sector; pawn->floorz = pawndup->floorz; pawn->ceilingz = pawndup->ceilingz; pawn->dropoffz = pawndup->dropoffz; pawn->floorsector = pawndup->floorsector; pawn->floorpic = pawndup->floorpic; pawn->floorterrain = pawndup->floorterrain; pawn->ceilingsector = pawndup->ceilingsector; pawn->ceilingpic = pawndup->ceilingpic; pawn->Floorclip = pawndup->Floorclip; pawn->waterlevel = pawndup->waterlevel; } else { P_FindFloorCeiling(pawn); } pawn->target = NULL; pawn->lastenemy = NULL; pawn->player->mo = pawn; pawn->player->camera = pawn; pawn->player->viewheight = pawn->ViewHeight; pawn->flags2 &= ~MF2_BLASTED; if (oldpawn != nullptr) { DObject::StaticPointerSubstitution (oldpawn, pawn); oldpawn->Destroy(); } if (pawndup != NULL) { pawndup->Destroy(); } pawn->LinkToWorld (); pawn->ClearInterpolation(); pawn->AddToHash (); pawn->SetState(pawn->SpawnState); pawn->player->SendPitchLimits(); for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory) { inv->ChangeStatNum (STAT_INVENTORY); inv->LinkToWorld (); inv->Travelled (); } if (ib_compatflags & BCOMPATF_RESETPLAYERSPEED) { pawn->Speed = pawn->GetDefault()->Speed; } if (level.FromSnapshot) { FBehavior::StaticStartTypedScripts (SCRIPT_Return, pawn, true); // [Nash] run REOPEN scripts upon map re-entry FBehavior::StaticStartTypedScripts(SCRIPT_Reopen, NULL, false); } } bglobal.FinishTravel (); // make sure that, after travelling has completed, no travelling thinkers are left. // Since this list is excluded from regular thinker cleaning, anything that may survive through here // will endlessly multiply and severely break the following savegames or just simply crash on broken pointers. DThinker::DestroyThinkersInList(STAT_TRAVELLING); }
void wait() { asem.wait(); Printf(Con,"wait()\n"); }
void G_DoLoadLevel (int position, bool autosave) { static int lastposition = 0; gamestate_t oldgs = gamestate; int i; if (NextSkill >= 0) { UCVarValue val; val.Int = NextSkill; gameskill.ForceSet (val, CVAR_Int); NextSkill = -1; } if (position == -1) position = lastposition; else lastposition = position; G_InitLevelLocals (); StatusBar->DetachAllMessages (); // Force 'teamplay' to 'true' if need be. if (level.flags2 & LEVEL2_FORCETEAMPLAYON) teamplay = true; // Force 'teamplay' to 'false' if need be. if (level.flags2 & LEVEL2_FORCETEAMPLAYOFF) teamplay = false; FString mapname = level.MapName; mapname.ToLower(); Printf ( "\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" "\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n" TEXTCOLOR_BOLD "%s - %s\n\n", mapname.GetChars(), level.LevelName.GetChars()); if (wipegamestate == GS_LEVEL) wipegamestate = GS_FORCEWIPE; if (gamestate != GS_TITLELEVEL) { gamestate = GS_LEVEL; } // Set the sky map. // First thing, we have a dummy sky texture name, // a flat. The data is in the WAD only because // we look for an actual index, instead of simply // setting one. skyflatnum = TexMan.GetTexture (gameinfo.SkyFlatName, FTexture::TEX_Flat, FTextureManager::TEXMAN_Overridable); // DOOM determines the sky texture to be used // depending on the current episode and the game version. // [RH] Fetch sky parameters from FLevelLocals. sky1texture = level.skytexture1; sky2texture = level.skytexture2; // [RH] Set up details about sky rendering R_InitSkyMap (); for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && (deathmatch || players[i].playerstate == PST_DEAD)) players[i].playerstate = PST_ENTER; // [BC] memset (players[i].frags,0,sizeof(players[i].frags)); if (!(dmflags2 & DF2_YES_KEEPFRAGS) && (alwaysapplydmflags || deathmatch)) players[i].fragcount = 0; } if (changeflags & CHANGELEVEL_NOMONSTERS) { level.flags2 |= LEVEL2_NOMONSTERS; } else { level.flags2 &= ~LEVEL2_NOMONSTERS; } if (changeflags & CHANGELEVEL_PRERAISEWEAPON) { level.flags2 |= LEVEL2_PRERAISEWEAPON; } level.maptime = 0; P_SetupLevel (level.MapName, position); AM_LevelInit(); // [RH] Start lightning, if MAPINFO tells us to if (level.flags & LEVEL_STARTLIGHTNING) { P_StartLightning (); } gameaction = ga_nothing; // clear cmd building stuff ResetButtonStates (); SendItemUse = NULL; SendItemDrop = NULL; mousex = mousey = 0; sendpause = sendsave = sendturn180 = SendLand = false; LocalViewAngle = 0; LocalViewPitch = 0; paused = 0; //Added by MC: Initialize bots. if (deathmatch) { bglobal.Init (); } if (timingdemo) { static bool firstTime = true; if (firstTime) { starttime = I_GetTime (false); firstTime = false; } } level.starttime = gametic; G_UnSnapshotLevel (!savegamerestore); // [RH] Restore the state of the level. G_FinishTravel (); // For each player, if they are viewing through a player, make sure it is themselves. for (int ii = 0; ii < MAXPLAYERS; ++ii) { if (playeringame[ii] && (players[ii].camera == NULL || players[ii].camera->player != NULL)) { players[ii].camera = players[ii].mo; } } StatusBar->AttachToPlayer (&players[consoleplayer]); P_DoDeferedScripts (); // [RH] Do script actions that were triggered on another map. if (demoplayback || oldgs == GS_STARTUP || oldgs == GS_TITLELEVEL) C_HideConsole (); C_FlushDisplay (); // [RH] Always save the game when entering a new level. if (autosave && !savegamerestore && disableautosave < 1) { DAutosaver GCCNOWARN *dummy = new DAutosaver; } }
void CheckCompatibility(MapData *map) { FMD5Holder md5; FCompatValues *flags; bool onlyparams = true; // When playing Doom IWAD levels force COMPAT_SHORTTEX and COMPATF_LIGHT. // I'm not sure if the IWAD maps actually need COMPATF_LIGHT but it certainly does not hurt. // TNT's MAP31 also needs COMPATF_STAIRINDEX but that only gets activated for TNT.WAD. if (Wads.GetLumpFile(map->lumpnum) == 1 && (gameinfo.flags & GI_COMPATSHORTTEX) && level.maptype == MAPTYPE_DOOM) { ii_compatflags = COMPATF_SHORTTEX|COMPATF_LIGHT; if (gameinfo.flags & GI_COMPATSTAIRS) ii_compatflags |= COMPATF_STAIRINDEX; ii_compatflags2 = 0; ib_compatflags = 0; ii_compatparams = -1; } else if (Wads.GetLumpFile(map->lumpnum) == 1 && (gameinfo.flags & GI_COMPATPOLY1) && Wads.CheckLumpName(map->lumpnum, "MAP36")) { ii_compatflags = COMPATF_POLYOBJ; ii_compatflags2 = 0; ib_compatflags = 0; ii_compatparams = -1; } else if (Wads.GetLumpFile(map->lumpnum) == 2 && (gameinfo.flags & GI_COMPATPOLY2) && Wads.CheckLumpName(map->lumpnum, "MAP47")) { ii_compatflags = COMPATF_POLYOBJ; ii_compatflags2 = 0; ib_compatflags = 0; ii_compatparams = -1; } else { onlyparams = false; } map->GetChecksum(md5.Bytes); flags = BCompatMap.CheckKey(md5); if (developer >= DMSG_NOTIFY) { Printf("MD5 = "); for (size_t j = 0; j < sizeof(md5.Bytes); ++j) { Printf("%02X", md5.Bytes[j]); } if (flags != NULL) { Printf(", cflags = %08x, cflags2 = %08x, bflags = %08x\n", flags->CompatFlags[SLOT_COMPAT], flags->CompatFlags[SLOT_COMPAT2], flags->CompatFlags[SLOT_BCOMPAT]); } else { Printf("\n"); } } if (flags != NULL) { if (!onlyparams) { ii_compatflags = flags->CompatFlags[SLOT_COMPAT]; ii_compatflags2 = flags->CompatFlags[SLOT_COMPAT2]; ib_compatflags = flags->CompatFlags[SLOT_BCOMPAT]; } ii_compatparams = flags->ExtCommandIndex; } else { if (!onlyparams) { ii_compatflags = 0; ii_compatflags2 = 0; ib_compatflags = 0; } ii_compatparams = -1; } // Reset i_compatflags compatflags.Callback(); compatflags2.Callback(); // Set floatbob compatibility for all maps with an original Hexen MAPINFO. if (level.flags2 & LEVEL2_HEXENHACK) { ib_compatflags |= BCOMPATF_FLOATBOB; } }
void TracePC::PrintModuleInfo() { if (NumGuards) { Printf("INFO: Loaded %zd modules (%zd guards): ", NumModules, NumGuards); for (size_t i = 0; i < NumModules; i++) Printf("%zd [%p, %p), ", Modules[i].Stop - Modules[i].Start, Modules[i].Start, Modules[i].Stop); Printf("\n"); } if (NumModulesWithInline8bitCounters) { Printf("INFO: Loaded %zd modules (%zd inline 8-bit counters): ", NumModulesWithInline8bitCounters, NumInline8bitCounters); for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) Printf("%zd [%p, %p), ", ModuleCounters[i].Stop - ModuleCounters[i].Start, ModuleCounters[i].Start, ModuleCounters[i].Stop); Printf("\n"); } if (NumPCTables) { Printf("INFO: Loaded %zd PC tables (%zd PCs): ", NumPCTables, NumPCsInPCTables); for (size_t i = 0; i < NumPCTables; i++) { Printf("%zd [%p,%p), ", ModulePCTable[i].Stop - ModulePCTable[i].Start, ModulePCTable[i].Start, ModulePCTable[i].Stop); } Printf("\n"); if ((NumGuards && NumGuards != NumPCsInPCTables) || (NumInline8bitCounters && NumInline8bitCounters != NumPCsInPCTables)) { Printf("ERROR: The size of coverage PC tables does not match the" " number of instrumented PCs. This might be a bug in the compiler," " please contact the libFuzzer developers.\n"); _Exit(1); } } if (size_t NumClangCounters = ClangCountersEnd() - ClangCountersBegin()) Printf("INFO: %zd Clang Coverage Counters\n", NumClangCounters); }
void Show(R r) { for(; +r ;++r) Printf(Con,"#; ",*r); Putch(Con,'\n'); }